public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
* [PATCH 1/5] python3: split python target configuration into own class
@ 2020-11-13 19:48 Alexander Kanavin
  2020-11-13 19:48 ` [PATCH 2/5] python3-pycairo: use python3targetconfig Alexander Kanavin
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Alexander Kanavin @ 2020-11-13 19:48 UTC (permalink / raw)
  To: openembedded-core; +Cc: Alexander Kanavin

Setting _PYTHON_SYSCONFIGDATA_NAME in python3native class globally was
problematic as it was leaking into host python environment, which
was causing tracebacks depending on host distro and action
(typically anything involving importing sysconfig module).

The new class sets the variable only in specific tasks where it is needed,
and should be inherited explicitly:
- use python3native to run scripts with native python
- use python3targetconfig to run scripts with native python
if those scripts need to access target config data (such
as correct installation directories). This also adds a dependency
on target python, so should be used carefully to avoid lengthening builds.

Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
---
 meta/classes/python3native.bbclass       |  2 --
 meta/classes/python3targetconfig.bbclass | 15 +++++++++++++++
 2 files changed, 15 insertions(+), 2 deletions(-)
 create mode 100644 meta/classes/python3targetconfig.bbclass

diff --git a/meta/classes/python3native.bbclass b/meta/classes/python3native.bbclass
index d98fb4c758..2e3a88c126 100644
--- a/meta/classes/python3native.bbclass
+++ b/meta/classes/python3native.bbclass
@@ -17,8 +17,6 @@ export STAGING_LIBDIR
 export PYTHON_LIBRARY="${STAGING_LIBDIR}/lib${PYTHON_DIR}${PYTHON_ABI}.so"
 export PYTHON_INCLUDE_DIR="${STAGING_INCDIR}/${PYTHON_DIR}${PYTHON_ABI}"
 
-export _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata"
-
 # suppress host user's site-packages dirs.
 export PYTHONNOUSERSITE = "1"
 
diff --git a/meta/classes/python3targetconfig.bbclass b/meta/classes/python3targetconfig.bbclass
new file mode 100644
index 0000000000..640d0c97b6
--- /dev/null
+++ b/meta/classes/python3targetconfig.bbclass
@@ -0,0 +1,15 @@
+inherit python3native
+
+DEPENDS_append = " python3"
+
+do_configure_prepend() {
+        export _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata"
+}
+
+do_compile_prepend() {
+        export _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata"
+}
+
+do_install_prepend() {
+        export _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata"
+}
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-11-17  6:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-13 19:48 [PATCH 1/5] python3: split python target configuration into own class Alexander Kanavin
2020-11-13 19:48 ` [PATCH 2/5] python3-pycairo: use python3targetconfig Alexander Kanavin
2020-11-13 19:48 ` [PATCH 3/5] distutils3-base.bbclass: " Alexander Kanavin
2020-11-17  6:58   ` [OE-core] " Khem Raj
2020-11-13 19:48 ` [PATCH 4/5] meta: drop _PYTHON_SYSCONFIGDATA_NAME hacks Alexander Kanavin
2020-11-13 19:48 ` [PATCH 5/5] gpgme: use python3targetconfig Alexander Kanavin
2020-11-14 16:41 ` [OE-core] [PATCH 1/5] python3: split python target configuration into own class Alistair Francis
2020-11-15 19:17 ` akuster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox