blob: 98627314932f10575f0280158fed6204d698a051 [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}"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08007DISTUTILS_INSTALL_ARGS ?= "--root=${D} \
8 --prefix=${prefix} \
9 --install-lib=${PYTHON_SITEPACKAGES_DIR} \
10 --install-data=${datadir}"
11
12distutils_do_configure() {
13 if [ "${CLEANBROKEN}" != "1" ] ; then
14 NO_FETCH_BUILD=1 \
15 ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py clean ${DISTUTILS_BUILD_ARGS}
16 fi
17}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050018
19distutils_do_compile() {
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080020 NO_FETCH_BUILD=1 \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050021 STAGING_INCDIR=${STAGING_INCDIR} \
22 STAGING_LIBDIR=${STAGING_LIBDIR} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050023 ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py build ${DISTUTILS_BUILD_ARGS} || \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080024 bbfatal_log "'${PYTHON_PN} setup.py build ${DISTUTILS_BUILD_ARGS}' execution failed."
Patrick Williamsc124f4f2015-09-15 14:41:29 -050025}
26
27distutils_stage_headers() {
28 install -d ${STAGING_DIR_HOST}${PYTHON_SITEPACKAGES_DIR}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050029 ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install_headers ${DISTUTILS_STAGE_HEADERS_ARGS} || \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080030 bbfatal_log "'${PYTHON_PN} setup.py install_headers ${DISTUTILS_STAGE_HEADERS_ARGS}' execution for stage_headers failed."
Patrick Williamsc124f4f2015-09-15 14:41:29 -050031}
32
33distutils_stage_all() {
34 STAGING_INCDIR=${STAGING_INCDIR} \
35 STAGING_LIBDIR=${STAGING_LIBDIR} \
36 install -d ${STAGING_DIR_HOST}${PYTHON_SITEPACKAGES_DIR}
37 PYTHONPATH=${STAGING_DIR_HOST}${PYTHON_SITEPACKAGES_DIR} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050038 ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install ${DISTUTILS_STAGE_ALL_ARGS} || \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080039 bbfatal_log "'${PYTHON_PN} setup.py install ${DISTUTILS_STAGE_ALL_ARGS}' execution for stage_all failed."
Patrick Williamsc124f4f2015-09-15 14:41:29 -050040}
41
42distutils_do_install() {
43 install -d ${D}${PYTHON_SITEPACKAGES_DIR}
44 STAGING_INCDIR=${STAGING_INCDIR} \
45 STAGING_LIBDIR=${STAGING_LIBDIR} \
46 PYTHONPATH=${D}${PYTHON_SITEPACKAGES_DIR} \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080047 ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install ${DISTUTILS_INSTALL_ARGS} || \
48 bbfatal_log "'${PYTHON_PN} setup.py install ${DISTUTILS_INSTALL_ARGS}' execution failed."
Patrick Williamsc124f4f2015-09-15 14:41:29 -050049
50 # support filenames with *spaces*
51 # only modify file if it contains path and recompile it
52 find ${D} -name "*.py" -exec grep -q ${D} {} \; -exec sed -i -e s:${D}::g {} \; -exec ${STAGING_BINDIR_NATIVE}/python-native/python -mcompileall {} \;
53
54 if test -e ${D}${bindir} ; then
55 for i in ${D}${bindir}/* ; do \
56 if [ ${PN} != "${BPN}-native" ]; then
Brad Bishop6e60e8b2018-02-01 10:27:11 -050057 sed -i -e s:${STAGING_BINDIR_NATIVE}/python-native/python:${USRBINPATH}/env\ python:g $i
Patrick Williamsc124f4f2015-09-15 14:41:29 -050058 fi
59 sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
60 done
61 fi
62
Brad Bishop6e60e8b2018-02-01 10:27:11 -050063 if [ -e ${D}${sbindir} ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -050064 for i in ${D}${sbindir}/* ; do \
65 if [ ${PN} != "${BPN}-native" ]; then
Brad Bishop6e60e8b2018-02-01 10:27:11 -050066 sed -i -e s:${STAGING_BINDIR_NATIVE}/python-native/python:${USRBINPATH}/env\ python:g $i
Patrick Williamsc124f4f2015-09-15 14:41:29 -050067 fi
68 sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
69 done
70 fi
71
72 rm -f ${D}${PYTHON_SITEPACKAGES_DIR}/easy-install.pth
73 rm -f ${D}${PYTHON_SITEPACKAGES_DIR}/site.py*
74
75 #
76 # FIXME: Bandaid against wrong datadir computation
77 #
Brad Bishop6e60e8b2018-02-01 10:27:11 -050078 if [ -e ${D}${datadir}/share ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -050079 mv -f ${D}${datadir}/share/* ${D}${datadir}/
80 rmdir ${D}${datadir}/share
81 fi
82
83 # Fix backport modules
Brad Bishop6e60e8b2018-02-01 10:27:11 -050084 if [ -e ${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/backports/__init__.py ] && [ -e ${D}${PYTHON_SITEPACKAGES_DIR}/backports/__init__.py ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -050085 rm ${D}${PYTHON_SITEPACKAGES_DIR}/backports/__init__.py;
86 rm ${D}${PYTHON_SITEPACKAGES_DIR}/backports/__init__.pyc;
87 fi
88}
89
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080090EXPORT_FUNCTIONS do_configure do_compile do_install
Patrick Williamsc124f4f2015-09-15 14:41:29 -050091
92export LDSHARED="${CCLD} -shared"