[meta-python] python3-crc32c: Do not poke at build system for finding platform

Message ID 20220304080216.754292-1-raj.khem@gmail.com
State New
Headers show
Series [meta-python] python3-crc32c: Do not poke at build system for finding platform | expand

Commit Message

Khem Raj March 4, 2022, 8:02 a.m. UTC
platform is target specific and when cross compiling it should be
detected differently, in this case lets pass it via environment so that
it can be set in recipe

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Cc: Justin Bronder <jsbronder@cold-front.org>
---
 ...p.py-Fix-determining-target-platform.patch | 34 +++++++++++++++++++
 .../python/python3-crc32c_2.2.post0.bb        |  3 ++
 2 files changed, 37 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-crc32c/0001-setup.py-Fix-determining-target-platform.patch

Patch

diff --git a/meta-python/recipes-devtools/python/python3-crc32c/0001-setup.py-Fix-determining-target-platform.patch b/meta-python/recipes-devtools/python/python3-crc32c/0001-setup.py-Fix-determining-target-platform.patch
new file mode 100644
index 0000000000..b534c05e9a
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-crc32c/0001-setup.py-Fix-determining-target-platform.patch
@@ -0,0 +1,34 @@ 
+From 855428feb14c44762ea21a18b05638e3e6266ab5 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Thu, 3 Mar 2022 23:50:30 -0800
+Subject: [PATCH] setup.py: Fix determining target platform
+
+Do not poke at the build machine to determine target platform or architecture
+pass it from environment instead for cross compiling to work
+
+Upstream-Status: Inappropriate [OE-Specific]
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ setup.py | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/setup.py
++++ b/setup.py
+@@ -20,6 +20,7 @@
+ #    MA 02111-1307  USA
+ #
+ import glob
++import os
+ import platform
+ 
+ import distutils.ccompiler
+@@ -58,7 +59,8 @@ class _build_ext(build_ext):
+ 
+     def run(self):
+         assert(len(self.distribution.ext_modules) == 1)
+-        platform = self.platform.lower()
++        platform = os.environ.get('PLATFORM', 'True')
++
+         is_intel = platform in ['x86_64', 'amd64', 'i386', 'i686']
+         is_arm = platform in ['aarch64_be', 'aarch64', 'armv8b', 'armv8l']
+         distutils.log.info("platform: %s, is_intel: %d, is_arm: %d", platform, is_intel, is_arm)
diff --git a/meta-python/recipes-devtools/python/python3-crc32c_2.2.post0.bb b/meta-python/recipes-devtools/python/python3-crc32c_2.2.post0.bb
index 0d51420939..040bbd320d 100644
--- a/meta-python/recipes-devtools/python/python3-crc32c_2.2.post0.bb
+++ b/meta-python/recipes-devtools/python/python3-crc32c_2.2.post0.bb
@@ -9,8 +9,11 @@  LIC_FILES_CHKSUM = " \
     file://crc32c_adler.c;startline=9;endline=24;md5=c60e6e55d0e5d95effa6fad27db0711a \
 "
 
+SRC_URI += "file://0001-setup.py-Fix-determining-target-platform.patch"
 SRC_URI[sha256sum] = "3d058e7a5e37e4985d1a7ad4cb702bca56b490daa658d4851377d13ead8b435e"
 
 inherit pypi setuptools3
 
+export PLATFORM = "${TARGET_ARCH}"
+
 RDEPENDS:${PN} += "python3-core"