summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/python
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2022-02-24 14:49:30 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-02-25 15:07:50 +0000
commit228c3b3562d7d3e31fa497a2a402f9f70f9a4472 (patch)
treed4cd8a601cb6fbd2ff2a3b27d2b952776df56601 /meta/recipes-devtools/python
parent3a4f842307e5cdf40b48baeac0f15e5bbee43760 (diff)
downloadpoky-228c3b3562d7d3e31fa497a2a402f9f70f9a4472.tar.gz
python3-pip: Improve reproducibility
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. (From OE-Core rev: 2c74d5346e7581949fbdebc4744c8317236221c3) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/python')
-rw-r--r--meta/recipes-devtools/python/python3-pip/reproducible.patch74
-rw-r--r--meta/recipes-devtools/python/python3-pip_22.0.3.bb1
2 files changed, 75 insertions, 0 deletions
diff --git a/meta/recipes-devtools/python/python3-pip/reproducible.patch b/meta/recipes-devtools/python/python3-pip/reproducible.patch
new file mode 100644
index 0000000000..538bb94f7a
--- /dev/null
+++ b/meta/recipes-devtools/python/python3-pip/reproducible.patch
@@ -0,0 +1,74 @@
1Pip 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 )
diff --git a/meta/recipes-devtools/python/python3-pip_22.0.3.bb b/meta/recipes-devtools/python/python3-pip_22.0.3.bb
index e02ea5bd3d..7eb9fb69ba 100644
--- a/meta/recipes-devtools/python/python3-pip_22.0.3.bb
+++ b/meta/recipes-devtools/python/python3-pip_22.0.3.bb
@@ -14,6 +14,7 @@ DEPENDS:append:class-native = " unzip-native"
14 14
15SRC_URI += "file://0001-change-shebang-to-python3.patch" 15SRC_URI += "file://0001-change-shebang-to-python3.patch"
16SRC_URI += "file://no_shebang_mangling.patch" 16SRC_URI += "file://no_shebang_mangling.patch"
17SRC_URI += "file://reproducible.patch"
17 18
18SRC_URI[sha256sum] = "f29d589df8c8ab99c060e68ad294c4a9ed896624f6368c5349d70aa581b333d0" 19SRC_URI[sha256sum] = "f29d589df8c8ab99c060e68ad294c4a9ed896624f6368c5349d70aa581b333d0"
19 20