Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add _supported_features() #133

Merged
merged 2 commits into from
Oct 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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