Skip to contentSkip to conversation

python2/3: Remove building host path from packages

PATCH In review Li Zhou 3 participants 3 messages Jun 5, 2017 – Sep 22, 2017

lore
Share & tools
lore

Li Zhou

author
#0 lore raw

PATCH v2 1/1 python2/3: Remove building host path from packages

Remove building host related path from python2 and python3 packages.

---
 meta/recipes-devtools/python/python3_3.5.3.bb | 7 ++++++-
 meta/recipes-devtools/python/python_2.7.13.bb | 5 +++++
 2 files changed, 11 insertions(+), 1 deletion(-)
meta/recipes-devtools/python/python3_3.5.3.bb +6 -1
index d7c29f2..58313f7 100644
@@ -185,9 +185,14 @@ py_package_preprocess () {
 	install -m 0644 ${B}/Makefile.orig ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_MAJMIN}${PYTHON_ABI}/Makefile
 	# Remove references to buildmachine paths in target Makefile and _sysconfigdata
 	sed -i -e 's:--sysroot=${STAGING_DIR_TARGET}::g' -e s:'--with-libtool-sysroot=${STAGING_DIR_TARGET}'::g \
+		-e 's:${STAGING_DIR_NATIVE}::g' \
+		-e 's:${STAGING_DIR_HOST}::g' \
+		-e 's:${WORKDIR}::g' \
+		-e 's:${TMPDIR}::g' \
 		${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config/Makefile \
 		${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_MAJMIN}${PYTHON_ABI}/Makefile \
-		${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata.py
+		${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata.py \
+		${PKGD}/${bindir}/python${PYTHON_MAJMIN}${PYTHON_ABI}-config
 }
 
 require python-${PYTHON_MAJMIN}-manifest.inc
meta/recipes-devtools/python/python_2.7.13.bb +5 -0
index 4ef9952..e93a84f 100644
@@ -131,7 +131,12 @@ py_package_preprocess () {
 
 	# Remove references to buildmachine paths in target Makefile and _sysconfigdata
 	sed -i -e 's:--sysroot=${STAGING_DIR_TARGET}::g' -e s:'--with-libtool-sysroot=${STAGING_DIR_TARGET}'::g \
+		-e 's:${STAGING_DIR_NATIVE}::g' \
+		-e 's:${STAGING_DIR_HOST}::g' \
+		-e 's:${WORKDIR}::g' \
+		-e 's:${TMPDIR}::g' \
 		${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config/Makefile \
+		${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config/config.c \
 		${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata.py
     python -m py_compile ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata.py
 }
Signature · 1 line
1.9.1
#1 lore raw
Quoted 16 lines · Li Zhou
(quoted diff) +0 -0
@@ -185,9 +185,14 @@ py_package_preprocess () {
        install -m 0644 ${B}/Makefile.orig ${PKGD}/${libdir}/python${

PYTHON_MAJMIN}/config-${PYTHON_MAJMIN}${PYTHON_ABI}/Makefile
# Remove references to buildmachine paths in target Makefile and
_sysconfigdata

        sed -i -e 's:--sysroot=${STAGING_DIR_TARGET}::g' -e

s:'--with-libtool-sysroot=${STAGING_DIR_TARGET}'::g \

meta/recipes-devtools/python/python3_3.5.3.bb +4 -0
+               -e 's:${STAGING_DIR_NATIVE}::g' \
+               -e 's:${STAGING_DIR_HOST}::g' \
+               -e 's:${WORKDIR}::g' \
+               -e 's:${TMPDIR}::g' \
                ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config/Makefile \
                ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config-${

PYTHON_MAJMIN}${PYTHON_ABI}/Makefile \

(quoted diff) +1 -1
-               ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata.py
+               ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata.py
Quoted 5 lines

\
+ ${PKGD}/${bindir}/python${PYTHON_MAJMIN}${PYTHON_ABI}-
config
}

The problem with doing this is py_package_preprocess is that it doesn't touch the .pyc files, so they'll have to be recompiled:

ross@flashheart /data/poky-master/tmp/work/corei7-64-poky-linux/python3/3.5.3-r1.0/packages-split

$ grep -r /data/poky-master
Binary file
python3-core/usr/lib/python3.5/__pycache__/_sysconfigdata.cpython-35.opt-2.pyc
matches
Binary file
python3-core/usr/lib/python3.5/__pycache__/_sysconfigdata.cpython-35.opt-1.pyc
matches
Binary file
python3-core/usr/lib/python3.5/__pycache__/_sysconfigdata.cpython-35.pyc
matches

I think the seds need to be moved earlier in the build, or that py file recompiled.

Ross

#2 lore raw

The libxml2 ,python3-dbus and gpgme used host include and/or library paths, if we

remove those host paths in the end of do_install task, those host paths would not

populate in sysroot, so it's better to put the removing action in PACKAGE_PREPROCESS_FUNCS.

Quoted 2 lines · Ross

I think the seds need to be moved earlier in the build, or that py file recompiled.