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