Skip to content

Commit d4c32a2

Browse files
authored
Merge pull request #9774 from sbidoul/warn-on-pep517-build-global-option
2 parents e6a65fc + 7c6ee48 commit d4c32a2

File tree

4 files changed

+28
-11
lines changed

4 files changed

+28
-11
lines changed

news/9774.feature.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Warn instead of erroring out when doing a PEP 517 build in presence of
2+
``--build-option``. Warn when doing a PEP 517 build in presence of
3+
``--global-option``.

src/pip/_internal/operations/build/wheel.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22
import os
3-
from typing import List, Optional
3+
from typing import Optional
44

55
from pip._vendor.pep517.wrappers import Pep517HookCaller
66

@@ -13,7 +13,6 @@ def build_wheel_pep517(
1313
name, # type: str
1414
backend, # type: Pep517HookCaller
1515
metadata_directory, # type: str
16-
build_options, # type: List[str]
1716
tempd, # type: str
1817
):
1918
# type: (...) -> Optional[str]
@@ -22,11 +21,6 @@ def build_wheel_pep517(
2221
Returns path to wheel if successfully built. Otherwise, returns None.
2322
"""
2423
assert metadata_directory is not None
25-
if build_options:
26-
# PEP 517 does not support --build-options
27-
logger.error('Cannot build wheel for %s using PEP 517 when '
28-
'--build-option is present', name)
29-
return None
3024
try:
3125
logger.debug('Destination directory: %s', tempd)
3226

src/pip/_internal/wheel_builder.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,18 @@ def _build_one_inside_env(
244244
if req.use_pep517:
245245
assert req.metadata_directory
246246
assert req.pep517_backend
247+
if global_options:
248+
logger.warning(
249+
'Ignoring --global-option when building %s using PEP 517', req.name
250+
)
251+
if build_options:
252+
logger.warning(
253+
'Ignoring --build-option when building %s using PEP 517', req.name
254+
)
247255
wheel_path = build_wheel_pep517(
248256
name=req.name,
249257
backend=req.pep517_backend,
250258
metadata_directory=req.metadata_directory,
251-
build_options=build_options,
252259
tempd=temp_dir.path,
253260
)
254261
else:

tests/functional/test_pep517.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,20 @@ def test_pep517_and_build_options(script, tmpdir, data, common_wheels):
263263
'--build-option', 'foo',
264264
'-f', common_wheels,
265265
project_dir,
266-
expect_error=True
267266
)
268-
assert 'Cannot build wheel' in result.stderr
269-
assert 'when --build-option is present' in result.stderr
267+
assert 'Ignoring --build-option when building' in result.stderr
268+
assert 'using PEP 517' in result.stderr
269+
270+
271+
@pytest.mark.network
272+
def test_pep517_and_global_options(script, tmpdir, data, common_wheels):
273+
"""Backend generated requirements are installed in the build env"""
274+
project_dir, name = make_pyproject_with_setup(tmpdir)
275+
result = script.pip(
276+
'wheel', '--wheel-dir', tmpdir,
277+
'--global-option', 'foo',
278+
'-f', common_wheels,
279+
project_dir,
280+
)
281+
assert 'Ignoring --global-option when building' in result.stderr
282+
assert 'using PEP 517' in result.stderr

0 commit comments

Comments
 (0)