diff options
author | Khem Raj <raj.khem@gmail.com> | 2013-03-09 22:08:32 -0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-02-02 22:37:39 +0000 |
commit | 0221af0f4ee9e8bfb8796841bdf806e38bc600c6 (patch) | |
tree | 5d837c92c24e005ab276257aa2fcf96c2bba7b9a /meta | |
parent | 8314590f099ec3e0592355b192ef80a2e71daac0 (diff) | |
download | poky-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')
-rw-r--r-- | meta/classes/distutils-tools.bbclass | 77 | ||||
-rw-r--r-- | meta/classes/distutils3-base.bbclass | 5 | ||||
-rw-r--r-- | meta/classes/distutils3-native-base.bbclass | 3 | ||||
-rw-r--r-- | meta/classes/distutils3.bbclass | 98 | ||||
-rw-r--r-- | meta/classes/setuptools.bbclass | 3 | ||||
-rw-r--r-- | meta/classes/setuptools3.bbclass | 8 |
6 files changed, 192 insertions, 2 deletions
diff --git a/meta/classes/distutils-tools.bbclass b/meta/classes/distutils-tools.bbclass new file mode 100644 index 0000000000..f43450e56f --- /dev/null +++ b/meta/classes/distutils-tools.bbclass | |||
@@ -0,0 +1,77 @@ | |||
1 | DISTUTILS_BUILD_ARGS ?= "" | ||
2 | DISTUTILS_STAGE_HEADERS_ARGS ?= "--install-dir=${STAGING_INCDIR}/${PYTHON_DIR}" | ||
3 | DISTUTILS_STAGE_ALL_ARGS ?= "--prefix=${STAGING_DIR_HOST}${prefix} \ | ||
4 | --install-data=${STAGING_DATADIR}" | ||
5 | DISTUTILS_INSTALL_ARGS ?= "--prefix=${D}/${prefix} \ | ||
6 | --install-data=${D}/${datadir}" | ||
7 | |||
8 | distutils_do_compile() { | ||
9 | STAGING_INCDIR=${STAGING_INCDIR} \ | ||
10 | STAGING_LIBDIR=${STAGING_LIBDIR} \ | ||
11 | BUILD_SYS=${BUILD_SYS} HOST_SYS=${HOST_SYS} \ | ||
12 | ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py build ${DISTUTILS_BUILD_ARGS} || \ | ||
13 | bbfatal "${PYTHON_PN} setup.py build_ext execution failed." | ||
14 | } | ||
15 | |||
16 | distutils_stage_headers() { | ||
17 | install -d ${STAGING_DIR_HOST}${PYTHON_SITEPACKAGES_DIR} | ||
18 | BUILD_SYS=${BUILD_SYS} HOST_SYS=${HOST_SYS} \ | ||
19 | ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install_headers ${DISTUTILS_STAGE_HEADERS_ARGS} || \ | ||
20 | bbfatal "${PYTHON_PN} setup.py install_headers execution failed." | ||
21 | } | ||
22 | |||
23 | distutils_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} \ | ||
28 | BUILD_SYS=${BUILD_SYS} HOST_SYS=${HOST_SYS} \ | ||
29 | ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py install ${DISTUTILS_STAGE_ALL_ARGS} || \ | ||
30 | bbfatal "${PYTHON_PN} setup.py install (stage) execution failed." | ||
31 | } | ||
32 | |||
33 | distutils_do_install() { | ||
34 | echo "Beginning ${PN} Install ..." | ||
35 | install -d ${D}${PYTHON_SITEPACKAGES_DIR} | ||
36 | echo "Step 2 of ${PN} Install ..." | ||
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 | echo "Step 3 of ${PN} Install ..." | ||
45 | # support filenames with *spaces* | ||
46 | find ${D} -name "*.py" -print0 | while read -d $'\0' i ; do \ | ||
47 | sed -i -e s:${D}::g $i | ||
48 | done | ||
49 | |||
50 | echo "Step 4 of ${PN} Install ..." | ||
51 | if test -e ${D}${bindir} ; then | ||
52 | for i in ${D}${bindir}/* ; do \ | ||
53 | sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i | ||
54 | done | ||
55 | fi | ||
56 | |||
57 | echo "Step 4 of ${PN} Install ..." | ||
58 | if test -e ${D}${sbindir}; then | ||
59 | for i in ${D}${sbindir}/* ; do \ | ||
60 | sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i | ||
61 | done | ||
62 | fi | ||
63 | |||
64 | echo "Step 5 of ${PN} Install ..." | ||
65 | rm -f ${D}${PYTHON_SITEPACKAGES_DIR}/easy-install.pth | ||
66 | |||
67 | # | ||
68 | # FIXME: Bandaid against wrong datadir computation | ||
69 | # | ||
70 | if test -e ${D}${datadir}/share; then | ||
71 | mv -f ${D}${datadir}/share/* ${D}${datadir}/ | ||
72 | fi | ||
73 | } | ||
74 | |||
75 | #EXPORT_FUNCTIONS do_compile do_install | ||
76 | |||
77 | export LDSHARED="${CCLD} -shared" | ||
diff --git a/meta/classes/distutils3-base.bbclass b/meta/classes/distutils3-base.bbclass new file mode 100644 index 0000000000..82ab6a3d1c --- /dev/null +++ b/meta/classes/distutils3-base.bbclass | |||
@@ -0,0 +1,5 @@ | |||
1 | DEPENDS += "${@["${PYTHON_PN}-native ${PYTHON_PN}", ""][(d.getVar('PACKAGES', True) == '')]}" | ||
2 | RDEPENDS_${PN} += "${@['', '${PYTHON_PN}-core']['${CLASSOVERRIDE}' == 'class-target']}" | ||
3 | |||
4 | inherit distutils-common-base python3native | ||
5 | |||
diff --git a/meta/classes/distutils3-native-base.bbclass b/meta/classes/distutils3-native-base.bbclass new file mode 100644 index 0000000000..b4a333f4d4 --- /dev/null +++ b/meta/classes/distutils3-native-base.bbclass | |||
@@ -0,0 +1,3 @@ | |||
1 | PYTHON_BASEVERSION = "3.3" | ||
2 | |||
3 | inherit distutils-native-base | ||
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 @@ | |||
1 | inherit distutils3-base | ||
2 | |||
3 | DISTUTILS_BUILD_ARGS ?= "" | ||
4 | DISTUTILS_BUILD_EXT_ARGS ?= "" | ||
5 | DISTUTILS_STAGE_HEADERS_ARGS ?= "--install-dir=${STAGING_INCDIR}/${PYTHON_DIR}" | ||
6 | DISTUTILS_STAGE_ALL_ARGS ?= "--prefix=${STAGING_DIR_HOST}${prefix} \ | ||
7 | --install-data=${STAGING_DATADIR}" | ||
8 | DISTUTILS_INSTALL_ARGS ?= "--prefix=${D}/${prefix} \ | ||
9 | --install-data=${D}/${datadir}" | ||
10 | |||
11 | distutils3_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 | |||
25 | distutils3_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 | |||
37 | distutils3_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 | |||
52 | distutils3_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 | |||
96 | EXPORT_FUNCTIONS do_compile do_install | ||
97 | |||
98 | export LDSHARED="${CCLD} -shared" | ||
diff --git a/meta/classes/setuptools.bbclass b/meta/classes/setuptools.bbclass index ba9cf13295..56343b1c73 100644 --- a/meta/classes/setuptools.bbclass +++ b/meta/classes/setuptools.bbclass | |||
@@ -1,9 +1,8 @@ | |||
1 | inherit distutils | 1 | inherit distutils |
2 | 2 | ||
3 | DEPENDS += "python-setuptools-native" | 3 | DEPENDS += "python-distribute-native" |
4 | 4 | ||
5 | DISTUTILS_INSTALL_ARGS = "--root=${D} \ | 5 | DISTUTILS_INSTALL_ARGS = "--root=${D} \ |
6 | --single-version-externally-managed \ | ||
7 | --prefix=${prefix} \ | 6 | --prefix=${prefix} \ |
8 | --install-lib=${PYTHON_SITEPACKAGES_DIR} \ | 7 | --install-lib=${PYTHON_SITEPACKAGES_DIR} \ |
9 | --install-data=${datadir}" | 8 | --install-data=${datadir}" |
diff --git a/meta/classes/setuptools3.bbclass b/meta/classes/setuptools3.bbclass new file mode 100644 index 0000000000..40c18c8976 --- /dev/null +++ b/meta/classes/setuptools3.bbclass | |||
@@ -0,0 +1,8 @@ | |||
1 | inherit distutils3 | ||
2 | |||
3 | DEPENDS += "python3-distribute-native" | ||
4 | |||
5 | DISTUTILS_INSTALL_ARGS = "--root=${D} \ | ||
6 | --prefix=${prefix} \ | ||
7 | --install-lib=${PYTHON_SITEPACKAGES_DIR} \ | ||
8 | --install-data=${datadir}" | ||