blob: 4f6ca44822c81751e9fca79e3d0df9294fe2e01a [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}"
8DISTUTILS_INSTALL_ARGS ?= "--prefix=${D}/${prefix} \
9 --install-data=${D}/${datadir}"
10
11distutils3_do_compile() {
12 if [ ${BUILD_SYS} != ${HOST_SYS} ]; then
13 SYS=${MACHINE}
14 else
15 SYS=${HOST_SYS}
16 fi
17 STAGING_INCDIR=${STAGING_INCDIR} \
18 STAGING_LIBDIR=${STAGING_LIBDIR} \
19 BUILD_SYS=${BUILD_SYS} HOST_SYS=${SYS} \
20 ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py \
21 build ${DISTUTILS_BUILD_ARGS} || \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050022 bbfatal_log "${PYTHON_PN} setup.py build_ext execution failed."
Patrick Williamsc124f4f2015-09-15 14:41:29 -050023}
Patrick Williamsf1e5d692016-03-30 15:21:19 -050024distutils3_do_compile[vardepsexclude] = "MACHINE"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050025
26distutils3_stage_headers() {
27 install -d ${STAGING_DIR_HOST}${PYTHON_SITEPACKAGES_DIR}
28 if [ ${BUILD_SYS} != ${HOST_SYS} ]; then
29 SYS=${MACHINE}
30 else
31 SYS=${HOST_SYS}
32 fi
33 BUILD_SYS=${BUILD_SYS} HOST_SYS=${SYS} \
34 ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install_headers ${DISTUTILS_STAGE_HEADERS_ARGS} || \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050035 bbfatal_log "${PYTHON_PN} setup.py install_headers execution failed."
Patrick Williamsc124f4f2015-09-15 14:41:29 -050036}
Patrick Williamsf1e5d692016-03-30 15:21:19 -050037distutils3_stage_headers[vardepsexclude] = "MACHINE"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050038
39distutils3_stage_all() {
40 if [ ${BUILD_SYS} != ${HOST_SYS} ]; then
41 SYS=${MACHINE}
42 else
43 SYS=${HOST_SYS}
44 fi
45 STAGING_INCDIR=${STAGING_INCDIR} \
46 STAGING_LIBDIR=${STAGING_LIBDIR} \
47 install -d ${STAGING_DIR_HOST}${PYTHON_SITEPACKAGES_DIR}
48 PYTHONPATH=${STAGING_DIR_HOST}${PYTHON_SITEPACKAGES_DIR} \
49 BUILD_SYS=${BUILD_SYS} HOST_SYS=${SYS} \
50 ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install ${DISTUTILS_STAGE_ALL_ARGS} || \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050051 bbfatal_log "${PYTHON_PN} setup.py install (stage) execution failed."
Patrick Williamsc124f4f2015-09-15 14:41:29 -050052}
Patrick Williamsf1e5d692016-03-30 15:21:19 -050053distutils3_stage_all[vardepsexclude] = "MACHINE"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050054
55distutils3_do_install() {
56 install -d ${D}${PYTHON_SITEPACKAGES_DIR}
57 if [ ${BUILD_SYS} != ${HOST_SYS} ]; then
58 SYS=${MACHINE}
59 else
60 SYS=${HOST_SYS}
61 fi
62 STAGING_INCDIR=${STAGING_INCDIR} \
63 STAGING_LIBDIR=${STAGING_LIBDIR} \
64 PYTHONPATH=${D}${PYTHON_SITEPACKAGES_DIR} \
65 BUILD_SYS=${BUILD_SYS} HOST_SYS=${SYS} \
66 ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install --install-lib=${D}/${PYTHON_SITEPACKAGES_DIR} ${DISTUTILS_INSTALL_ARGS} || \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050067 bbfatal_log "${PYTHON_PN} setup.py install execution failed."
Patrick Williamsc124f4f2015-09-15 14:41:29 -050068
69 # support filenames with *spaces*
70 find ${D} -name "*.py" -exec grep -q ${D} {} \; -exec sed -i -e s:${D}::g {} \;
71
72 if test -e ${D}${bindir} ; then
73 for i in ${D}${bindir}/* ; do \
74 sed -i -e s:${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN}:${bindir}/env\ ${PYTHON_PN}:g $i
75 sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
76 done
77 fi
78
79 if test -e ${D}${sbindir}; then
80 for i in ${D}${sbindir}/* ; do \
81 sed -i -e s:${STAGING_BINDIR_NATIVE}/python-${PYTHON_PN}/${PYTHON_PN}:${bindir}/env\ ${PYTHON_PN}:g $i
82 sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
83 done
84 fi
85
86 rm -f ${D}${PYTHON_SITEPACKAGES_DIR}/easy-install.pth
87
88 #
89 # FIXME: Bandaid against wrong datadir computation
90 #
91 if test -e ${D}${datadir}/share; then
92 mv -f ${D}${datadir}/share/* ${D}${datadir}/
93 rmdir ${D}${datadir}/share
94 fi
95}
Patrick Williamsf1e5d692016-03-30 15:21:19 -050096distutils3_do_install[vardepsexclude] = "MACHINE"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050097
98EXPORT_FUNCTIONS do_compile do_install
99
100export LDSHARED="${CCLD} -shared"