Skip to content

Commit c9df690

Browse files
authored
Merge pull request #6305 from pfmoore/pep517_build_options
Reject --build-options for PEP 517 builds
2 parents 62cfaf0 + 8b7c23d commit c9df690

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

news/6305.feature

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Using ``--build-options`` in a PEP 517 build now fails with an error,
2+
rather than silently ignoring the option.

src/pip/_internal/wheel.py

+5
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,11 @@ def _build_one_pep517(self, req, tempd, python_tag=None):
910910
Returns path to wheel if successfully built. Otherwise, returns None.
911911
"""
912912
assert req.metadata_directory is not None
913+
if self.build_options:
914+
# PEP 517 does not support --build-options
915+
logger.error('Cannot build wheel for %s using PEP 517 when '
916+
'--build-options is present' % (req.name,))
917+
return None
913918
try:
914919
req.spin_message = 'Building wheel for %s (PEP 517)' % (req.name,)
915920
logger.debug('Destination directory: %s', tempd)

tests/functional/test_pep517.py

+14
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,17 @@ def test_explicit_setuptools_backend(script, tmpdir, data, common_wheels):
198198
project_dir,
199199
)
200200
result.assert_installed(name, editable=False)
201+
202+
203+
def test_pep517_and_build_options(script, tmpdir, data, common_wheels):
204+
"""Backend generated requirements are installed in the build env"""
205+
project_dir, name = make_pyproject_with_setup(tmpdir)
206+
result = script.pip(
207+
'wheel', '--wheel-dir', tmpdir,
208+
'--build-option', 'foo',
209+
'-f', common_wheels,
210+
project_dir,
211+
expect_error=True
212+
)
213+
assert 'Cannot build wheel' in result.stderr
214+
assert 'when --build-options is present' in result.stderr

0 commit comments

Comments
 (0)