blob: 0ed0c9177ffb3d0460c6be4c59d1e03e0ef66848 [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
Patrick Williamsdb4c27e2022-08-05 08:10:29 -050017Signed-off-by: Wang Mingyu <wangmy@fujitsu.com>
18---
19 src/pip/_internal/operations/install/wheel.py | 5 ++++-
20 src/pip/_internal/req/req_install.py | 5 ++++-
21 2 files changed, 8 insertions(+), 2 deletions(-)
22
23diff --git a/src/pip/_internal/operations/install/wheel.py b/src/pip/_internal/operations/install/wheel.py
24index 1af8978..3e48f9b 100644
25--- a/src/pip/_internal/operations/install/wheel.py
26+++ b/src/pip/_internal/operations/install/wheel.py
27@@ -434,6 +434,7 @@ def _install_wheel(
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000028 warn_script_location: bool = True,
29 direct_url: Optional[DirectUrl] = None,
30 requested: bool = False,
31+ root: str = None,
32 ) -> None:
33 """Install a wheel.
34
Patrick Williamsdb4c27e2022-08-05 08:10:29 -050035@@ -610,7 +611,7 @@ def _install_wheel(
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000036 with warnings.catch_warnings():
37 warnings.filterwarnings("ignore")
38 for path in pyc_source_file_paths():
39- success = compileall.compile_file(path, force=True, quiet=True)
40+ success = compileall.compile_file(path, force=True, quiet=True, stripdir=root)
41 if success:
42 pyc_path = pyc_output_path(path)
43 assert os.path.exists(pyc_path)
Patrick Williamsdb4c27e2022-08-05 08:10:29 -050044@@ -721,6 +722,7 @@ def install_wheel(
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000045 warn_script_location: bool = True,
46 direct_url: Optional[DirectUrl] = None,
47 requested: bool = False,
48+ root: str = None,
49 ) -> None:
50 with ZipFile(wheel_path, allowZip64=True) as z:
51 with req_error_context(req_description):
Patrick Williamsdb4c27e2022-08-05 08:10:29 -050052@@ -733,4 +735,5 @@ def install_wheel(
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000053 warn_script_location=warn_script_location,
54 direct_url=direct_url,
55 requested=requested,
56+ root=root,
57 )
Patrick Williamsdb4c27e2022-08-05 08:10:29 -050058diff --git a/src/pip/_internal/req/req_install.py b/src/pip/_internal/req/req_install.py
59index a1e376c..4c3f1bb 100644
60--- a/src/pip/_internal/req/req_install.py
61+++ b/src/pip/_internal/req/req_install.py
62@@ -779,7 +779,9 @@ class InstallRequirement:
63 assert self.local_file_path
64 direct_url = None
65 # TODO this can be refactored to direct_url = self.download_info
66- if self.editable:
67+ if '_PYTHON_SYSCONFIGDATA_NAME' in os.environ:
68+ direct_url = None
69+ elif self.editable:
70 direct_url = direct_url_for_editable(self.unpacked_source_directory)
71 elif self.original_link:
72 direct_url = direct_url_from_link(
73@@ -796,6 +798,7 @@ class InstallRequirement:
74 warn_script_location=warn_script_location,
75 direct_url=direct_url,
76 requested=self.user_supplied,
77+ root=root,
78 )
79 self.install_succeeded = True
80 return
81--
822.25.1
83