Patchwork [04/24] classes/distutils: Introduce PYTHON_PN

login
register
mail settings
Submitter Khem Raj
Date June 28, 2013, 10:03 p.m.
Message ID <984ceb9c26e5fc05dcad1046f8ebf396a9034e10.1372456294.git.raj.khem@gmail.com>
Download mbox | patch
Permalink /patch/52645/
State New
Headers show

Comments

Khem Raj - June 28, 2013, 10:03 p.m.
This is needed to accomodate python3 alongside
python2

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 meta/classes/distutils-base.bbclass        |    5 ++---
 meta/classes/distutils-native-base.bbclass |    4 ++--
 meta/classes/distutils.bbclass             |   24 +++++++++++++-----------
 meta/classes/python-dir.bbclass            |    1 +
 meta/classes/pythonnative.bbclass          |    9 ++++++---
 5 files changed, 24 insertions(+), 19 deletions(-)
Martin Jansa - June 29, 2013, 5:29 a.m.
On Fri, Jun 28, 2013 at 03:03:49PM -0700, Khem Raj wrote:
> This is needed to accomodate python3 alongside
> python2
> 
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> ---
>  meta/classes/distutils-base.bbclass        |    5 ++---
>  meta/classes/distutils-native-base.bbclass |    4 ++--
>  meta/classes/distutils.bbclass             |   24 +++++++++++++-----------
>  meta/classes/python-dir.bbclass            |    1 +
>  meta/classes/pythonnative.bbclass          |    9 ++++++---
>  5 files changed, 24 insertions(+), 19 deletions(-)
> 
> diff --git a/meta/classes/distutils-base.bbclass b/meta/classes/distutils-base.bbclass
> index 3b43e76..aa18e8b 100644
> --- a/meta/classes/distutils-base.bbclass
> +++ b/meta/classes/distutils-base.bbclass
> @@ -1,5 +1,4 @@
> -DEPENDS  += "${@["python-native python", ""][(d.getVar('PACKAGES', True) == '')]}"
> -RDEPENDS_${PN} += "${@['', 'python-core']['${CLASSOVERRIDE}' == 'class-target']}"
> +DEPENDS  += "${@["${PYTHON_PN}-native ${PYTHON_PN}", ""][(d.getVar('PACKAGES', True) == '')]}"
> +RDEPENDS_${PN} += "${@['', '${PYTHON_PN}-core']['${CLASSOVERRIDE}' == 'class-target']}"
>  
>  inherit distutils-common-base pythonnative
> -
> diff --git a/meta/classes/distutils-native-base.bbclass b/meta/classes/distutils-native-base.bbclass
> index ceda512..509cb95 100644
> --- a/meta/classes/distutils-native-base.bbclass
> +++ b/meta/classes/distutils-native-base.bbclass
> @@ -1,3 +1,3 @@
> -DEPENDS  += "${@["python-native", ""][(d.getVar('PACKAGES', True) == '')]}"
> -
>  inherit distutils-common-base
> +
> +DEPENDS  += "${@["${PYTHON_PN}-native", ""][(d.getVar('PACKAGES', True) == '')]}"
> diff --git a/meta/classes/distutils.bbclass b/meta/classes/distutils.bbclass
> index a0e1f50..f99959d 100644
> --- a/meta/classes/distutils.bbclass
> +++ b/meta/classes/distutils.bbclass
> @@ -1,4 +1,5 @@
>  inherit distutils-base
> +#distutils-tools

^^ do we need this?

