summaryrefslogtreecommitdiffstats
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:06:46 +0000
commit2c74d5346e7581949fbdebc4744c8317236221c3 (patch)
tree7743f61b011a2b2fdb88f51a2f3526abc42c6f5d
parent5b58328b610273fea42c144cd590e638c0dc1e4e (diff)
downloadopenembedded-core-contrib-2c74d5346e7581949fbdebc4744c8317236221c3.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. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-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 @@
+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
+
+Index: pip-22.0.3/src/pip/_internal/req/req_install.py
+===================================================================
+--- pip-22.0.3.orig/src/pip/_internal/req/req_install.py
++++ pip-22.0.3/src/pip/_internal/req/req_install.py
+@@ -758,7 +758,9 @@ class InstallRequirement:
+ if self.is_wheel:
+ assert self.local_file_path
+ direct_url = None
+- 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(
+@@ -775,6 +777,7 @@ class InstallRequirement:
+ warn_script_location=warn_script_location,
+ direct_url=direct_url,
+ requested=self.user_supplied,
++ root=root,
+ )
+ self.install_succeeded = True
+ return
+Index: pip-22.0.3/src/pip/_internal/operations/install/wheel.py
+===================================================================
+--- pip-22.0.3.orig/src/pip/_internal/operations/install/wheel.py
++++ pip-22.0.3/src/pip/_internal/operations/install/wheel.py
+@@ -436,6 +436,7 @@ def _install_wheel(
+ warn_script_location: bool = True,
+ direct_url: Optional[DirectUrl] = None,
+ requested: bool = False,
++ root: str = None,
+ ) -> None:
+ """Install a wheel.
+
+@@ -612,7 +613,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)
+@@ -723,6 +724,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):
+@@ -735,4 +737,5 @@ def install_wheel(
+ warn_script_location=warn_script_location,
+ direct_url=direct_url,
+ requested=requested,
++ root=root,
+ )
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"
SRC_URI += "file://0001-change-shebang-to-python3.patch"
SRC_URI += "file://no_shebang_mangling.patch"
+SRC_URI += "file://reproducible.patch"
SRC_URI[sha256sum] = "f29d589df8c8ab99c060e68ad294c4a9ed896624f6368c5349d70aa581b333d0"