From 39ddef6a83eb43857f3d46296a30f68ac27e89d5 Mon Sep 17 00:00:00 2001 From: Ross Burton Date: Mon, 20 Jan 2020 17:14:33 +0000 Subject: 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 Signed-off-by: Tim Orling --- classes/distutils-base.bbclass | 4 ++ classes/distutils.bbclass | 87 ++++++++++++++++++++++++++++++++++++++++++ classes/python-dir.bbclass | 5 +++ classes/pythonnative.bbclass | 27 +++++++++++++ classes/setuptools.bbclass | 3 ++ 5 files changed, 126 insertions(+) create mode 100644 classes/distutils-base.bbclass create mode 100644 classes/distutils.bbclass create mode 100644 classes/python-dir.bbclass create mode 100644 classes/pythonnative.bbclass create mode 100644 classes/setuptools.bbclass (limited to 'classes') diff --git a/classes/distutils-base.bbclass b/classes/distutils-base.bbclass new file mode 100644 index 0000000..9f398d7 --- /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 0000000..3759b58 --- /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 0000000..a11dc35 --- /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 0000000..0e9019d --- /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 0000000..a923ea3 --- /dev/null +++ b/classes/setuptools.bbclass @@ -0,0 +1,3 @@ +inherit distutils + +DEPENDS += "python-setuptools-native" -- cgit 1.2.3-korg