Skip to content

Commit

Permalink
Merge pull request #133 from sbidoul/add-supported-hooks-sbi
Browse files Browse the repository at this point in the history
Add _supported_features()
  • Loading branch information
takluyver authored Oct 18, 2021
2 parents e18227d + 95de24d commit 7452fa7
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pytest
pytest-flake8
flake8 < 4 # https://github.com/tholo/pytest-flake8/issues/81
pytest-forward-compatibility; python_version<'3'
mock ; python_version<'3.6'
testpath
Expand Down
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_features():
"""Return the list of options features supported by the backend.
Returns a list of strings.
The only possible value is 'build_editable'.
"""
backend = _build_backend()
features = []
if hasattr(backend, "build_editable"):
features.append("build_editable")
return features


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_features',
}


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

def _supported_features(self):
"""Return the list of optional features supported by the backend."""
return self._call_hook('_supported_features', {})

def get_requires_for_build_wheel(self, config_settings=None):
"""Identify packages required for building a wheel
Expand Down
15 changes: 15 additions & 0 deletions tests/test_call_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,18 @@ 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"]),
("pkg2", []),
("pkg3", ["build_editable"]),
],
)
def test__supported_features(pkg, expected):
hooks = get_hooks(pkg)
with modified_env({"PYTHONPATH": BUILDSYS_PKGS}):
res = hooks._supported_features()
assert res == expected

0 comments on commit 7452fa7

Please sign in to comment.