Skip to content

Commit

Permalink
Don't pass --cert to build subprocesses unless also given on CLI
Browse files Browse the repository at this point in the history
This fixes a regression introduced by commit 34fc0e2. After
that patch, --cert would always be given to the nested pip call, either
pointing to pip's CA bundle, or to whatever the user had set on the CLI.
This means truststore is always disabled... which is bad.

We used to have to do some shenanigans to pass the CA bundle to the
subprocess as certifi doesn't (didn't?) really play nice when in a
zipfile. Regardless, we stopped packing pip into a zipfile to provision
the build environment a while ago, so we can simply do the normal thing
and pass --cert when it's actually given. Otherwise, the subprocess will
find its CA bundle without fuss.

There apparently aren't any truststore tests (as testing system CAs is
probably a pain), so I didn't add one here either. At some point, we
should, though.
  • Loading branch information
ichard26 authored and sbidoul committed Feb 9, 2025
1 parent aea8629 commit ebd0a52
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions news/13186.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix regression where truststore would never be used while installing build dependencies.
5 changes: 2 additions & 3 deletions src/pip/_internal/build_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from types import TracebackType
from typing import TYPE_CHECKING, Iterable, List, Optional, Set, Tuple, Type, Union

from pip._vendor.certifi import where
from pip._vendor.packaging.version import Version

from pip import __file__ as pip_location
Expand Down Expand Up @@ -246,8 +245,6 @@ def _install_requirements(
# target from config file or env var should be ignored
"--target",
"",
"--cert",
finder.custom_cert or where(),
]
if logger.getEffectiveLevel() <= logging.DEBUG:
args.append("-vv")
Expand Down Expand Up @@ -276,6 +273,8 @@ def _install_requirements(
args.extend(["--proxy", finder.proxy])
for host in finder.trusted_hosts:
args.extend(["--trusted-host", host])
if finder.custom_cert:
args.extend(["--cert", finder.custom_cert])
if finder.client_cert:
args.extend(["--client-cert", finder.client_cert])
if finder.allow_all_prereleases:
Expand Down

0 comments on commit ebd0a52

Please sign in to comment.