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

Supply the extra pip args in the resolver. #6006

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions news/6006.feature.rst
@@ -0,0 +1 @@
Supply any ``--extra-pip-args`` also in the resolver steps.
1 change: 1 addition & 0 deletions pipenv/cli/command.py
Expand Up @@ -258,6 +258,7 @@ def upgrade(state, **kwargs):
dev=state.installstate.dev,
system=state.system,
lock_only=state.installstate.lock_only,
extra_pip_args=state.installstate.extra_pip_args,
)


Expand Down
2 changes: 2 additions & 0 deletions pipenv/routines/lock.py
Expand Up @@ -14,6 +14,7 @@ def do_lock(
write=True,
pypi_mirror=None,
categories=None,
extra_pip_args=None,
):
"""Executes the freeze functionality."""
if not pre:
Expand Down Expand Up @@ -74,6 +75,7 @@ def do_lock(
pipfile=packages,
lockfile=lockfile,
old_lock_data=old_lock_data,
extra_pip_args=extra_pip_args,
)

# Overwrite any category packages with default packages.
Expand Down
8 changes: 8 additions & 0 deletions pipenv/routines/update.py
@@ -1,3 +1,5 @@
import json
import os
import sys
from collections import defaultdict

Expand Down Expand Up @@ -62,6 +64,7 @@ def do_update(
pre=pre,
pypi_mirror=pypi_mirror,
write=not outdated,
extra_pip_args=extra_pip_args,
)
else:
upgrade(
Expand All @@ -75,6 +78,7 @@ def do_update(
index_url=index_url,
dev=dev,
lock_only=lock_only,
extra_pip_args=extra_pip_args,
)

if outdated:
Expand Down Expand Up @@ -110,6 +114,7 @@ def upgrade(
categories=None,
dev=False,
lock_only=False,
extra_pip_args=None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is extra_pip_args passed here? Is it a dict or a string?

Can you add a test for that? Or at least a comment?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it is a string, I'll revisit soon.

):
lockfile = project.lockfile()
if not pre:
Expand All @@ -123,6 +128,9 @@ def upgrade(
if index_url:
index_name = add_index_to_pipfile(project, index_url)

if extra_pip_args:
os.environ["PIPENV_EXTRA_PIP_ARGS"] = json.dumps(extra_pip_args)

package_args = list(packages) + [f"-e {pkg}" for pkg in editable_packages]

requested_install_reqs = defaultdict(dict)
Expand Down
11 changes: 10 additions & 1 deletion pipenv/utils/resolver.py
Expand Up @@ -261,6 +261,10 @@ def prepare_pip_args(self, use_pep517=None, build_isolation=True):
if self.pre:
pip_args.append("--pre")
pip_args.extend(["--cache-dir", self.project.s.PIPENV_CACHE_DIR])
extra_pip_args = os.environ.get("PIPENV_EXTRA_PIP_ARGS")
if extra_pip_args:
extra_pip_args = json.loads(extra_pip_args)
pip_args.extend(extra_pip_args)
return pip_args

@property # cached_property breaks authenticated private indexes
Expand Down Expand Up @@ -733,6 +737,7 @@ def venv_resolve_deps(
pipfile=None,
lockfile=None,
old_lock_data=None,
extra_pip_args=None,
):
"""
Resolve dependencies for a pipenv project, acts as a portal to the target environment.
Expand Down Expand Up @@ -784,7 +789,11 @@ def venv_resolve_deps(
os.environ["PIPENV_SITE_DIR"] = pipenv_site_dir
else:
os.environ.pop("PIPENV_SITE_DIR", None)
with console.status("Locking...", spinner=project.s.PIPENV_SPINNER) as st:
if extra_pip_args:
os.environ["PIPENV_EXTRA_PIP_ARGS"] = json.dumps(extra_pip_args)
with console.status(
f"Locking {category}...", spinner=project.s.PIPENV_SPINNER
) as st:
# This conversion is somewhat slow on local and file-type requirements since
# we now download those requirements / make temporary folders to perform
# dependency resolution on them, so we are including this step inside the
Expand Down