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