From b4e2463621de8cbb319e0e3fec0b9fc3f5f78777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Wed, 13 Oct 2021 22:35:45 +0200 Subject: [PATCH 1/2] Work around pytest-flake8 issue --- dev-requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/dev-requirements.txt b/dev-requirements.txt index 5c97f06..4404a51 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -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 From 95de24dacb876d496f64782fef160e5f348732c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Wed, 13 Oct 2021 22:35:32 +0200 Subject: [PATCH 2/2] Add _supported_features --- pep517/in_process/_in_process.py | 14 ++++++++++++++ pep517/wrappers.py | 4 ++++ tests/test_call_hooks.py | 15 +++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/pep517/in_process/_in_process.py b/pep517/in_process/_in_process.py index c7f5f05..954a4ab 100644 --- a/pep517/in_process/_in_process.py +++ b/pep517/in_process/_in_process.py @@ -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 @@ -312,6 +325,7 @@ def build_sdist(sdist_directory, config_settings): 'build_editable', 'get_requires_for_build_sdist', 'build_sdist', + '_supported_features', } diff --git a/pep517/wrappers.py b/pep517/wrappers.py index 52da22e..e031ed7 100644 --- a/pep517/wrappers.py +++ b/pep517/wrappers.py @@ -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 diff --git a/tests/test_call_hooks.py b/tests/test_call_hooks.py index 381fe33..0693b7d 100644 --- a/tests/test_call_hooks.py +++ b/tests/test_call_hooks.py @@ -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