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

Warn when doing a PEP 517 build in presence of --global-option #9774

Merged
merged 2 commits into from
Apr 14, 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
3 changes: 3 additions & 0 deletions news/9774.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Warn instead of erroring out when doing a PEP 517 build in presence of
``--build-option``. Warn when doing a PEP 517 build in presence of
``--global-option``.
8 changes: 1 addition & 7 deletions src/pip/_internal/operations/build/wheel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
import os
from typing import List, Optional
from typing import Optional

from pip._vendor.pep517.wrappers import Pep517HookCaller

Expand All @@ -13,7 +13,6 @@ def build_wheel_pep517(
name, # type: str
backend, # type: Pep517HookCaller
metadata_directory, # type: str
build_options, # type: List[str]
tempd, # type: str
):
# type: (...) -> Optional[str]
Expand All @@ -22,11 +21,6 @@ def build_wheel_pep517(
Returns path to wheel if successfully built. Otherwise, returns None.
"""
assert metadata_directory is not None
if build_options:
# PEP 517 does not support --build-options
logger.error('Cannot build wheel for %s using PEP 517 when '
'--build-option is present', name)
return None
try:
logger.debug('Destination directory: %s', tempd)

Expand Down
9 changes: 8 additions & 1 deletion src/pip/_internal/wheel_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,18 @@ 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
)
wheel_path = build_wheel_pep517(
name=req.name,
backend=req.pep517_backend,
metadata_directory=req.metadata_directory,
build_options=build_options,
tempd=temp_dir.path,
)
else:
Expand Down
19 changes: 16 additions & 3 deletions tests/functional/test_pep517.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,20 @@ def test_pep517_and_build_options(script, tmpdir, data, common_wheels):
'--build-option', 'foo',
'-f', common_wheels,
project_dir,
expect_error=True
)
assert 'Cannot build wheel' in result.stderr
assert 'when --build-option is present' in result.stderr
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