Skip to contentSkip to conversation

fix .pyc/.pyo buildpaths issue

PATCH New Hongxu Jia 1 participant 4 messages Jul 19, 2018

lore
Share & tools
lore

Hongxu Jia

author
#0 lore raw

v2 cover fix .pyc/.pyo buildpaths issue

Changed in V2: Rebase to latest oe-core

The following changes since commit ff0b682b807959521c85716296de7a1d26d7d18f:

systemd-boot: upgrade to 239 (2018-07-18 10:13:30 +0100)

are available in the git repository at:

git://git.openembedded.org/openembedded-core-contrib hongxu/pyc-buildpath
http://cgit.openembedded.org/openembedded-core-contrib/log/?h=hongxu/pyc-buildpath

Hongxu Jia (3):
distutils/setuptools, distutils3/setuptools3: improve reproducibility python-setuptools.inc: clean up useless local
var-DISTUTILS_INSTALL_ARGS
python3-pip: clean up obsolete

 meta/classes/distutils.bbclass                     |  8 +++++---
 meta/classes/distutils3.bbclass                    |  8 +++++---
 meta/classes/setuptools.bbclass                    |  5 -----
 meta/classes/setuptools3.bbclass                   |  4 ----
 meta/recipes-devtools/python/python-setuptools.inc |  3 ---
 meta/recipes-devtools/python/python3-pip_10.0.1.bb | 18 ------------------
 6 files changed, 10 insertions(+), 36 deletions(-)
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v2 1/3 distutils/setuptools, distutils3/setuptools3: improve reproducibility

- Unify var-DISTUTILS_INSTALL_ARGS in distutils and setuptools

- Supply "--root" directory to the "install" command, and use it as a prefix to strip off the purported filename encoded in bytecode files. (It strips build path prefix from .pyc files)

