Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | inherit distutils-base |
| 2 | |
| 3 | DISTUTILS_BUILD_ARGS ?= "" |
| 4 | DISTUTILS_STAGE_HEADERS_ARGS ?= "--install-dir=${STAGING_INCDIR}/${PYTHON_DIR}" |
| 5 | DISTUTILS_STAGE_ALL_ARGS ?= "--prefix=${STAGING_DIR_HOST}${prefix} \ |
| 6 | --install-data=${STAGING_DATADIR}" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 7 | DISTUTILS_INSTALL_ARGS ?= "--root=${D} \ |
| 8 | --prefix=${prefix} \ |
| 9 | --install-lib=${PYTHON_SITEPACKAGES_DIR} \ |
| 10 | --install-data=${datadir}" |
| 11 | |
| 12 | distutils_do_configure() { |
| 13 | if [ "${CLEANBROKEN}" != "1" ] ; then |
| 14 | NO_FETCH_BUILD=1 \ |
| 15 | ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py clean ${DISTUTILS_BUILD_ARGS} |
| 16 | fi |
| 17 | } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 18 | |
| 19 | distutils_do_compile() { |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 20 | NO_FETCH_BUILD=1 \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 21 | STAGING_INCDIR=${STAGING_INCDIR} \ |
| 22 | STAGING_LIBDIR=${STAGING_LIBDIR} \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 23 | ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py build ${DISTUTILS_BUILD_ARGS} || \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 24 | bbfatal_log "'${PYTHON_PN} setup.py build ${DISTUTILS_BUILD_ARGS}' execution failed." |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | distutils_stage_headers() { |
| 28 | install -d ${STAGING_DIR_HOST}${PYTHON_SITEPACKAGES_DIR} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 29 | ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install_headers ${DISTUTILS_STAGE_HEADERS_ARGS} || \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 30 | bbfatal_log "'${PYTHON_PN} setup.py install_headers ${DISTUTILS_STAGE_HEADERS_ARGS}' execution for stage_headers failed." |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | distutils_stage_all() { |
| 34 | STAGING_INCDIR=${STAGING_INCDIR} \ |
| 35 | STAGING_LIBDIR=${STAGING_LIBDIR} \ |
| 36 | install -d ${STAGING_DIR_HOST}${PYTHON_SITEPACKAGES_DIR} |
| 37 | PYTHONPATH=${STAGING_DIR_HOST}${PYTHON_SITEPACKAGES_DIR} \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 38 | ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install ${DISTUTILS_STAGE_ALL_ARGS} || \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 39 | bbfatal_log "'${PYTHON_PN} setup.py install ${DISTUTILS_STAGE_ALL_ARGS}' execution for stage_all failed." |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | distutils_do_install() { |
| 43 | install -d ${D}${PYTHON_SITEPACKAGES_DIR} |
| 44 | STAGING_INCDIR=${STAGING_INCDIR} \ |
| 45 | STAGING_LIBDIR=${STAGING_LIBDIR} \ |
| 46 | PYTHONPATH=${D}${PYTHON_SITEPACKAGES_DIR} \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 47 | ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install ${DISTUTILS_INSTALL_ARGS} || \ |
| 48 | bbfatal_log "'${PYTHON_PN} setup.py install ${DISTUTILS_INSTALL_ARGS}' execution failed." |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 49 | |
| 50 | # support filenames with *spaces* |
| 51 | # only modify file if it contains path and recompile it |
| 52 | find ${D} -name "*.py" -exec grep -q ${D} {} \; -exec sed -i -e s:${D}::g {} \; -exec ${STAGING_BINDIR_NATIVE}/python-native/python -mcompileall {} \; |
| 53 | |
| 54 | if test -e ${D}${bindir} ; then |
| 55 | for i in ${D}${bindir}/* ; do \ |
| 56 | if [ ${PN} != "${BPN}-native" ]; then |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 57 | sed -i -e s:${STAGING_BINDIR_NATIVE}/python-native/python:${USRBINPATH}/env\ python:g $i |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 58 | fi |
| 59 | sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i |
| 60 | done |
| 61 | fi |
| 62 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 63 | if [ -e ${D}${sbindir} ]; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 64 | for i in ${D}${sbindir}/* ; do \ |
| 65 | if [ ${PN} != "${BPN}-native" ]; then |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 66 | sed -i -e s:${STAGING_BINDIR_NATIVE}/python-native/python:${USRBINPATH}/env\ python:g $i |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 67 | fi |
| 68 | sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i |
| 69 | done |
| 70 | fi |
| 71 | |
| 72 | rm -f ${D}${PYTHON_SITEPACKAGES_DIR}/easy-install.pth |
| 73 | rm -f ${D}${PYTHON_SITEPACKAGES_DIR}/site.py* |
| 74 | |
| 75 | # |
| 76 | # FIXME: Bandaid against wrong datadir computation |
| 77 | # |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 78 | if [ -e ${D}${datadir}/share ]; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 79 | mv -f ${D}${datadir}/share/* ${D}${datadir}/ |
| 80 | rmdir ${D}${datadir}/share |
| 81 | fi |
| 82 | |
| 83 | # Fix backport modules |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 84 | if [ -e ${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/backports/__init__.py ] && [ -e ${D}${PYTHON_SITEPACKAGES_DIR}/backports/__init__.py ]; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 85 | rm ${D}${PYTHON_SITEPACKAGES_DIR}/backports/__init__.py; |
| 86 | rm ${D}${PYTHON_SITEPACKAGES_DIR}/backports/__init__.pyc; |
| 87 | fi |
| 88 | } |
| 89 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 90 | EXPORT_FUNCTIONS do_configure do_compile do_install |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 91 | |
| 92 | export LDSHARED="${CCLD} -shared" |