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

Respect --global-option and --install-option for VCS installs. #6389

Merged
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
2 changes: 2 additions & 0 deletions news/5518.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Respect ``--global-option`` and ``--install-option`` when installing from
a version control url (e.g. ``git``).
8 changes: 4 additions & 4 deletions src/pip/_internal/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,10 +763,6 @@ def should_use_ephemeral_cache(
if req.editable or not req.source_dir:
return None

if req.link and not req.link.is_artifact:
# VCS checkout. Build wheel just for this run.
return True

if "binary" not in format_control.get_allowed_formats(
canonicalize_name(req.name)):
logger.info(
Expand All @@ -775,6 +771,10 @@ def should_use_ephemeral_cache(
)
return None

if req.link and not req.link.is_artifact:
# VCS checkout. Build wheel just for this run.
return True

link = req.link
base, ext = link.splitext()
if cache_available and _contains_egg_info(base):
Expand Down
43 changes: 43 additions & 0 deletions tests/unit/test_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,49 @@ def test_should_use_ephemeral_cache__issue_6197(
assert ephem_cache is expected


@pytest.mark.parametrize(
"disallow_binaries, expected",
[
# By default (i.e. when binaries are allowed), VCS requirements
# should be built.
(False, True),
# Disallowing binaries, however, should cause them not to be built.
(True, None),
],
)
def test_should_use_ephemeral_cache__disallow_binaries_and_vcs_checkout(
disallow_binaries, expected,
):
"""
Test that disallowing binaries (e.g. from passing --global-option)
causes should_use_ephemeral_cache() to return None for VCS checkouts.
"""
req = Requirement('pendulum')
# Passing a VCS url causes link.is_artifact to return False.
link = Link(url='git+https://git.example.com/pendulum.git')
req = InstallRequirement(
req=req,
comes_from=None,
constraint=False,
editable=False,
link=link,
source_dir='/tmp/pip-install-9py5m2z1/pendulum',
)
assert not req.is_wheel
assert not req.link.is_artifact

format_control = FormatControl()
if disallow_binaries:
format_control.disallow_binaries()

# The cache_available value doesn't matter for this test.
ephem_cache = wheel.should_use_ephemeral_cache(
req, format_control=format_control, autobuilding=True,
cache_available=True,
)
assert ephem_cache is expected


def test_format_command_result__INFO(caplog):
caplog.set_level(logging.INFO)
actual = wheel.format_command_result(
Expand Down