Skip to content

Commit

Permalink
pass --proxy option to build environment
Browse files Browse the repository at this point in the history
  • Loading branch information
martinezlc99 committed Nov 10, 2024
1 parent fe0925b commit 4bacbdf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions news/6018.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pass in command-line ``--proxy`` option to isolated build environment.
2 changes: 2 additions & 0 deletions src/pip/_internal/build_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ def _install_requirements(
args.append("--pre")
if finder.prefer_binary:
args.append("--prefer-binary")
if finder.proxy is not None:
args.extend(["--proxy", finder.proxy])
args.append("--")
args.extend(requirements)
extra_environ = {"_PIP_STANDALONE_CERT": where()}
Expand Down
1 change: 1 addition & 0 deletions src/pip/_internal/cli/req_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,4 +326,5 @@ def _build_package_finder(
link_collector=link_collector,
selection_prefs=selection_prefs,
target_python=target_python,
proxy=options.proxy,
)
6 changes: 6 additions & 0 deletions src/pip/_internal/index/package_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ def __init__(
format_control: Optional[FormatControl] = None,
candidate_prefs: Optional[CandidatePreferences] = None,
ignore_requires_python: Optional[bool] = None,
proxy: Optional[str] = None,
) -> None:
"""
This constructor is primarily meant to be used by the create() class
Expand Down Expand Up @@ -619,6 +620,9 @@ def __init__(
# These are boring links that have already been logged somehow.
self._logged_links: Set[Tuple[Link, LinkType, str]] = set()

# Send in proxy for build environment
self.proxy = proxy

# Don't include an allow_yanked default value to make sure each call
# site considers whether yanked releases are allowed. This also causes
# that decision to be made explicit in the calling code, which helps
Expand All @@ -629,6 +633,7 @@ def create(
link_collector: LinkCollector,
selection_prefs: SelectionPreferences,
target_python: Optional[TargetPython] = None,
proxy: Optional[str] = None,
) -> "PackageFinder":
"""Create a PackageFinder.
Expand All @@ -653,6 +658,7 @@ def create(
allow_yanked=selection_prefs.allow_yanked,
format_control=selection_prefs.format_control,
ignore_requires_python=selection_prefs.ignore_requires_python,
proxy=proxy,
)

@property
Expand Down

0 comments on commit 4bacbdf

Please sign in to comment.