[yocto] [meta][PATCH] python-native: Compute prefix based on staging area

Kyle Russell bkylerussell at gmail.com
Thu Jul 28 07:31:08 PDT 2016


python-native should not assume that prefix points to the native
sysroot, and instead use STAGING_LIBDIR to determine prefix, since
python-native may be used to compile non-native python modules for the
target sysroot.

Computing an incorrect prefix causes unintended build behavior,
especially on setuptools packages.  A setuptools package may declare
setup_requires dependencies in its setup.py.  setuptools makes sure
these setup_requires dependencies are available during do_compile.
The bitbake recipes for these setuptools packages also express these
setup_requires dependencies as DEPENDS.

Since python's sysconfig computes the prefix from where python-native
was compiled, setuptools only searches the native sysroot for packages
that satisfy its setup_requires dependencies, while bitbake satisfies
its DEPENDS for the packages by populating the target sysroot.  Since
setuptools was being mislead by prefix on where to look for its
dependencies, it would try to download pypi packages into the compiling
package's workdir when it didn't find them in the native sysroot.
Instead, prefix should instruct setuptools to look in the target sysroot
to satisfy its setup_requires dependencies so setuptools can take
advantage of the DEPENDS satisfied by bitbake.

Note that a similar approach has already been patched for the
distutils.sysconfig module in python-native, but sysconfig was moved out
of distutils in Python 2.7 and >= 3.2, which appears to be why the previous
patch does not impact setuptools.

Signed-off-by: Kyle Russell <bkylerussell at gmail.com>
---
 ...g.py-prefix-should-be-inside-staging-area.patch | 32 ++++++++++++++++++++++
 .../recipes-devtools/python/python-native_2.7.9.bb |  1 +
 2 files changed, 33 insertions(+)
 create mode 100644 meta/recipes-devtools/python/python-native/0001-sysconfig.py-prefix-should-be-inside-staging-area.patch

diff --git a/meta/recipes-devtools/python/python-native/0001-sysconfig.py-prefix-should-be-inside-staging-area.patch b/meta/recipes-devtools/python/python-native/0001-sysconfig.py-prefix-should-be-inside-staging-area.patch
new file mode 100644
index 0000000..27f191f
--- /dev/null
+++ b/meta/recipes-devtools/python/python-native/0001-sysconfig.py-prefix-should-be-inside-staging-area.patch
@@ -0,0 +1,32 @@
+From 47e1df99c073ba50213f5b5f78ea36828668001f Mon Sep 17 00:00:00 2001
+From: Kyle Russell <bkylerussell at gmail.com>
+Date: Thu, 28 Jul 2016 09:15:45 -0400
+Subject: [PATCH] sysconfig.py: prefix should be inside staging area
+
+Similar to the distutils fix for correct prefix handling for the sysroot
+layout, but applies to the sysconfig API moved out of distutils in
+Python 2.7 and >=3.2.
+
+Upstream-Status: Inappropriate [embedded specific]
+---
+ Lib/sysconfig.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
+index ffc55ba..1cb4107 100644
+--- a/Lib/sysconfig.py
++++ b/Lib/sysconfig.py
+@@ -89,8 +89,8 @@ _SCHEME_KEYS = ('stdlib', 'platstdlib', 'purelib', 'platlib', 'include',
+ _PY_VERSION = sys.version.split()[0]
+ _PY_VERSION_SHORT = sys.version[:3]
+ _PY_VERSION_SHORT_NO_DOT = _PY_VERSION[0] + _PY_VERSION[2]
+-_PREFIX = os.path.normpath(sys.prefix)
+-_EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
++_PREFIX = '/'.join(os.environ['STAGING_LIBDIR'].split('/')[:-1])
++_EXEC_PREFIX = '/'.join(os.environ['STAGING_LIBDIR'].split('/')[:-1])
+ _CONFIG_VARS = None
+ _USER_BASE = None
+ _PYTHONBUILDDIR = os.environ.get("PYTHONBUILDDIR", None)
+-- 
+1.9.3
+
diff --git a/meta/recipes-devtools/python/python-native_2.7.9.bb b/meta/recipes-devtools/python/python-native_2.7.9.bb
index 34f5c29..6c668e7 100644
--- a/meta/recipes-devtools/python/python-native_2.7.9.bb
+++ b/meta/recipes-devtools/python/python-native_2.7.9.bb
@@ -18,6 +18,7 @@ SRC_URI += "\
             file://parallel-makeinst-create-bindir.patch \
             file://revert_use_of_sysconfigdata.patch \
             file://avoid_parallel_make_races_on_pgen.patch \
+            file://0001-sysconfig.py-prefix-should-be-inside-staging-area.patch \
            "
 S = "${WORKDIR}/Python-${PV}"
 
-- 
1.9.1




More information about the yocto mailing list