From 4bacbdf683c5728a295b941f225503e3354b081b Mon Sep 17 00:00:00 2001 From: lcmartin Date: Sun, 10 Nov 2024 15:09:26 -0600 Subject: [PATCH 1/2] pass --proxy option to build environment --- news/6018.feature.rst | 1 + src/pip/_internal/build_env.py | 2 ++ src/pip/_internal/cli/req_command.py | 1 + src/pip/_internal/index/package_finder.py | 6 ++++++ 4 files changed, 10 insertions(+) create mode 100644 news/6018.feature.rst diff --git a/news/6018.feature.rst b/news/6018.feature.rst new file mode 100644 index 00000000000..905f9108a21 --- /dev/null +++ b/news/6018.feature.rst @@ -0,0 +1 @@ +Pass in command-line ``--proxy`` option to isolated build environment. \ No newline at end of file diff --git a/src/pip/_internal/build_env.py b/src/pip/_internal/build_env.py index 0f1e2667caf..90259d4ce3d 100644 --- a/src/pip/_internal/build_env.py +++ b/src/pip/_internal/build_env.py @@ -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()} diff --git a/src/pip/_internal/cli/req_command.py b/src/pip/_internal/cli/req_command.py index 92900f94ff4..87c75d2364c 100644 --- a/src/pip/_internal/cli/req_command.py +++ b/src/pip/_internal/cli/req_command.py @@ -326,4 +326,5 @@ def _build_package_finder( link_collector=link_collector, selection_prefs=selection_prefs, target_python=target_python, + proxy=options.proxy, ) diff --git a/src/pip/_internal/index/package_finder.py b/src/pip/_internal/index/package_finder.py index 0d65ce35f37..6bfb69fc8c1 100644 --- a/src/pip/_internal/index/package_finder.py +++ b/src/pip/_internal/index/package_finder.py @@ -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 @@ -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 @@ -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. @@ -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 From 6d916e3c0d450010d70dc4d0faf772e6f14b70f4 Mon Sep 17 00:00:00 2001 From: lcmartin Date: Sun, 10 Nov 2024 15:57:39 -0600 Subject: [PATCH 2/2] fix linter errors --- news/6018.feature.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/6018.feature.rst b/news/6018.feature.rst index 905f9108a21..1467dfa272e 100644 --- a/news/6018.feature.rst +++ b/news/6018.feature.rst @@ -1 +1 @@ -Pass in command-line ``--proxy`` option to isolated build environment. \ No newline at end of file +Pass in command-line ``--proxy`` option to isolated build environment.