[YOCTO #8446]
[YOCTO #12084]

---
 meta/classes/distutils.bbclass   | 8 +++++---
 meta/classes/distutils3.bbclass  | 8 +++++---
 meta/classes/setuptools.bbclass  | 5 -----
 meta/classes/setuptools3.bbclass | 4 ----
 4 files changed, 10 insertions(+), 15 deletions(-)
meta/classes/distutils.bbclass +5 -3
index 1930c35..db28767 100644
@@ -4,8 +4,10 @@ DISTUTILS_BUILD_ARGS ?= ""
 DISTUTILS_STAGE_HEADERS_ARGS ?= "--install-dir=${STAGING_INCDIR}/${PYTHON_DIR}"
 DISTUTILS_STAGE_ALL_ARGS ?= "--prefix=${STAGING_DIR_HOST}${prefix} \
     --install-data=${STAGING_DATADIR}"
-DISTUTILS_INSTALL_ARGS ?= "--prefix=${D}/${prefix} \
-    --install-data=${D}/${datadir}"
+DISTUTILS_INSTALL_ARGS ?= "--root=${D} \
+    --prefix=${prefix} \
+    --install-lib=${PYTHON_SITEPACKAGES_DIR} \
+    --install-data=${datadir}"
 
 distutils_do_compile() {
          STAGING_INCDIR=${STAGING_INCDIR} \
@@ -34,7 +36,7 @@ distutils_do_install() {
         STAGING_INCDIR=${STAGING_INCDIR} \
         STAGING_LIBDIR=${STAGING_LIBDIR} \
         PYTHONPATH=${D}${PYTHON_SITEPACKAGES_DIR} \
-        ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install --install-lib=${D}/${PYTHON_SITEPACKAGES_DIR} ${DISTUTILS_INSTALL_ARGS} || \
+        ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install ${DISTUTILS_INSTALL_ARGS} || \
         bbfatal_log "${PYTHON_PN} setup.py install execution failed."
 
         # support filenames with *spaces*
meta/classes/distutils3.bbclass +5 -3
index d4b92a3..9637486 100644
@@ -5,8 +5,10 @@ DISTUTILS_BUILD_EXT_ARGS ?= ""
 DISTUTILS_STAGE_HEADERS_ARGS ?= "--install-dir=${STAGING_INCDIR}/${PYTHON_DIR}"
 DISTUTILS_STAGE_ALL_ARGS ?= "--prefix=${STAGING_DIR_HOST}${prefix} \
     --install-data=${STAGING_DATADIR}"
-DISTUTILS_INSTALL_ARGS ?= "--prefix=${D}/${prefix} \
-    --install-data=${D}/${datadir}"
+DISTUTILS_INSTALL_ARGS ?= "--root=${D} \
+    --prefix=${prefix} \
+    --install-lib=${PYTHON_SITEPACKAGES_DIR} \
+    --install-data=${datadir}"
 
 distutils3_do_configure() {
 	if [ "${CLEANBROKEN}" != "1" ] ; then
@@ -45,7 +47,7 @@ distutils3_do_install() {
         STAGING_INCDIR=${STAGING_INCDIR} \
         STAGING_LIBDIR=${STAGING_LIBDIR} \
         PYTHONPATH=${D}${PYTHON_SITEPACKAGES_DIR} \
-        ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install --install-lib=${D}/${PYTHON_SITEPACKAGES_DIR} ${DISTUTILS_INSTALL_ARGS} || \
+        ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install ${DISTUTILS_INSTALL_ARGS} || \
         bbfatal_log "${PYTHON_PN} setup.py install execution failed."
 
         # support filenames with *spaces*
meta/classes/setuptools.bbclass +0 -5
index 157ef63..a923ea3 100644
@@ -1,8 +1,3 @@
 inherit distutils
 
 DEPENDS += "python-setuptools-native"
-
-DISTUTILS_INSTALL_ARGS = "--root=${D} \
-    --prefix=${prefix} \
-    --install-lib=${PYTHON_SITEPACKAGES_DIR} \
-    --install-data=${datadir}"
meta/classes/setuptools3.bbclass +0 -4
index de6dd94..8ca66ee 100644
@@ -2,7 +2,3 @@ inherit distutils3
 
 DEPENDS += "python3-setuptools-native"
 
-DISTUTILS_INSTALL_ARGS = "--root=${D} \
-    --prefix=${prefix} \
-    --install-lib=${PYTHON_SITEPACKAGES_DIR} \
-    --install-data=${datadir}"
Signature · 1 line
2.7.4
author
#2 lore raw

PATCH v2 2/3 python-setuptools.inc: clean up useless local var-DISTUTILS_INSTALL_ARGS

In reply to Hongxu Jia

Since unify var-DISTUTILS_INSTALL_ARGS in distutils and setuptools, The local var-DISTUTILS_INSTALL_ARGS broke do_install
...
error: option --script-dir not recognized
ERROR: python3 setup.py install execution failed.
...

[YOCTO #8446]

---
 meta/recipes-devtools/python/python-setuptools.inc | 3 ---
 1 file changed, 3 deletions(-)
meta/recipes-devtools/python/python-setuptools.inc +0 -3
index ab1c013..6dd772d 100644
@@ -13,9 +13,6 @@ SRC_URI[sha256sum] = "012adb8e25fbfd64c652e99e7bab58799a3aaf05d39ab38561f69190a9
 
 DEPENDS += "${PYTHON_PN}"
 
-DISTUTILS_INSTALL_ARGS += "--install-lib=${D}${PYTHON_SITEPACKAGES_DIR} \
-                           --script-dir=${bindir}"
-
 RDEPENDS_${PN} = "\
   ${PYTHON_PN}-compile \
   ${PYTHON_PN}-compression \
Signature · 1 line
2.7.4
author
#3 lore raw

PATCH v2 3/3 python3-pip: clean up obsolete

In reply to Hongxu Jia

Since unify var-DISTUTILS_INSTALL_ARGS in distutils and setuptools,
- The local DISTUTILS_INSTALL_ARGS assignment is obsolete;
- The site.py is not be generated any more;
- The layout is in a standard pip dir (such as /usr/lib/python3.5/site- packages/pip rather than /lib/python3.5/site-packages/pip-10.0.1- py3.5.egg/pip), the pth file is not required;

`#!/usr/bin/env python3' is already used, do not manually sed.

[YOCTO #8446]

---
 meta/recipes-devtools/python/python3-pip_10.0.1.bb | 18 ------------------
 1 file changed, 18 deletions(-)
meta/recipes-devtools/python/python3-pip_10.0.1.bb +0 -18
index 100d4d0..8deec2b 100644
@@ -11,27 +11,9 @@ SRC_URI[sha256sum] = "f2bd08e0cd1b06e10218feaf6fef299f473ba706582eb3bd9d52203fdb
 
 inherit pypi distutils3
 
-DISTUTILS_INSTALL_ARGS += "--install-lib=${D}${PYTHON_SITEPACKAGES_DIR}"
-
-do_install_prepend() {
-    install -d ${D}${PYTHON_SITEPACKAGES_DIR}
-}
-
-# Use setuptools site.py instead, avoid shared state issue
 do_install_append() {
-    rm ${D}${PYTHON_SITEPACKAGES_DIR}/site.py
-    rm ${D}${PYTHON_SITEPACKAGES_DIR}/__pycache__/site.cpython-*.pyc
-
     # Install as pip3 and leave pip2 as default
     rm ${D}/${bindir}/pip
-
-    # Installed eggs need to be passed directly to the interpreter via a pth file
-    echo "./${PYPI_PACKAGE}-${PV}-py${PYTHON_BASEVERSION}.egg" > ${D}${PYTHON_SITEPACKAGES_DIR}/${PYPI_PACKAGE}-${PV}.pth
-
-    # Make sure we use /usr/bin/env python3
-    for PYTHSCRIPT in `grep -rIl ${bindir} ${D}${bindir}/pip3*`; do
-        sed -i -e '1s|^#!.*|#!/usr/bin/env python3|' $PYTHSCRIPT
-    done
 }
 
 RDEPENDS_${PN} = "\
Signature · 1 line
2.7.4