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