blob: 538bb94f7adb8a86b3aaa4d795cbc2fdd0e8bdc1 [file] [log] [blame]
Andrew Geissler7e0e3c02022-02-25 20:34:39 +00001Pip installed wheels are not reproducible currently. The direct_url
2files encode an installation path and the installed wheels compile
3the python files at their location, not their final install location
4which is incorrect.
5
6To fix this, simply disable the direct_urls and pass the "root" to
7the python compile function to strip that path out of the compiled
8files.
9
10A version of this patch, perhaps stripping root from the direct_urls
11may be something that could be considered by upstream.
12
13Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
14
15Upstream-Status: Pending
16
17Index: pip-22.0.3/src/pip/_internal/req/req_install.py
18===================================================================
19--- pip-22.0.3.orig/src/pip/_internal/req/req_install.py
20+++ pip-22.0.3/src/pip/_internal/req/req_install.py
21@@ -758,7 +758,9 @@ class InstallRequirement:
22 if self.is_wheel:
23 assert self.local_file_path
24 direct_url = None
25- if self.editable:
26+ if '_PYTHON_SYSCONFIGDATA_NAME' in os.environ:
27+ direct_url = None
28+ elif self.editable:
29 direct_url = direct_url_for_editable(self.unpacked_source_directory)
30 elif self.original_link:
31 direct_url = direct_url_from_link(
32@@ -775,6 +777,7 @@ class InstallRequirement:
33 warn_script_location=warn_script_location,
34 direct_url=direct_url,
35 requested=self.user_supplied,
36+ root=root,
37 )
38 self.install_succeeded = True
39 return
40Index: pip-22.0.3/src/pip/_internal/operations/install/wheel.py
41===================================================================
42--- pip-22.0.3.orig/src/pip/_internal/operations/install/wheel.py
43+++ pip-22.0.3/src/pip/_internal/operations/install/wheel.py
44@@ -436,6 +436,7 @@ def _install_wheel(
45 warn_script_location: bool = True,
46 direct_url: Optional[DirectUrl] = None,
47 requested: bool = False,
48+ root: str = None,
49 ) -> None:
50 """Install a wheel.
51
52@@ -612,7 +613,7 @@ def _install_wheel(
53 with warnings.catch_warnings():
54 warnings.filterwarnings("ignore")
55 for path in pyc_source_file_paths():
56- success = compileall.compile_file(path, force=True, quiet=True)
57+ success = compileall.compile_file(path, force=True, quiet=True, stripdir=root)
58 if success:
59 pyc_path = pyc_output_path(path)
60 assert os.path.exists(pyc_path)
61@@ -723,6 +724,7 @@ def install_wheel(
62 warn_script_location: bool = True,
63 direct_url: Optional[DirectUrl] = None,
64 requested: bool = False,
65+ root: str = None,
66 ) -> None:
67 with ZipFile(wheel_path, allowZip64=True) as z:
68 with req_error_context(req_description):
69@@ -735,4 +737,5 @@ def install_wheel(
70 warn_script_location=warn_script_location,
71 direct_url=direct_url,
72 requested=requested,
73+ root=root,
74 )