Skip to content

Commit c09b0f7

Browse files
committed
Fix building for various packages.
1 parent e3d01eb commit c09b0f7

File tree

3 files changed

+46
-4
lines changed

3 files changed

+46
-4
lines changed

Lib/pip.py

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import warnings
77
import platform
88
import rebuildpython
9+
import re
910

1011
import __np__
1112
import __np__.packaging
@@ -29,6 +30,36 @@
2930
builtin_packages = ensurepip._get_packages()
3031

3132

33+
import pip._internal.utils.subprocess
34+
35+
call_subprocess_orig = pip._internal.utils.subprocess.call_subprocess
36+
37+
def our_call_subprocess(
38+
cmd,
39+
show_stdout = False,
40+
cwd = None,
41+
on_returncode = "raise",
42+
extra_ok_returncodes = None,
43+
extra_environ = None,
44+
unset_environ = None,
45+
spinner = None,
46+
log_failed_cmd = True,
47+
stdout_only = False,
48+
*,
49+
command_desc: str,
50+
):
51+
if extra_ok_returncodes is None:
52+
our_extra_ok_returncodes = []
53+
else:
54+
our_extra_ok_returncodes = list(extra_ok_returncodes)
55+
56+
# Some packages cause this error code to be returned even if all is ok.
57+
our_extra_ok_returncodes += [3221225477]
58+
return call_subprocess_orig(cmd, show_stdout, cwd, on_returncode, our_extra_ok_returncodes, extra_environ, unset_environ, spinner, log_failed_cmd, stdout_only, command_desc=command_desc)
59+
60+
pip._internal.utils.subprocess.call_subprocess = our_call_subprocess
61+
62+
3263
import pip._internal.pyproject
3364

3465
load_pyproject_toml_orig = pip._internal.pyproject.load_pyproject_toml
@@ -39,12 +70,14 @@ def our_load_pyproject_toml(use_pep517, pyproject_toml, setup_py, req_name):
3970
# We will be taking over the build process.
4071
if os.path.isfile(os.path.join(os.path.dirname(os.path.dirname(pyproject_toml)), "script.json")):
4172
return pip._internal.pyproject.BuildSystemDetails(
42-
[], "__np__.metabuild:managed_build", [], [real_pip_dir, os.path.dirname(__file__)])
73+
[], "__np__.metabuild:managed_build", [], [os.path.dirname(__file__), real_pip_dir])
4374

4475
result = load_pyproject_toml_orig(use_pep517, pyproject_toml, setup_py, req_name)
76+
if result is None:
77+
return None
4578
return pip._internal.pyproject.BuildSystemDetails(
4679
[x for x in result.requires if re.split(r'[><=]', x, 1)[0] not in builtin_packages],
47-
result.backend, result.check, result.backend_path + [real_pip_dir])
80+
result.backend, result.check, [os.path.dirname(__file__), real_pip_dir] + result.backend_path)
4881

4982

5083

Lib/rebuildpython.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def run_rebuild():
142142

143143
ext_suffix = get_config_var("SO" if str is bytes else "EXT_SUFFIX")
144144

145-
extra_scan_dirs = []
145+
extra_scan_dirs = [__np__.getDependencyInstallDir()]
146146
if platform.system() == "Windows":
147147
extra_scan_dirs.append(os.path.join(sysconfig.get_config_var('srcdir'), 'libs'))
148148

@@ -384,6 +384,10 @@ def run_rebuild():
384384
elif os.path.isfile(os.path.join(dir, lib) + ".lib"):
385385
final_path = os.path.join(dir, lib) + ".lib"
386386
break
387+
else:
388+
# System libraries need to not end in .lib since the linker will automatically append it.
389+
if final_path.endswith(".lib"):
390+
final_path = final_path[:-4]
387391
if final_path not in final_lib_list:
388392
final_lib_list.append(final_path)
389393

Lib/wheel.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import sys
3+
import sysconfig
34

45
# Make the standard wheel, the real wheel module.
56
# Need to keep a reference alive, or the module will loose all attributes.
@@ -14,5 +15,9 @@
1415
del sys.path[0]
1516
sys.modules["wheel"] = _wheel
1617

18+
def our_generic_abi():
19+
return [wheel.vendored.packaging.tags._normalize_string(sysconfig.get_config_var("SOABI"))]
20+
1721
import wheel.vendored.packaging.tags
18-
wheel.vendored.packaging.tags.INTERPRETER_SHORT_NAMES["nuitkapython"] = "np"
22+
wheel.vendored.packaging.tags._generic_abi = our_generic_abi
23+

0 commit comments

Comments
 (0)