aboutsummaryrefslogtreecommitdiffstats
path: root/classes
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2020-01-20 17:14:33 +0000
committerTim Orling <ticotimo@gmail.com>2020-01-20 09:33:23 -0800
commit39ddef6a83eb43857f3d46296a30f68ac27e89d5 (patch)
tree5fc63f954a35455338705b061d74c834c21dc200 /classes
parent909fd91182e55a6e5147ab8bf3e6d56e77b9fef0 (diff)
downloadmeta-python2-39ddef6a83eb43857f3d46296a30f68ac27e89d5.tar.gz
meta-python2-39ddef6a83eb43857f3d46296a30f68ac27e89d5.tar.bz2
meta-python2-39ddef6a83eb43857f3d46296a30f68ac27e89d5.zip
python: add 2.7.17 from oe-core
Python 2 ceased being maintained on the 1st January 2020. All users of Python 2 in oe-core have already been ported to Python 3, so in oe-core 390f3eda Python 2 was finally removed from oe-core itself. The following are added to meta-python2 in this commit: - python and python-native 2.7.17 - python-setuptools - The classes pythonnative, pythondir, distutils, setuptools Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Tim Orling <ticotimo@gmail.com>
Diffstat (limited to 'classes')
-rw-r--r--classes/distutils-base.bbclass4
-rw-r--r--classes/distutils.bbclass87
-rw-r--r--classes/python-dir.bbclass5
-rw-r--r--classes/pythonnative.bbclass27
-rw-r--r--classes/setuptools.bbclass3
5 files changed, 126 insertions, 0 deletions
diff --git a/classes/distutils-base.bbclass b/classes/distutils-base.bbclass
new file mode 100644
index 00000000..9f398d70
--- /dev/null
+++ b/classes/distutils-base.bbclass
@@ -0,0 +1,4 @@
+DEPENDS += "${@["${PYTHON_PN}-native ${PYTHON_PN}", ""][(d.getVar('PACKAGES') == '')]}"
+RDEPENDS_${PN} += "${@['', '${PYTHON_PN}-core']['${CLASSOVERRIDE}' == 'class-target']}"
+
+inherit distutils-common-base pythonnative
diff --git a/classes/distutils.bbclass b/classes/distutils.bbclass
new file mode 100644
index 00000000..3759b582
--- /dev/null
+++ b/classes/distutils.bbclass
@@ -0,0 +1,87 @@
+inherit distutils-base
+
+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 ?= "--root=${D} \
+ --prefix=${prefix} \
+ --install-lib=${PYTHON_SITEPACKAGES_DIR} \
+ --install-data=${datadir}"
+
+DISTUTILS_PYTHON = "python"
+DISTUTILS_PYTHON_class-native = "nativepython"
+
+distutils_do_configure() {
+ if [ "${CLEANBROKEN}" != "1" ] ; then
+ NO_FETCH_BUILD=1 \
+ ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py clean ${DISTUTILS_BUILD_ARGS}
+ fi
+}
+
+distutils_do_compile() {
+ NO_FETCH_BUILD=1 \
+ STAGING_INCDIR=${STAGING_INCDIR} \
+ STAGING_LIBDIR=${STAGING_LIBDIR} \
+ ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py build ${DISTUTILS_BUILD_ARGS} || \
+ bbfatal_log "'${PYTHON_PN} setup.py build ${DISTUTILS_BUILD_ARGS}' execution failed."
+}
+
+distutils_stage_headers() {
+ install -d ${STAGING_DIR_HOST}${PYTHON_SITEPACKAGES_DIR}
+ ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install_headers ${DISTUTILS_STAGE_HEADERS_ARGS} || \
+ bbfatal_log "'${PYTHON_PN} setup.py install_headers ${DISTUTILS_STAGE_HEADERS_ARGS}' execution for stage_headers failed."
+}
+
+distutils_stage_all() {
+ STAGING_INCDIR=${STAGING_INCDIR} \
+ STAGING_LIBDIR=${STAGING_LIBDIR} \
+ install -d ${STAGING_DIR_HOST}${PYTHON_SITEPACKAGES_DIR}
+ PYTHONPATH=${STAGING_DIR_HOST}${PYTHON_SITEPACKAGES_DIR} \
+ ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install ${DISTUTILS_STAGE_ALL_ARGS} || \
+ bbfatal_log "'${PYTHON_PN} setup.py install ${DISTUTILS_STAGE_ALL_ARGS}' execution for stage_all failed."
+}
+
+distutils_do_install() {
+ install -d ${D}${PYTHON_SITEPACKAGES_DIR}
+ STAGING_INCDIR=${STAGING_INCDIR} \
+ STAGING_LIBDIR=${STAGING_LIBDIR} \
+ PYTHONPATH=${D}${PYTHON_SITEPACKAGES_DIR} \
+ ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install ${DISTUTILS_INSTALL_ARGS} || \
+ bbfatal_log "'${PYTHON_PN} setup.py install ${DISTUTILS_INSTALL_ARGS}' execution failed."
+
+ # support filenames with *spaces*
+ # only modify file if it contains path and recompile it
+ find ${D} -name "*.py" -exec grep -q ${D} {} \; \
+ -exec sed -i -e s:${D}::g {} \; \
+ -exec ${STAGING_BINDIR_NATIVE}/python-native/python -mcompileall {} \;
+
+ for i in ${D}${bindir}/* ${D}${sbindir}/*; do
+ if [ -f "$i" ]; then
+ sed -i -e s:${PYTHON}:${USRBINPATH}/env\ ${DISTUTILS_PYTHON}:g $i
+ sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
+ fi
+ done
+
+ rm -f ${D}${PYTHON_SITEPACKAGES_DIR}/easy-install.pth
+ rm -f ${D}${PYTHON_SITEPACKAGES_DIR}/site.py*
+
+ #
+ # FIXME: Bandaid against wrong datadir computation
+ #
+ if [ -e ${D}${datadir}/share ]; then
+ mv -f ${D}${datadir}/share/* ${D}${datadir}/
+ rmdir ${D}${datadir}/share
+ fi
+
+ # Fix backport modules
+ if [ -e ${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/backports/__init__.py ] &&
+ [ -e ${D}${PYTHON_SITEPACKAGES_DIR}/backports/__init__.py ]; then
+ rm ${D}${PYTHON_SITEPACKAGES_DIR}/backports/__init__.py;
+ rm ${D}${PYTHON_SITEPACKAGES_DIR}/backports/__init__.pyc;
+ fi
+}
+
+EXPORT_FUNCTIONS do_configure do_compile do_install
+
+export LDSHARED="${CCLD} -shared"
diff --git a/classes/python-dir.bbclass b/classes/python-dir.bbclass
new file mode 100644
index 00000000..a11dc350
--- /dev/null
+++ b/classes/python-dir.bbclass
@@ -0,0 +1,5 @@
+PYTHON_BASEVERSION = "2.7"
+PYTHON_ABI = ""
+PYTHON_DIR = "python${PYTHON_BASEVERSION}"
+PYTHON_PN = "python"
+PYTHON_SITEPACKAGES_DIR = "${libdir}/${PYTHON_DIR}/site-packages"
diff --git a/classes/pythonnative.bbclass b/classes/pythonnative.bbclass
new file mode 100644
index 00000000..0e9019d1
--- /dev/null
+++ b/classes/pythonnative.bbclass
@@ -0,0 +1,27 @@
+
+inherit python-dir
+
+PYTHON="${STAGING_BINDIR_NATIVE}/python-native/python"
+# PYTHON_EXECUTABLE is used by cmake
+PYTHON_EXECUTABLE="${PYTHON}"
+EXTRANATIVEPATH += "python-native"
+DEPENDS_append = " python-native "
+
+# python-config and other scripts are using distutils modules
+# which we patch to access these variables
+export STAGING_INCDIR
+export STAGING_LIBDIR
+
+# Packages can use
+# find_package(PythonInterp REQUIRED)
+# find_package(PythonLibs REQUIRED)
+# which ends up using libs/includes from build host
+# Therefore pre-empt that effort
+export PYTHON_LIBRARY="${STAGING_LIBDIR}/lib${PYTHON_DIR}${PYTHON_ABI}.so"
+export PYTHON_INCLUDE_DIR="${STAGING_INCDIR}/${PYTHON_DIR}${PYTHON_ABI}"
+
+# suppress host user's site-packages dirs.
+export PYTHONNOUSERSITE = "1"
+
+# autoconf macros will use their internal default preference otherwise
+export PYTHON
diff --git a/classes/setuptools.bbclass b/classes/setuptools.bbclass
new file mode 100644
index 00000000..a923ea3c
--- /dev/null
+++ b/classes/setuptools.bbclass
@@ -0,0 +1,3 @@
+inherit distutils
+
+DEPENDS += "python-setuptools-native"