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