summaryrefslogtreecommitdiffstats
path: root/meta/classes/distutils3.bbclass
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2013-03-09 22:08:32 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-02-02 22:37:39 +0000
commit0221af0f4ee9e8bfb8796841bdf806e38bc600c6 (patch)
tree5d837c92c24e005ab276257aa2fcf96c2bba7b9a /meta/classes/distutils3.bbclass
parent8314590f099ec3e0592355b192ef80a2e71daac0 (diff)
downloadpoky-0221af0f4ee9e8bfb8796841bdf806e38bc600c6.tar.gz
classes: Add distutils for python3
In line with python2 add distutils and setuptools classes for handing python3 Use python-distribute instead of python-setuptools in setuptools bbclass Remove --single-version-externally-managed since its setuptools specific and we dont use it anymore Do build_ext as separate step during compile Add DISTUTILS_BUILD_EXT_ARGS for modules to pass flags to build_ext step in setup.py Add build_ext as sepate step during compile and add the cross sysrooted library and headers since we are cross compiling Use ${PYTHON_PN} in place of hardcoding python name Remove the /etc/share if its empty Since OE-Core times we now have machine specific sysroots for targets unlike before when we used arch specific sysroots so reflect that here Use MACHINE for sysroot when not building for build host Python's machinery replaces directories in sysroot path to match OE's staging area sysroots. Earlier we use to have HOST_SYS represent sysroot always but now we use MACHINE to represent target sysroots but HOST_SYS to represent host sysroot. This patch caters to that difference (From OE-Core rev: 8bb0206ed67228c88dd5bc2d8b36ce28f48b78f4) Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/distutils3.bbclass')
-rw-r--r--meta/classes/distutils3.bbclass98
1 files changed, 98 insertions, 0 deletions
diff --git a/meta/classes/distutils3.bbclass b/meta/classes/distutils3.bbclass
new file mode 100644
index 0000000000..bbd645cc63
--- /dev/null
+++ b/meta/classes/distutils3.bbclass
@@ -0,0 +1,98 @@
1inherit 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" -print0 | while read -d $'\0' i ; do \
68 sed -i -e s:${D}::g "$i"
69 done
70
71 if test -e ${D}${bindir} ; then
72 for i in ${D}${bindir}/* ; do \
73 sed -i -e s:${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN}:${bindir}/env\ ${PYTHON_PN}:g $i
74 sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
75 done
76 fi
77
78 if test -e ${D}${sbindir}; then
79 for i in ${D}${sbindir}/* ; do \
80 sed -i -e s:${STAGING_BINDIR_NATIVE}/python-${PYTHON_PN}/${PYTHON_PN}:${bindir}/env\ ${PYTHON_PN}:g $i
81 sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
82 done
83 fi
84
85 rm -f ${D}${PYTHON_SITEPACKAGES_DIR}/easy-install.pth
86
87 #
88 # FIXME: Bandaid against wrong datadir computation
89 #
90 if test -e ${D}${datadir}/share; then
91 mv -f ${D}${datadir}/share/* ${D}${datadir}/
92 rmdir ${D}${datadir}/share
93 fi
94}
95
96EXPORT_FUNCTIONS do_compile do_install
97
98export LDSHARED="${CCLD} -shared"