>  
>  DISTUTILS_BUILD_ARGS ?= ""
>  DISTUTILS_STAGE_HEADERS_ARGS ?= "--install-dir=${STAGING_INCDIR}/${PYTHON_DIR}"
> @@ -11,15 +12,15 @@ distutils_do_compile() {
>           STAGING_INCDIR=${STAGING_INCDIR} \
>           STAGING_LIBDIR=${STAGING_LIBDIR} \
>           BUILD_SYS=${BUILD_SYS} HOST_SYS=${HOST_SYS} \
> -         ${STAGING_BINDIR_NATIVE}/python-native/python setup.py build ${DISTUTILS_BUILD_ARGS} || \
> -         bbfatal "python setup.py build_ext execution failed."
> +         ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py build ${DISTUTILS_BUILD_ARGS} || \
> +         bbfatal "${PYTHON_PN} setup.py build_ext execution failed."
>  }
>  
>  distutils_stage_headers() {
>          install -d ${STAGING_DIR_HOST}${PYTHON_SITEPACKAGES_DIR}
>          BUILD_SYS=${BUILD_SYS} HOST_SYS=${HOST_SYS} \
> -        ${STAGING_BINDIR_NATIVE}/python-native/python setup.py install_headers ${DISTUTILS_STAGE_HEADERS_ARGS} || \
> -        bbfatal "python setup.py install_headers execution failed."
> +        ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install_headers ${DISTUTILS_STAGE_HEADERS_ARGS} || \
> +        bbfatal "${PYTHON_PN} setup.py install_headers execution failed."
>  }
>  
>  distutils_stage_all() {
> @@ -28,21 +29,22 @@ distutils_stage_all() {
>          install -d ${STAGING_DIR_HOST}${PYTHON_SITEPACKAGES_DIR}
>          PYTHONPATH=${STAGING_DIR_HOST}${PYTHON_SITEPACKAGES_DIR} \
>          BUILD_SYS=${BUILD_SYS} HOST_SYS=${HOST_SYS} \
> -        ${STAGING_BINDIR_NATIVE}/python-native/python setup.py install ${DISTUTILS_STAGE_ALL_ARGS} || \
> -        bbfatal "python setup.py install (stage) execution failed."
> +        ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install ${DISTUTILS_STAGE_ALL_ARGS} || \
> +        bbfatal "${PYTHON_PN} setup.py install (stage) execution failed."
>  }
>  
>  distutils_do_install() {
>          install -d ${D}${PYTHON_SITEPACKAGES_DIR}
>          STAGING_INCDIR=${STAGING_INCDIR} \
>          STAGING_LIBDIR=${STAGING_LIBDIR} \
> -        PYTHONPATH=${D}/${PYTHON_SITEPACKAGES_DIR} \
> +        PYTHONPATH=${D}${PYTHON_SITEPACKAGES_DIR} \
>          BUILD_SYS=${BUILD_SYS} HOST_SYS=${HOST_SYS} \
> -        ${STAGING_BINDIR_NATIVE}/python-native/python setup.py install --install-lib=${D}/${PYTHON_SITEPACKAGES_DIR} ${DISTUTILS_INSTALL_ARGS} || \
> -        bbfatal "python setup.py install execution failed."
> +        ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install --install-lib=${D}/${PYTHON_SITEPACKAGES_DIR} ${DISTUTILS_INSTALL_ARGS} || \
> +        bbfatal "${PYTHON_PN} setup.py install execution failed."
>  
> -        for i in `find ${D} -name "*.py"` ; do \
> -            sed -i -e s:${D}::g $i
> +        # support filenames with *spaces*
> +        find ${D} -name "*.py" -print0 | while read -d $'\0' i ; do \
> +            sed -i -e s:${D}::g "$i"
>          done
>  
>          if test -e ${D}${bindir} ; then	
> diff --git a/meta/classes/python-dir.bbclass b/meta/classes/python-dir.bbclass
> index 0b6a33c..b4b5ab0 100644
> --- a/meta/classes/python-dir.bbclass
> +++ b/meta/classes/python-dir.bbclass
> @@ -1,3 +1,4 @@
>  PYTHON_BASEVERSION ?= "2.7"
>  PYTHON_DIR = "python${PYTHON_BASEVERSION}"
> +PYTHON_PN = "python${@'' if '${PYTHON_BASEVERSION}'.startswith('2') else '3'}"
>  PYTHON_SITEPACKAGES_DIR = "${libdir}/${PYTHON_DIR}/site-packages"
> diff --git a/meta/classes/pythonnative.bbclass b/meta/classes/pythonnative.bbclass
> index 7886207..fdd22bb 100644
> --- a/meta/classes/pythonnative.bbclass
> +++ b/meta/classes/pythonnative.bbclass
> @@ -1,3 +1,6 @@
> -PYTHON="${STAGING_BINDIR_NATIVE}/python-native/python"
> -EXTRANATIVEPATH += "python-native"
> -DEPENDS += " python-native "
> +
> +inherit python-dir
> +
> +PYTHON="${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN}"
> +EXTRANATIVEPATH += "${PYTHON_PN}-native"
> +DEPENDS += " ${PYTHON_PN}-native "
> -- 
> 1.7.9.5
> 
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
Khem Raj - June 29, 2013, 2:07 p.m.
On Jun 28, 2013, at 10:29 PM, Martin Jansa <martin.jansa@gmail.com> wrote:

>> inherit distutils-base
>> +#distutils-tools
> 
> ^^ do we need this?

No, update the pull branch with fix

Patch

diff --git a/meta/classes/distutils-base.bbclass b/meta/classes/distutils-base.bbclass
index 3b43e76..aa18e8b 100644
--- a/meta/classes/distutils-base.bbclass
+++ b/meta/classes/distutils-base.bbclass
@@ -1,5 +1,4 @@ 
-DEPENDS  += "${@["python-native python", ""][(d.getVar('PACKAGES', True) == '')]}"
-RDEPENDS_${PN} += "${@['', 'python-core']['${CLASSOVERRIDE}' == 'class-target']}"
+DEPENDS  += "${@["${PYTHON_PN}-native ${PYTHON_PN}", ""][(d.getVar('PACKAGES', True) == '')]}"
+RDEPENDS_${PN} += "${@['', '${PYTHON_PN}-core']['${CLASSOVERRIDE}' == 'class-target']}"
 
 inherit distutils-common-base pythonnative
-
diff --git a/meta/classes/distutils-native-base.bbclass b/meta/classes/distutils-native-base.bbclass
index ceda512..509cb95 100644
--- a/meta/classes/distutils-native-base.bbclass
+++ b/meta/classes/distutils-native-base.bbclass
@@ -1,3 +1,3 @@ 
-DEPENDS  += "${@["python-native", ""][(d.getVar('PACKAGES', True) == '')]}"
-
 inherit distutils-common-base
+
+DEPENDS  += "${@["${PYTHON_PN}-native", ""][(d.getVar('PACKAGES', True) == '')]}"
diff --git a/meta/classes/distutils.bbclass b/meta/classes/distutils.bbclass
index a0e1f50..f99959d 100644
--- a/meta/classes/distutils.bbclass
+++ b/meta/classes/distutils.bbclass
@@ -1,4 +1,5 @@ 
 inherit distutils-base
+#distutils-tools
 
 DISTUTILS_BUILD_ARGS ?= ""
 DISTUTILS_STAGE_HEADERS_ARGS ?= "--install-dir=${STAGING_INCDIR}/${PYTHON_DIR}"
@@ -11,15 +12,15 @@  distutils_do_compile() {
          STAGING_INCDIR=${STAGING_INCDIR} \
          STAGING_LIBDIR=${STAGING_LIBDIR} \
          BUILD_SYS=${BUILD_SYS} HOST_SYS=${HOST_SYS} \
-         ${STAGING_BINDIR_NATIVE}/python-native/python setup.py build ${DISTUTILS_BUILD_ARGS} || \
-         bbfatal "python setup.py build_ext execution failed."
+         ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py build ${DISTUTILS_BUILD_ARGS} || \
+         bbfatal "${PYTHON_PN} setup.py build_ext execution failed."
 }
 
 distutils_stage_headers() {
         install -d ${STAGING_DIR_HOST}${PYTHON_SITEPACKAGES_DIR}
         BUILD_SYS=${BUILD_SYS} HOST_SYS=${HOST_SYS} \
-        ${STAGING_BINDIR_NATIVE}/python-native/python setup.py install_headers ${DISTUTILS_STAGE_HEADERS_ARGS} || \
-        bbfatal "python setup.py install_headers execution failed."
+        ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install_headers ${DISTUTILS_STAGE_HEADERS_ARGS} || \
+        bbfatal "${PYTHON_PN} setup.py install_headers execution failed."
 }
 
 distutils_stage_all() {
@@ -28,21 +29,22 @@  distutils_stage_all() {
         install -d ${STAGING_DIR_HOST}${PYTHON_SITEPACKAGES_DIR}
         PYTHONPATH=${STAGING_DIR_HOST}${PYTHON_SITEPACKAGES_DIR} \
         BUILD_SYS=${BUILD_SYS} HOST_SYS=${HOST_SYS} \
-        ${STAGING_BINDIR_NATIVE}/python-native/python setup.py install ${DISTUTILS_STAGE_ALL_ARGS} || \
-        bbfatal "python setup.py install (stage) execution failed."
+        ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install ${DISTUTILS_STAGE_ALL_ARGS} || \
+        bbfatal "${PYTHON_PN} setup.py install (stage) execution failed."
 }
 
 distutils_do_install() {
         install -d ${D}${PYTHON_SITEPACKAGES_DIR}
         STAGING_INCDIR=${STAGING_INCDIR} \
         STAGING_LIBDIR=${STAGING_LIBDIR} \
-        PYTHONPATH=${D}/${PYTHON_SITEPACKAGES_DIR} \
+        PYTHONPATH=${D}${PYTHON_SITEPACKAGES_DIR} \
         BUILD_SYS=${BUILD_SYS} HOST_SYS=${HOST_SYS} \
-        ${STAGING_BINDIR_NATIVE}/python-native/python setup.py install --install-lib=${D}/${PYTHON_SITEPACKAGES_DIR} ${DISTUTILS_INSTALL_ARGS} || \
-        bbfatal "python setup.py install execution failed."
+        ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install --install-lib=${D}/${PYTHON_SITEPACKAGES_DIR} ${DISTUTILS_INSTALL_ARGS} || \
+        bbfatal "${PYTHON_PN} setup.py install execution failed."
 
-        for i in `find ${D} -name "*.py"` ; do \
-            sed -i -e s:${D}::g $i
+        # support filenames with *spaces*
+        find ${D} -name "*.py" -print0 | while read -d $'\0' i ; do \
+            sed -i -e s:${D}::g "$i"
         done
 
         if test -e ${D}${bindir} ; then	
diff --git a/meta/classes/python-dir.bbclass b/meta/classes/python-dir.bbclass
index 0b6a33c..b4b5ab0 100644
--- a/meta/classes/python-dir.bbclass
+++ b/meta/classes/python-dir.bbclass
@@ -1,3 +1,4 @@ 
 PYTHON_BASEVERSION ?= "2.7"
 PYTHON_DIR = "python${PYTHON_BASEVERSION}"
+PYTHON_PN = "python${@'' if '${PYTHON_BASEVERSION}'.startswith('2') else '3'}"
 PYTHON_SITEPACKAGES_DIR = "${libdir}/${PYTHON_DIR}/site-packages"
diff --git a/meta/classes/pythonnative.bbclass b/meta/classes/pythonnative.bbclass
index 7886207..fdd22bb 100644
--- a/meta/classes/pythonnative.bbclass
+++ b/meta/classes/pythonnative.bbclass
@@ -1,3 +1,6 @@ 
-PYTHON="${STAGING_BINDIR_NATIVE}/python-native/python"
-EXTRANATIVEPATH += "python-native"
-DEPENDS += " python-native "
+
+inherit python-dir
+
+PYTHON="${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN}"
+EXTRANATIVEPATH += "${PYTHON_PN}-native"
+DEPENDS += " ${PYTHON_PN}-native "