Skip to content

Commit 813736b

Browse files
committed
Handle change to pip._internal.req.InstallRequirement.install signature
1 parent afbf444 commit 813736b

File tree

2 files changed

+56
-4
lines changed

2 files changed

+56
-4
lines changed

relenv/runtime.py

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -750,12 +750,39 @@ 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+
755+
@functools.wraps(func)
756+
def wrapper(
757+
self,
758+
root=None,
759+
home=None,
760+
prefix=None,
761+
warn_script_location=True,
762+
use_user_site=False,
763+
pycompile=True,
764+
):
765+
try:
766+
if TARGET.TARGET:
767+
TARGET.INSTALL = True
768+
home = TARGET.PATH
769+
return func(
770+
self,
771+
root,
772+
home,
773+
prefix,
774+
warn_script_location,
775+
use_user_site,
776+
pycompile,
777+
)
778+
finally:
779+
TARGET.INSTALL = False
780+
781+
elif mod.InstallRequirement.install.__code__.co_argcount == 8:
754782

755783
@functools.wraps(func)
756784
def wrapper(
757785
self,
758-
install_options,
759786
global_options=None,
760787
root=None,
761788
home=None,
@@ -770,7 +797,6 @@ def wrapper(
770797
home = TARGET.PATH
771798
return func(
772799
self,
773-
install_options,
774800
global_options,
775801
root,
776802
home,
@@ -783,10 +809,12 @@ def wrapper(
783809
TARGET.INSTALL = False
784810

785811
else:
812+
# Oldest version of this method sigature with 9 arguments.
786813

787814
@functools.wraps(func)
788815
def wrapper(
789816
self,
817+
install_options,
790818
global_options=None,
791819
root=None,
792820
home=None,
@@ -801,6 +829,7 @@ def wrapper(
801829
home = TARGET.PATH
802830
return func(
803831
self,
832+
install_options,
804833
global_options,
805834
root,
806835
home,
@@ -845,8 +874,8 @@ def install_cargo_config():
845874
# load the ssl module. Causing out setup_openssl method to fail to load
846875
# fips module.
847876
dirs = common().work_dirs()
848-
triplet = common().get_triplet()
849877
cargo_home = dirs.data / "cargo"
878+
triplet = common().get_triplet()
850879

851880
toolchain = common().get_toolchain()
852881
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)