summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/python/python3-pip/reproducible.patch
blob: 0ed0c9177ffb3d0460c6be4c59d1e03e0ef66848 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
Pip installed wheels are not reproducible currently. The direct_url
files encode an installation path and the installed wheels compile
the python files at their location, not their final install location
which is incorrect.

To fix this, simply disable the direct_urls and pass the "root" to
the python compile function to strip that path out of the compiled
files.

A version of this patch, perhaps stripping root from the direct_urls
may be something that could be considered by upstream.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>

Upstream-Status: Pending

Signed-off-by: Wang Mingyu <wangmy@fujitsu.com>
---
 src/pip/_internal/operations/install/wheel.py | 5 ++++-
 src/pip/_internal/req/req_install.py          | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/pip/_internal/operations/install/wheel.py b/src/pip/_internal/operations/install/wheel.py
index 1af8978..3e48f9b 100644
--- a/src/pip/_internal/operations/install/wheel.py
+++ b/src/pip/_internal/operations/install/wheel.py
@@ -434,6 +434,7 @@ def _install_wheel(
     warn_script_location: bool = True,
     direct_url: Optional[DirectUrl] = None,
     requested: bool = False,
+    root: str = None,
 ) -> None:
     """Install a wheel.
 
@@ -610,7 +611,7 @@ def _install_wheel(
             with warnings.catch_warnings():
                 warnings.filterwarnings("ignore")
                 for path in pyc_source_file_paths():
-                    success = compileall.compile_file(path, force=True, quiet=True)
+                    success = compileall.compile_file(path, force=True, quiet=True, stripdir=root)
                     if success:
                         pyc_path = pyc_output_path(path)
                         assert os.path.exists(pyc_path)
@@ -721,6 +722,7 @@ def install_wheel(
     warn_script_location: bool = True,
     direct_url: Optional[DirectUrl] = None,
     requested: bool = False,
+    root: str = None,
 ) -> None:
     with ZipFile(wheel_path, allowZip64=True) as z:
         with req_error_context(req_description):
@@ -733,4 +735,5 @@ def install_wheel(
                 warn_script_location=warn_script_location,
                 direct_url=direct_url,
                 requested=requested,
+                root=root,
             )
diff --git a/src/pip/_internal/req/req_install.py b/src/pip/_internal/req/req_install.py
index a1e376c..4c3f1bb 100644
--- a/src/pip/_internal/req/req_install.py
+++ b/src/pip/_internal/req/req_install.py
@@ -779,7 +779,9 @@ class InstallRequirement:
             assert self.local_file_path
             direct_url = None
             # TODO this can be refactored to direct_url = self.download_info
-            if self.editable:
+            if '_PYTHON_SYSCONFIGDATA_NAME' in os.environ:
+                direct_url = None
+            elif self.editable:
                 direct_url = direct_url_for_editable(self.unpacked_source_directory)
             elif self.original_link:
                 direct_url = direct_url_from_link(
@@ -796,6 +798,7 @@ class InstallRequirement:
                 warn_script_location=warn_script_location,
                 direct_url=direct_url,
                 requested=self.user_supplied,
+                root=root,
             )
             self.install_succeeded = True
             return
-- 
2.25.1