blob: e909ef41b6629de90181f3f936dd176e9102ee3a [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} || \
22 bbfatal "${PYTHON_PN} setup.py build_ext execution failed."
23}
24
25distutils3_stage_headers() {
26 install -d ${STAGING_DIR_HOST}${PYTHON_SITEPACKAGES_DIR}
27 if [ ${BUILD_SYS} != ${HOST_SYS} ]; then
28 SYS=${MACHINE}
29 else
30 SYS=${HOST_SYS}
31 fi
32 BUILD_SYS=${BUILD_SYS} HOST_SYS=${SYS} \
33 ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install_headers ${DISTUTILS_STAGE_HEADERS_ARGS} || \
34 bbfatal "${PYTHON_PN} setup.py install_headers execution failed."
35}
36
37distutils3_stage_all() {
38 if [ ${BUILD_SYS} != ${HOST_SYS} ]; then
39 SYS=${MACHINE}
40 else
41 SYS=${HOST_SYS}
42 fi
43 STAGING_INCDIR=${STAGING_INCDIR} \
44 STAGING_LIBDIR=${STAGING_LIBDIR} \
45 install -d ${STAGING_DIR_HOST}${PYTHON_SITEPACKAGES_DIR}
46 PYTHONPATH=${STAGING_DIR_HOST}${PYTHON_SITEPACKAGES_DIR} \
47 BUILD_SYS=${BUILD_SYS} HOST_SYS=${SYS} \
48 ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install ${DISTUTILS_STAGE_ALL_ARGS} || \
49 bbfatal "${PYTHON_PN} setup.py install (stage) execution failed."
50}
51
52distutils3_do_install() {
53 install -d ${D}${PYTHON_SITEPACKAGES_DIR}
54 if [ ${BUILD_SYS} != ${HOST_SYS} ]; then
55 SYS=${MACHINE}
56 else
57 SYS=${HOST_SYS}
58 fi
59 STAGING_INCDIR=${STAGING_INCDIR} \
60 STAGING_LIBDIR=${STAGING_LIBDIR} \
61 PYTHONPATH=${D}${PYTHON_SITEPACKAGES_DIR} \
62 BUILD_SYS=${BUILD_SYS} HOST_SYS=${SYS} \
63 ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install --install-lib=${D}/${PYTHON_SITEPACKAGES_DIR} ${DISTUTILS_INSTALL_ARGS} || \
64 bbfatal "${PYTHON_PN} setup.py install execution failed."
65
66 # support filenames with *spaces*
67 find ${D} -name "*.py" -exec grep -q ${D} {} \; -exec sed -i -e s:${D}::g {} \;
68
69 if test -e ${D}${bindir} ; then
70 for i in ${D}${bindir}/* ; do \
71 sed -i -e s:${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN}:${bindir}/env\ ${PYTHON_PN}:g $i
72 sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
73 done
74 fi
75
76 if test -e ${D}${sbindir}; then
77 for i in ${D}${sbindir}/* ; do \
78 sed -i -e s:${STAGING_BINDIR_NATIVE}/python-${PYTHON_PN}/${PYTHON_PN}:${bindir}/env\ ${PYTHON_PN}:g $i
79 sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
80 done
81 fi
82
83 rm -f ${D}${PYTHON_SITEPACKAGES_DIR}/easy-install.pth
84
85 #
86 # FIXME: Bandaid against wrong datadir computation
87 #
88 if test -e ${D}${datadir}/share; then
89 mv -f ${D}${datadir}/share/* ${D}${datadir}/
90 rmdir ${D}${datadir}/share
91 fi
92}
93
94EXPORT_FUNCTIONS do_compile do_install
95
96export LDSHARED="${CCLD} -shared"