blob: 3759b582633158314228e5619f4ecf14d4a2fb25 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001inherit distutils-base
2
3DISTUTILS_BUILD_ARGS ?= ""
4DISTUTILS_STAGE_HEADERS_ARGS ?= "--install-dir=${STAGING_INCDIR}/${PYTHON_DIR}"
5DISTUTILS_STAGE_ALL_ARGS ?= "--prefix=${STAGING_DIR_HOST}${prefix} \
6 --install-data=${STAGING_DATADIR}"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08007DISTUTILS_INSTALL_ARGS ?= "--root=${D} \
8 --prefix=${prefix} \
9 --install-lib=${PYTHON_SITEPACKAGES_DIR} \
10 --install-data=${datadir}"
11
Brad Bishopc342db32019-05-15 21:57:59 -040012DISTUTILS_PYTHON = "python"
13DISTUTILS_PYTHON_class-native = "nativepython"
14
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080015distutils_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 Williamsc124f4f2015-09-15 14:41:29 -050021
22distutils_do_compile() {
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080023 NO_FETCH_BUILD=1 \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050024 STAGING_INCDIR=${STAGING_INCDIR} \
25 STAGING_LIBDIR=${STAGING_LIBDIR} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050026 ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py build ${DISTUTILS_BUILD_ARGS} || \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080027 bbfatal_log "'${PYTHON_PN} setup.py build ${DISTUTILS_BUILD_ARGS}' execution failed."
Patrick Williamsc124f4f2015-09-15 14:41:29 -050028}
29
30distutils_stage_headers() {
31 install -d ${STAGING_DIR_HOST}${PYTHON_SITEPACKAGES_DIR}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050032 ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install_headers ${DISTUTILS_STAGE_HEADERS_ARGS} || \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080033 bbfatal_log "'${PYTHON_PN} setup.py install_headers ${DISTUTILS_STAGE_HEADERS_ARGS}' execution for stage_headers failed."
Patrick Williamsc124f4f2015-09-15 14:41:29 -050034}
35
36distutils_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 Williamsc124f4f2015-09-15 14:41:29 -050041 ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install ${DISTUTILS_STAGE_ALL_ARGS} || \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080042 bbfatal_log "'${PYTHON_PN} setup.py install ${DISTUTILS_STAGE_ALL_ARGS}' execution for stage_all failed."
Patrick Williamsc124f4f2015-09-15 14:41:29 -050043}
44
45distutils_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 Bishop1a4b7ee2018-12-16 17:11:34 -080050 ${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 Williamsc124f4f2015-09-15 14:41:29 -050052
53 # support filenames with *spaces*
54 # only modify file if it contains path and recompile it
Brad Bishopc342db32019-05-15 21:57:59 -040055 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 Williamsc124f4f2015-09-15 14:41:29 -050058
Brad Bishopc342db32019-05-15 21:57:59 -040059 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 Williamsc124f4f2015-09-15 14:41:29 -050062 sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
Brad Bishopc342db32019-05-15 21:57:59 -040063 fi
64 done
Patrick Williamsc124f4f2015-09-15 14:41:29 -050065
66 rm -f ${D}${PYTHON_SITEPACKAGES_DIR}/easy-install.pth
67 rm -f ${D}${PYTHON_SITEPACKAGES_DIR}/site.py*
Brad Bishopc342db32019-05-15 21:57:59 -040068
Patrick Williamsc124f4f2015-09-15 14:41:29 -050069 #
70 # FIXME: Bandaid against wrong datadir computation
71 #
Brad Bishop6e60e8b2018-02-01 10:27:11 -050072 if [ -e ${D}${datadir}/share ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -050073 mv -f ${D}${datadir}/share/* ${D}${datadir}/
74 rmdir ${D}${datadir}/share
75 fi
76
77 # Fix backport modules
Brad Bishopc342db32019-05-15 21:57:59 -040078 if [ -e ${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/backports/__init__.py ] &&
79 [ -e ${D}${PYTHON_SITEPACKAGES_DIR}/backports/__init__.py ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -050080 rm ${D}${PYTHON_SITEPACKAGES_DIR}/backports/__init__.py;
81 rm ${D}${PYTHON_SITEPACKAGES_DIR}/backports/__init__.pyc;
82 fi
83}
84
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080085EXPORT_FUNCTIONS do_configure do_compile do_install
Patrick Williamsc124f4f2015-09-15 14:41:29 -050086
87export LDSHARED="${CCLD} -shared"