Skip to content

Commit 7b162b1

Browse files
committed
Handle change to pip._internal.req.InstallRequirement.install signature
1 parent 06a6132 commit 7b162b1

File tree

2 files changed

+61
-6
lines changed

2 files changed

+61
-6
lines changed

relenv/runtime.py

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ def wrapper(*args, **kwargs):
613613
return func(*args, **kwargs)
614614
base_dir = common().DATA_DIR / "toolchain"
615615
toolchain = base_dir / common().get_triplet()
616-
cargo_home = str(common().DATA_DIR / "cargo")
616+
cargo_home = install_cargo_config.tmpdir.name
617617
if not toolchain.exists():
618618
debug("Unable to set CARGO_HOME no toolchain exists")
619619
else:
@@ -750,12 +750,38 @@ def wrap_req_install(name):
750750
mod = importlib.import_module(name)
751751

752752
def wrap(func):
753-
if mod.InstallRequirement.install.__code__.co_argcount == 9:
753+
if mod.InstallRequirement.install.__code__.co_argcount == 7:
754+
@functools.wraps(func)
755+
def wrapper(
756+
self,
757+
root=None,
758+
home=None,
759+
prefix=None,
760+
warn_script_location=True,
761+
use_user_site=False,
762+
pycompile=True,
763+
):
764+
try:
765+
if TARGET.TARGET:
766+
TARGET.INSTALL = True
767+
home = TARGET.PATH
768+
return func(
769+
self,
770+
root,
771+
home,
772+
prefix,
773+
warn_script_location,
774+
use_user_site,
775+
pycompile,
776+
)
777+
finally:
778+
TARGET.INSTALL = False
779+
780+
elif mod.InstallRequirement.install.__code__.co_argcount == 8:
754781

755782
@functools.wraps(func)
756783
def wrapper(
757784
self,
758-
install_options,
759785
global_options=None,
760786
root=None,
761787
home=None,
@@ -770,7 +796,6 @@ def wrapper(
770796
home = TARGET.PATH
771797
return func(
772798
self,
773-
install_options,
774799
global_options,
775800
root,
776801
home,
@@ -783,10 +808,12 @@ def wrapper(
783808
TARGET.INSTALL = False
784809

785810
else:
811+
# Oldest version of this method sigature with 9 arguments.
786812

787813
@functools.wraps(func)
788814
def wrapper(
789815
self,
816+
install_options,
790817
global_options=None,
791818
root=None,
792819
home=None,
@@ -801,6 +828,7 @@ def wrapper(
801828
home = TARGET.PATH
802829
return func(
803830
self,
831+
install_options,
804832
global_options,
805833
root,
806834
home,
@@ -844,9 +872,13 @@ def install_cargo_config():
844872
# We need this as a late import for python < 3.12 becuase importing it will
845873
# load the ssl module. Causing out setup_openssl method to fail to load
846874
# fips module.
847-
dirs = common().work_dirs()
875+
import tempfile
876+
877+
install_cargo_config.tmpdir = tempfile.TemporaryDirectory(prefix="relenvcargo")
878+
cargo_home = pathlib.Path(install_cargo_config.tmpdir.name)
879+
848880
triplet = common().get_triplet()
849-
cargo_home = dirs.data / "cargo"
881+
# dirs = common().work_dirs()
850882

851883
toolchain = common().get_toolchain()
852884
if not toolchain:

tests/test_verify_build.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1859,3 +1859,26 @@ def test_import_ssl_module(pyexec):
18591859
assert proc.returncode == 0
18601860
assert proc.stdout.decode() == ""
18611861
assert proc.stderr.decode() == ""
1862+
1863+
1864+
@pytest.mark.skip_unless_on_linux
1865+
@pytest.mark.parametrize("pip_version", ["25.2", "25.3"])
1866+
def test_install_setuptools_25_2_to_25_3(pipexec, build, minor_version):
1867+
"""
1868+
Validate we handle the changes to pip._internal.req.InstallRequirement.install signature.
1869+
"""
1870+
subprocess.run(
1871+
[str(pipexec), "install", "--upgrade", "pip==25.2"],
1872+
check=True,
1873+
)
1874+
subprocess.run(
1875+
[
1876+
str(pipexec),
1877+
"install",
1878+
"--upgrade",
1879+
"--no-binary=:all:",
1880+
"--no-cache-dir",
1881+
"setuptools",
1882+
],
1883+
check=True,
1884+
)

0 commit comments

Comments
 (0)