Skip to content

Commit

Permalink
Add _supported_hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Oct 13, 2021
1 parent 9359590 commit 1b90a82
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pep517/in_process/_in_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,19 @@ def _build_backend():
return obj


def _supported_hooks():
"""Invoke the _supported_hooks pseudo hook.
Returns a list of strings.
"""
backend = _build_backend()
return [
hook_name
for hook_name in sorted(HOOK_NAMES)
if hook_name != "_supported_hooks" and hasattr(backend, hook_name)
]


def get_requires_for_build_wheel(config_settings):
"""Invoke the optional get_requires_for_build_wheel hook
Expand Down Expand Up @@ -312,6 +325,7 @@ def build_sdist(sdist_directory, config_settings):
'build_editable',
'get_requires_for_build_sdist',
'build_sdist',
'_supported_hooks',
}


Expand Down
3 changes: 3 additions & 0 deletions pep517/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ def subprocess_runner(self, runner):
finally:
self._subprocess_runner = prev

def _supported_hooks(self):
return self._call_hook('_supported_hooks', {})

def get_requires_for_build_wheel(self, config_settings=None):
"""Identify packages required for building a wheel
Expand Down
24 changes: 24 additions & 0 deletions tests/test_call_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,27 @@ def test_setup_py():
# Some versions of setuptools list setuptools itself here
res = [x for x in res if x != 'setuptools']
assert res == ['wheel']


@pytest.mark.parametrize(
("pkg", "expected"),
[
("pkg1", [
"build_editable",
"build_sdist",
"build_wheel",
"get_requires_for_build_editable",
"get_requires_for_build_sdist",
"get_requires_for_build_wheel",
"prepare_metadata_for_build_editable",
"prepare_metadata_for_build_wheel",
]),
("pkg2", ["build_sdist", "build_wheel"]),
("pkg3", ["build_editable", "build_sdist", "build_wheel"]),
],
)
def test__supported_hooks(pkg, expected):
hooks = get_hooks(pkg)
with modified_env({"PYTHONPATH": BUILDSYS_PKGS}):
res = hooks._supported_hooks()
assert res == expected

0 comments on commit 1b90a82

Please sign in to comment.