diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-02-24 14:49:30 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-02-25 15:07:50 +0000 |
commit | 228c3b3562d7d3e31fa497a2a402f9f70f9a4472 (patch) | |
tree | d4cd8a601cb6fbd2ff2a3b27d2b952776df56601 /meta/recipes-devtools/python | |
parent | 3a4f842307e5cdf40b48baeac0f15e5bbee43760 (diff) | |
download | poky-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.patch | 74 | ||||
-rw-r--r-- | meta/recipes-devtools/python/python3-pip_22.0.3.bb | 1 |
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 @@ | |||
1 | Pip installed wheels are not reproducible currently. The direct_url | ||
2 | files encode an installation path and the installed wheels compile | ||
3 | the python files at their location, not their final install location | ||
4 | which is incorrect. | ||
5 | |||
6 | To fix this, simply disable the direct_urls and pass the "root" to | ||
7 | the python compile function to strip that path out of the compiled | ||
8 | files. | ||
9 | |||
10 | A version of this patch, perhaps stripping root from the direct_urls | ||
11 | may be something that could be considered by upstream. | ||
12 | |||
13 | Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> | ||
14 | |||
15 | Upstream-Status: Pending | ||
16 | |||
17 | Index: 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 | ||
40 | Index: 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 | ||
15 | SRC_URI += "file://0001-change-shebang-to-python3.patch" | 15 | SRC_URI += "file://0001-change-shebang-to-python3.patch" |
16 | SRC_URI += "file://no_shebang_mangling.patch" | 16 | SRC_URI += "file://no_shebang_mangling.patch" |
17 | SRC_URI += "file://reproducible.patch" | ||
17 | 18 | ||
18 | SRC_URI[sha256sum] = "f29d589df8c8ab99c060e68ad294c4a9ed896624f6368c5349d70aa581b333d0" | 19 | SRC_URI[sha256sum] = "f29d589df8c8ab99c060e68ad294c4a9ed896624f6368c5349d70aa581b333d0" |
19 | 20 | ||