2 DEPENDS = "python-native bzip2 db gdbm openssl readline sqlite3 zlib"
5 DISTRO_SRC_URI ?= "file://sitecustomize.py"
6 DISTRO_SRC_URI_linuxstdbase = ""
8 file://01-fix-have-long-long-format.patch;patch=1 \
9 file://01-use-proper-tools-for-cross-build.patch;patch=1 \
10 file://03-fix-tkinter-detection.patch;patch=1 \
11 file://05-enable-ctypes-cross-build.patch;patch=1 \
12 file://06-ctypes-libffi-fix-configure.patch;patch=1 \
13 file://06-avoid_usr_lib_termcap_path_in_linking.patch;patch=1 \
15 file://multilib.patch;patch=1 \
16 file://cgi_py.patch;patch=1 \
17 file://remove_sqlite_rpath.patch;patch=1 \
18 file://setup_py_skip_cross_import_check.patch;patch=1 \
19 file://add-md5module-support.patch;patch=1 \
20 file://host_include_contamination.patch;patch=1 \
21 file://fix_for_using_different_libdir.patch;patch=1 \
22 file://setuptweaks.patch;patch=1 \
23 file://check-if-target-is-64b-not-host.patch;patch=1 \
24 file://search_db_h_in_inc_dirs_and_avoid_warning.patch;patch=1 \
25 file://avoid_warning_about_tkinter.patch;patch=1 \
26 file://avoid_warning_for_sunos_specific_module.patch;patch=1 \
27 file://python-2.7.3-berkeley-db-5.3.patch;patch=1 \
28 file://python-2.7.3-remove-bsdb-rpath.patch;patch=1 \
29 file://builddir.patch;patch=1 \
30 file://python-2.7.3-CVE-2012-2135.patch;patch=1 \
31 file://gcc-4.8-fix-configure-Wformat.patch;patch=1 \
32 file://fix-makefile-for-ptest.patch;patch=1 \
34 file://CVE-2013-4073_py27.patch;patch=1 \
35 file://pypirc-secure.patch;patch=1 \
36 file://parallel-makeinst-create-bindir.patch;patch=1 \
39 S = "${WORKDIR}/Python-${PV}"
41 inherit autotools pythonnative
42 # inherit multilib_header
44 # The 3 lines below are copied from the libffi recipe, ctypes ships its own copy of the libffi sources
45 #Somehow gcc doesn't set __SOFTFP__ when passing -mfloatabi=softp :(
46 TARGET_CC_ARCH_append_armv6 = " -D__SOFTFP__"
47 TARGET_CC_ARCH_append_armv7a = " -D__SOFTFP__"
49 do_configure_prepend() {
50 rm -f ${S}/Makefile.orig
51 autoreconf -Wcross --verbose --install --force --exclude=autopoint Modules/_ctypes/libffi || bbnote "_ctypes failed to autoreconf"
55 # regenerate platform specific files, because they depend on system headers
57 include=${STAGING_INCDIR} ${STAGING_BINDIR_NATIVE}/python \
58 ${S}/Tools/scripts/h2py.py -i '(u_long)' \
59 ${STAGING_INCDIR}/dlfcn.h \
60 ${STAGING_INCDIR}/linux/cdrom.h \
61 ${STAGING_INCDIR}/netinet/in.h \
62 ${STAGING_INCDIR}/sys/types.h
63 sed -e 's,${STAGING_DIR_HOST},,g' -i *.py
66 # remove hardcoded ccache, see http://bugs.openembedded.net/show_bug.cgi?id=4144
67 sed -i -e s,ccache\ ,'$(CCACHE) ', Makefile
69 # remove any bogus LD_LIBRARY_PATH
70 sed -i -e s,RUNSHARED=.*,RUNSHARED=, Makefile
72 if [ ! -f Makefile.orig ]; then
73 install -m 0644 Makefile Makefile.orig
75 sed -i -e 's,^LDFLAGS=.*,LDFLAGS+=-L. -L${STAGING_LIBDIR},g' \
76 -e 's,libdir=${libdir},libdir=${STAGING_LIBDIR},g' \
77 -e 's,libexecdir=${libexecdir},libexecdir=${STAGING_DIR_HOST}${libexecdir},g' \
78 -e 's,^LIBDIR=.*,LIBDIR=${STAGING_LIBDIR},g' \
79 -e 's,includedir=${includedir},includedir=${STAGING_INCDIR},g' \
80 -e 's,^INCLUDEDIR=.*,INCLUDE=${STAGING_INCDIR},g' \
81 -e 's,^CONFINCLUDEDIR=.*,CONFINCLUDE=${STAGING_INCDIR},g' \
83 # save copy of it now, because if we do it in do_install and
84 # then call do_install twice we get Makefile.orig == Makefile.sysroot
85 install -m 0644 Makefile Makefile.sysroot
87 export CROSS_COMPILE="${TARGET_PREFIX}"
88 export PYTHONBUILDDIR="${S}"
90 oe_runmake HOSTPGEN=${STAGING_BINDIR_NATIVE}/pgen \
91 HOSTPYTHON=${STAGING_BINDIR_NATIVE}/python \
92 STAGING_LIBDIR=${STAGING_LIBDIR} \
93 STAGING_INCDIR=${STAGING_INCDIR} \
94 STAGING_BASELIBDIR=${STAGING_BASELIBDIR} \
95 BUILD_SYS=${BUILD_SYS} HOST_SYS=${HOST_SYS} \
100 # make install needs the original Makefile, or otherwise the inclues would
101 # go to ${D}${STAGING...}/...
102 install -m 0644 Makefile.orig Makefile
104 export CROSS_COMPILE="${TARGET_PREFIX}"
105 export PYTHONBUILDDIR="${S}"
107 # After swizzling the makefile, we need to run the build again.
108 # install can race with the build so we have to run this first, then install
109 oe_runmake HOSTPGEN=${STAGING_BINDIR_NATIVE}/pgen \
110 HOSTPYTHON=${STAGING_BINDIR_NATIVE}/python \
111 CROSSPYTHONPATH=${STAGING_LIBDIR_NATIVE}/python${PYTHON_MAJMIN}/lib-dynload/ \
112 STAGING_LIBDIR=${STAGING_LIBDIR} \
113 STAGING_INCDIR=${STAGING_INCDIR} \
114 STAGING_BASELIBDIR=${STAGING_BASELIBDIR} \
115 BUILD_SYS=${BUILD_SYS} HOST_SYS=${HOST_SYS} \
116 DESTDIR=${D} LIBDIR=${libdir}
118 oe_runmake HOSTPGEN=${STAGING_BINDIR_NATIVE}/pgen \
119 HOSTPYTHON=${STAGING_BINDIR_NATIVE}/python \
120 CROSSPYTHONPATH=${STAGING_LIBDIR_NATIVE}/python${PYTHON_MAJMIN}/lib-dynload/ \
121 STAGING_LIBDIR=${STAGING_LIBDIR} \
122 STAGING_INCDIR=${STAGING_INCDIR} \
123 STAGING_BASELIBDIR=${STAGING_BASELIBDIR} \
124 BUILD_SYS=${BUILD_SYS} HOST_SYS=${HOST_SYS} \
125 DESTDIR=${D} LIBDIR=${libdir} install
127 install -m 0644 Makefile.sysroot ${D}/${libdir}/python${PYTHON_MAJMIN}/config/Makefile
129 if [ -e ${WORKDIR}/sitecustomize.py ]; then
130 install -m 0644 ${WORKDIR}/sitecustomize.py ${D}/${libdir}/python${PYTHON_MAJMIN}
133 # oe_multilib_header python${PYTHON_MAJMIN}/pyconfig.h
136 #do_install_append_class-nativesdk () {
137 # create_wrapper ${D}${bindir}/python2.7 TERMINFO_DIRS='${sysconfdir}/terminfo:/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo'
140 SSTATE_SCAN_FILES += "Makefile"
141 PACKAGE_PREPROCESS_FUNCS += "py_package_preprocess"
143 py_package_preprocess () {
144 # copy back the old Makefile to fix target package
145 install -m 0644 Makefile.orig ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config/Makefile
147 # Remove references to buildmachine paths in target Makefile
148 sed -i -e 's:--sysroot=${STAGING_DIR_TARGET}::g' -e s:'--with-libtool-sysroot=${STAGING_DIR_TARGET}'::g ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config/Makefile
151 require python-${PYTHON_MAJMIN}-manifest.inc
153 # manual dependency additions
154 RPROVIDES_${PN}-core = "${PN}"
155 RRECOMMENDS_${PN}-core = "${PN}-readline"
156 RRECOMMENDS_${PN}-crypt = "openssl"
157 # RRECOMMENDS_${PN}-crypt_class-nativesdk = "nativesdk-openssl"
160 PACKAGES =+ "lib${BPN}2"
161 FILES_lib${BPN}2 = "${libdir}/libpython*.so.*"
163 # catch debug extensions (isn't that already in python-core-dbg?)
164 FILES_${PN}-dbg += "${libdir}/python${PYTHON_MAJMIN}/lib-dynload/.debug"
166 # catch all the rest (unsorted)
167 PACKAGES += "${PN}-misc"
168 FILES_${PN}-misc = "${libdir}/python${PYTHON_MAJMIN}"
169 RDEPENDS_${PN}-ptest = "${PN}-modules ${PN}-misc"
170 #inherit ptest after "require python-${PYTHON_MAJMIN}-manifest.inc" so PACKAGES doesn't get overwritten
173 # This must come after inherit ptest for the override to take effect
175 cp ${B}/Makefile ${D}${PTEST_PATH}
176 sed -e s:LIBDIR/python/ptest:${PTEST_PATH}:g \
177 -e s:LIBDIR:${libdir}:g \
178 -i ${D}${PTEST_PATH}/run-ptest
182 PACKAGES += "${PN}-man"
183 FILES_${PN}-man = "${datadir}/man"
185 # BBCLASSEXTEND = "nativesdk"
189 # additional stuff -dev
191 FILES_${PN}-dev += "\
193 ${libdir}/lib*${SOLIBSDEV} \
197 ${libdir}/pkgconfig \
201 ${datadir}/pkgconfig \