From 7c6ee48b041972e067bf2f1211e25959f8b95982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Sun, 4 Apr 2021 14:39:24 +0200 Subject: [PATCH] PEP 517 build in presence of --global-option emits a warning So these are not ignored silently. --- news/9774.feature.rst | 3 ++- src/pip/_internal/wheel_builder.py | 4 ++++ tests/functional/test_pep517.py | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/news/9774.feature.rst b/news/9774.feature.rst index 298362f8be2..8baac5e967f 100644 --- a/news/9774.feature.rst +++ b/news/9774.feature.rst @@ -1,2 +1,3 @@ Warn instead of erroring out when doing a PEP 517 build in presence of -``--build-option``. +``--build-option``. Warn when doing a PEP 517 build in presence of +``--global-option``. diff --git a/src/pip/_internal/wheel_builder.py b/src/pip/_internal/wheel_builder.py index c2cbf1eebb7..92f172bca16 100644 --- a/src/pip/_internal/wheel_builder.py +++ b/src/pip/_internal/wheel_builder.py @@ -244,6 +244,10 @@ def _build_one_inside_env( if req.use_pep517: assert req.metadata_directory assert req.pep517_backend + if global_options: + logger.warning( + 'Ignoring --global-option when building %s using PEP 517', req.name + ) if build_options: logger.warning( 'Ignoring --build-option when building %s using PEP 517', req.name diff --git a/tests/functional/test_pep517.py b/tests/functional/test_pep517.py index ae747d9fda1..4458a7ad56e 100644 --- a/tests/functional/test_pep517.py +++ b/tests/functional/test_pep517.py @@ -266,3 +266,17 @@ def test_pep517_and_build_options(script, tmpdir, data, common_wheels): ) assert 'Ignoring --build-option when building' in result.stderr assert 'using PEP 517' in result.stderr + + +@pytest.mark.network +def test_pep517_and_global_options(script, tmpdir, data, common_wheels): + """Backend generated requirements are installed in the build env""" + project_dir, name = make_pyproject_with_setup(tmpdir) + result = script.pip( + 'wheel', '--wheel-dir', tmpdir, + '--global-option', 'foo', + '-f', common_wheels, + project_dir, + ) + assert 'Ignoring --global-option when building' in result.stderr + assert 'using PEP 517' in result.stderr