blob: 05a24bfe26f4b6f8f798c6c2121ca5e928ee91fe [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001inherit distutils3-base
2
3DISTUTILS_BUILD_ARGS ?= ""
4DISTUTILS_BUILD_EXT_ARGS ?= ""
5DISTUTILS_STAGE_HEADERS_ARGS ?= "--install-dir=${STAGING_INCDIR}/${PYTHON_DIR}"
6DISTUTILS_STAGE_ALL_ARGS ?= "--prefix=${STAGING_DIR_HOST}${prefix} \
7 --install-data=${STAGING_DATADIR}"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08008DISTUTILS_INSTALL_ARGS ?= "--root=${D} \
9 --prefix=${prefix} \
10 --install-lib=${PYTHON_SITEPACKAGES_DIR} \
11 --install-data=${datadir}"
12
Brad Bishopc342db32019-05-15 21:57:59 -040013DISTUTILS_PYTHON = "python3"
14DISTUTILS_PYTHON_class-native = "nativepython3"
15
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080016distutils3_do_configure() {
17 if [ "${CLEANBROKEN}" != "1" ] ; then
18 NO_FETCH_BUILD=1 \
19 ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py clean ${DISTUTILS_BUILD_ARGS}
20 fi
21}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050022
23distutils3_do_compile() {
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080024 NO_FETCH_BUILD=1 \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050025 STAGING_INCDIR=${STAGING_INCDIR} \
26 STAGING_LIBDIR=${STAGING_LIBDIR} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050027 ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py \
28 build ${DISTUTILS_BUILD_ARGS} || \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080029 bbfatal_log "'${PYTHON_PN} setup.py build ${DISTUTILS_BUILD_ARGS}' execution failed."
Patrick Williamsc124f4f2015-09-15 14:41:29 -050030}
Patrick Williamsf1e5d692016-03-30 15:21:19 -050031distutils3_do_compile[vardepsexclude] = "MACHINE"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050032
33distutils3_stage_headers() {
34 install -d ${STAGING_DIR_HOST}${PYTHON_SITEPACKAGES_DIR}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050035 ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install_headers ${DISTUTILS_STAGE_HEADERS_ARGS} || \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080036 bbfatal_log "'${PYTHON_PN} setup.py install_headers ${DISTUTILS_STAGE_HEADERS_ARGS}' execution for stage_headers failed."
Patrick Williamsc124f4f2015-09-15 14:41:29 -050037}
Patrick Williamsf1e5d692016-03-30 15:21:19 -050038distutils3_stage_headers[vardepsexclude] = "MACHINE"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050039
40distutils3_stage_all() {
Patrick Williamsc124f4f2015-09-15 14:41:29 -050041 STAGING_INCDIR=${STAGING_INCDIR} \
42 STAGING_LIBDIR=${STAGING_LIBDIR} \
43 install -d ${STAGING_DIR_HOST}${PYTHON_SITEPACKAGES_DIR}
44 PYTHONPATH=${STAGING_DIR_HOST}${PYTHON_SITEPACKAGES_DIR} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050045 ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install ${DISTUTILS_STAGE_ALL_ARGS} || \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080046 bbfatal_log "'${PYTHON_PN} setup.py install ${DISTUTILS_STAGE_ALL_ARGS}' execution for stage_all failed."
Patrick Williamsc124f4f2015-09-15 14:41:29 -050047}
Patrick Williamsf1e5d692016-03-30 15:21:19 -050048distutils3_stage_all[vardepsexclude] = "MACHINE"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050049
50distutils3_do_install() {
51 install -d ${D}${PYTHON_SITEPACKAGES_DIR}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050052 STAGING_INCDIR=${STAGING_INCDIR} \
53 STAGING_LIBDIR=${STAGING_LIBDIR} \
54 PYTHONPATH=${D}${PYTHON_SITEPACKAGES_DIR} \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080055 ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install ${DISTUTILS_INSTALL_ARGS} || \
56 bbfatal_log "'${PYTHON_PN} setup.py install ${DISTUTILS_INSTALL_ARGS}' execution failed."
Patrick Williamsc124f4f2015-09-15 14:41:29 -050057
58 # support filenames with *spaces*
Brad Bishopc342db32019-05-15 21:57:59 -040059 find ${D} -name "*.py" -exec grep -q ${D} {} \; \
60 -exec sed -i -e s:${D}::g {} \;
Patrick Williamsc124f4f2015-09-15 14:41:29 -050061
Brad Bishopc342db32019-05-15 21:57:59 -040062 for i in ${D}${bindir}/* ${D}${sbindir}/*; do
63 if [ -f "$i" ]; then
64 sed -i -e s:${PYTHON}:${USRBINPATH}/env\ ${DISTUTILS_PYTHON}:g $i
Patrick Williamsc124f4f2015-09-15 14:41:29 -050065 sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
Brad Bishopc342db32019-05-15 21:57:59 -040066 fi
67 done
Patrick Williamsc124f4f2015-09-15 14:41:29 -050068
69 rm -f ${D}${PYTHON_SITEPACKAGES_DIR}/easy-install.pth
Brad Bishopc342db32019-05-15 21:57:59 -040070
Patrick Williamsc124f4f2015-09-15 14:41:29 -050071 #
72 # FIXME: Bandaid against wrong datadir computation
73 #
Brad Bishop6e60e8b2018-02-01 10:27:11 -050074 if [ -e ${D}${datadir}/share ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -050075 mv -f ${D}${datadir}/share/* ${D}${datadir}/
76 rmdir ${D}${datadir}/share
77 fi
78}
Patrick Williamsf1e5d692016-03-30 15:21:19 -050079distutils3_do_install[vardepsexclude] = "MACHINE"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050080
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080081EXPORT_FUNCTIONS do_configure do_compile do_install
Patrick Williamsc124f4f2015-09-15 14:41:29 -050082
83export LDSHARED="${CCLD} -shared"