python: prevent build failure when pycache files missing

Message ID 20220122171546.30099-1-athoik@gmail.com
State New
Headers show
Series python: prevent build failure when pycache files missing | expand

Commit Message

Athanasios Oikonomou Jan. 22, 2022, 5:15 p.m. UTC
Building a patched version of python3 with byte-code files saved to their legacy locations and names causes the following errors:

| rm: cannot remove '/.../build/tmp/work/x86_64-linux/python3-native/3.9.9-r0/recipe-sysroot-native/usr/lib/python3.9/test/__pycache__/test_range.cpython*': No such file or directory
| rm: cannot remove '/.../build/tmp/work/x86_64-linux/meson-native/0.57.1-r1/recipe-sysroot-native/usr/lib/python*/site-packages/mesonbuild/dependencies/__pycache__/mpi.cpython*': No such file or directory

Force remove pycache files, preventing build failure in case they are absent.

Python3 patched with legacy byte-code locations in order to create a sourceless .pyc deployment for small flash boxes. Unappropriate for upstream.

Signed-off-by: Athanasios Oikonomou <athoik@gmail.com>
---
 meta/recipes-devtools/meson/meson.inc         | 2 +-
 meta/recipes-devtools/python/python3_3.9.9.bb | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

Comments

Richard Purdie Jan. 25, 2022, 12:15 p.m. UTC | #1
On Sat, 2022-01-22 at 19:15 +0200, Athanasios Oikonomou wrote:
> Building a patched version of python3 with byte-code files saved to their
> legacy locations and names causes the following errors:
> 
> > rm: cannot remove '/.../build/tmp/work/x86_64-linux/python3-native/3.9.9-
> > r0/recipe-sysroot-
> > native/usr/lib/python3.9/test/__pycache__/test_range.cpython*': No such file
> > or directory
> > rm: cannot remove '/.../build/tmp/work/x86_64-linux/meson-native/0.57.1-
> > r1/recipe-sysroot-native/usr/lib/python*/site-
> > packages/mesonbuild/dependencies/__pycache__/mpi.cpython*': No such file or
> > directory
> 
> Force remove pycache files, preventing build failure in case they are absent.
> 
> Python3 patched with legacy byte-code locations in order to create a
> sourceless .pyc deployment for small flash boxes. Unappropriate for upstream.

Do people commonly patch python to build with legacy byte-code locations? If you
do that aren't files generated at a different location and hence break
reproduciblity? This seems to be a rather niche requirement?

I'm a little worried we add the -f and then if files change location, we don't
realise...

Cheers,

Richard

Patch

diff --git a/meta/recipes-devtools/meson/meson.inc b/meta/recipes-devtools/meson/meson.inc
index e186dede92..bc8ff2bcdc 100644
--- a/meta/recipes-devtools/meson/meson.inc
+++ b/meta/recipes-devtools/meson/meson.inc
@@ -44,5 +44,5 @@  do_install_append () {
 	# Upstream is discussing ways to solve the issue properly, until then let's
 	# just not install the problematic files.
 	# More info: http://benno.id.au/blog/2013/01/15/python-determinism
-	rm ${D}${libdir}/python*/site-packages/mesonbuild/dependencies/__pycache__/mpi.cpython*
+	rm -f ${D}${libdir}/python*/site-packages/mesonbuild/dependencies/__pycache__/mpi.cpython*
 }
diff --git a/meta/recipes-devtools/python/python3_3.9.9.bb b/meta/recipes-devtools/python/python3_3.9.9.bb
index f41529833c..7d0bef06d5 100644
--- a/meta/recipes-devtools/python/python3_3.9.9.bb
+++ b/meta/recipes-devtools/python/python3_3.9.9.bb
@@ -174,8 +174,8 @@  do_install_append() {
         # Upstream is discussing ways to solve the issue properly, until then let's
         # just not install the problematic files.
         # More info: http://benno.id.au/blog/2013/01/15/python-determinism
-        rm ${D}${libdir}/python${PYTHON_MAJMIN}/test/__pycache__/test_range.cpython*
-        rm ${D}${libdir}/python${PYTHON_MAJMIN}/test/__pycache__/test_xml_etree.cpython*
+        rm -f ${D}${libdir}/python${PYTHON_MAJMIN}/test/__pycache__/test_range.cpython*
+        rm -f ${D}${libdir}/python${PYTHON_MAJMIN}/test/__pycache__/test_xml_etree.cpython*
 }
 
 do_install_append_class-nativesdk () {