blob: f61d278d79d4afd1b435954419142713b683d146 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001require recipes-devtools/python/python.inc
2
3DEPENDS = "python3-native libffi bzip2 db gdbm openssl readline sqlite3 zlib virtual/libintl xz"
4PR = "${INC_PR}.0"
5PYTHON_MAJMIN = "3.4"
6PYTHON_BINABI= "${PYTHON_MAJMIN}m"
7DISTRO_SRC_URI ?= "file://sitecustomize.py"
8DISTRO_SRC_URI_linuxstdbase = ""
9SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.xz \
10file://python-config.patch \
11file://000-cross-compile.patch \
12file://020-dont-compile-python-files.patch \
13file://030-fixup-include-dirs.patch \
14file://070-dont-clean-ipkg-install.patch \
15file://080-distutils-dont_adjust_files.patch \
16file://110-enable-zlib.patch \
17file://130-readline-setup.patch \
18file://150-fix-setupterm.patch \
19file://0001-h2py-Fix-issue-13032-where-it-fails-with-UnicodeDeco.patch \
20file://makerace.patch \
21${DISTRO_SRC_URI} \
22"
23
24SRC_URI += "\
25 file://03-fix-tkinter-detection.patch \
26 file://04-default-is-optimized.patch \
27 file://avoid_warning_about_tkinter.patch \
28 file://cgi_py.patch \
29 file://host_include_contamination.patch \
30 file://python-3.3-multilib.patch \
31 file://shutil-follow-symlink-fix.patch \
32 file://sysroot-include-headers.patch \
33 file://unixccompiler.patch \
34 file://avoid-ncursesw-include-path.patch \
35 file://python3-use-CROSSPYTHONPATH-for-PYTHON_FOR_BUILD.patch \
36 file://python3-setup.py-no-host-headers-libs.patch \
37 file://sysconfig.py-add-_PYTHON_PROJECT_SRC.patch \
38 file://setup.py-check-cross_compiling-when-get-FLAGS.patch \
39 file://setup.py-find-libraries-in-staging-dirs.patch \
40 "
41SRC_URI[md5sum] = "7d092d1bba6e17f0d9bd21b49e441dd5"
42SRC_URI[sha256sum] = "b5b3963533768d5fc325a4d7a6bd6f666726002d696f1d399ec06b043ea996b8"
43
44LIC_FILES_CHKSUM = "file://LICENSE;md5=dd98d01d471fac8d8dbdd975229dba03"
45
46S = "${WORKDIR}/Python-${PV}"
47
48inherit autotools multilib_header python3native pkgconfig
49
50CONFIGUREOPTS += " --with-system-ffi "
51
52CACHED_CONFIGUREVARS = "ac_cv_have_chflags=no \
53 ac_cv_have_lchflags=no \
54 ac_cv_have_long_long_format=yes \
55 ac_cv_buggy_getaddrinfo=no \
56 ac_cv_file__dev_ptmx=yes \
57 ac_cv_file__dev_ptc=no \
58"
59# The 3 lines below are copied from the libffi recipe, ctypes ships its own copy of the libffi sources
60#Somehow gcc doesn't set __SOFTFP__ when passing -mfloatabi=softp :(
61TARGET_CC_ARCH_append_armv6 = " -D__SOFTFP__"
62TARGET_CC_ARCH_append_armv7a = " -D__SOFTFP__"
63TARGET_CC_ARCH += "-DNDEBUG -fno-inline"
64EXTRA_OEMAKE += "CROSS_COMPILE=yes"
65EXTRA_OECONF += "CROSSPYTHONPATH=${STAGING_LIBDIR_NATIVE}/python${PYTHON_MAJMIN}/lib-dynload/ --without-ensurepip"
66
67export CROSS_COMPILE = "${TARGET_PREFIX}"
68export _PYTHON_PROJECT_BASE = "${B}"
69export _PYTHON_PROJECT_SRC = "${S}"
70export CCSHARED = "-fPIC"
71
72# Fix ctypes cross compilation
73export CROSSPYTHONPATH = "${B}/build/lib.linux-${TARGET_ARCH}-${PYTHON_MAJMIN}:${S}/Lib:${S}/Lib/plat-linux"
74
75# No ctypes option for python 3
76PYTHONLSBOPTS = ""
77
78do_configure_append() {
79 rm -f ${S}/Makefile.orig
80 autoreconf -Wcross --verbose --install --force --exclude=autopoint ../Python-${PV}/Modules/_ctypes/libffi
81}
82
83do_compile() {
84 # regenerate platform specific files, because they depend on system headers
85 cd ${S}/Lib/plat-linux*
86 include=${STAGING_INCDIR} ${STAGING_BINDIR_NATIVE}/python3-native/python3 \
87 ${S}/Tools/scripts/h2py.py -i '(u_long)' \
88 ${STAGING_INCDIR}/dlfcn.h \
89 ${STAGING_INCDIR}/linux/cdrom.h \
90 ${STAGING_INCDIR}/netinet/in.h \
91 ${STAGING_INCDIR}/sys/types.h
92 sed -e 's,${STAGING_DIR_HOST},,g' -i *.py
93 cd -
94
95
96 # remove any bogus LD_LIBRARY_PATH
97 sed -i -e s,RUNSHARED=.*,RUNSHARED=, Makefile
98
99 if [ ! -f Makefile.orig ]; then
100 install -m 0644 Makefile Makefile.orig
101 fi
102 sed -i -e 's,^CONFIGURE_LDFLAGS=.*,CONFIGURE_LDFLAGS=-L. -L${STAGING_LIBDIR},g' \
103 -e 's,libdir=${libdir},libdir=${STAGING_LIBDIR},g' \
104 -e 's,libexecdir=${libexecdir},libexecdir=${STAGING_DIR_HOST}${libexecdir},g' \
105 -e 's,^LIBDIR=.*,LIBDIR=${STAGING_LIBDIR},g' \
106 -e 's,includedir=${includedir},includedir=${STAGING_INCDIR},g' \
107 -e 's,^INCLUDEDIR=.*,INCLUDE=${STAGING_INCDIR},g' \
108 -e 's,^CONFINCLUDEDIR=.*,CONFINCLUDE=${STAGING_INCDIR},g' \
109 Makefile
110 # save copy of it now, because if we do it in do_install and
111 # then call do_install twice we get Makefile.orig == Makefile.sysroot
112 install -m 0644 Makefile Makefile.sysroot
113
114 oe_runmake HOSTPGEN=${STAGING_BINDIR_NATIVE}/python3-native/pgen \
115 HOSTPYTHON=${STAGING_BINDIR_NATIVE}/python3-native/python3 \
116 STAGING_LIBDIR=${STAGING_LIBDIR} \
117 STAGING_BASELIBDIR=${STAGING_BASELIBDIR} \
118 STAGING_INCDIR=${STAGING_INCDIR} \
119 BUILD_SYS=${BUILD_SYS} HOST_SYS=${HOST_SYS} \
120 LIB=${baselib} \
121 ARCH=${TARGET_ARCH} \
122 OPT="${CFLAGS}" libpython3.so
123
124 oe_runmake HOSTPGEN=${STAGING_BINDIR_NATIVE}/python3-native/pgen \
125 HOSTPYTHON=${STAGING_BINDIR_NATIVE}/python3-native/python3 \
126 STAGING_LIBDIR=${STAGING_LIBDIR} \
127 STAGING_INCDIR=${STAGING_INCDIR} \
128 STAGING_BASELIBDIR=${STAGING_BASELIBDIR} \
129 BUILD_SYS=${BUILD_SYS} HOST_SYS=${HOST_SYS} \
130 LIB=${baselib} \
131 ARCH=${TARGET_ARCH} \
132 OPT="${CFLAGS}"
133}
134
135do_install() {
136 # make install needs the original Makefile, or otherwise the inclues would
137 # go to ${D}${STAGING...}/...
138 install -m 0644 Makefile.orig Makefile
139
140 install -d ${D}${libdir}/pkgconfig
141 install -d ${D}${libdir}/python${PYTHON_MAJMIN}/config
142
143 # rerun the build once again with original makefile this time
144 # run install in a separate step to avoid compile/install race
145 oe_runmake HOSTPGEN=${STAGING_BINDIR_NATIVE}/python3-native/pgen \
146 HOSTPYTHON=${STAGING_BINDIR_NATIVE}/python3-native/python3 \
147 STAGING_LIBDIR=${STAGING_LIBDIR} \
148 STAGING_INCDIR=${STAGING_INCDIR} \
149 STAGING_BASELIBDIR=${STAGING_BASELIBDIR} \
150 BUILD_SYS=${BUILD_SYS} HOST_SYS=${HOST_SYS} \
151 LIB=${baselib} \
152 ARCH=${TARGET_ARCH} \
153 DESTDIR=${D} LIBDIR=${libdir}
154
155 oe_runmake HOSTPGEN=${STAGING_BINDIR_NATIVE}/python3-native/pgen \
156 HOSTPYTHON=${STAGING_BINDIR_NATIVE}/python3-native/python3 \
157 STAGING_LIBDIR=${STAGING_LIBDIR} \
158 STAGING_INCDIR=${STAGING_INCDIR} \
159 STAGING_BASELIBDIR=${STAGING_BASELIBDIR} \
160 BUILD_SYS=${BUILD_SYS} HOST_SYS=${HOST_SYS} \
161 LIB=${baselib} \
162 ARCH=${TARGET_ARCH} \
163 DESTDIR=${D} LIBDIR=${libdir} install
164
165 # avoid conflict with 2to3 from Python 2
166 rm -f ${D}/${bindir}/2to3
167
168 install -m 0644 Makefile.sysroot ${D}/${libdir}/python${PYTHON_MAJMIN}/config/Makefile
169
170 if [ -e ${WORKDIR}/sitecustomize.py ]; then
171 install -m 0644 ${WORKDIR}/sitecustomize.py ${D}/${libdir}/python${PYTHON_MAJMIN}
172 fi
173
174 oe_multilib_header python${PYTHON_BINABI}/pyconfig.h
175}
176
177do_install_append_class-nativesdk () {
178 create_wrapper ${D}${bindir}/python${PYTHON_MAJMIN} TERMINFO_DIRS='${sysconfdir}/terminfo:/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo'
179}
180
181SSTATE_SCAN_FILES += "Makefile"
182PACKAGE_PREPROCESS_FUNCS += "py_package_preprocess"
183
184py_package_preprocess () {
185 # copy back the old Makefile to fix target package
186 install -m 0644 ${B}/Makefile.orig ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config/Makefile
187 # Remove references to buildmachine paths in target Makefile and _sysconfigdata
188 sed -i -e 's:--sysroot=${STAGING_DIR_TARGET}::g' -e s:'--with-libtool-sysroot=${STAGING_DIR_TARGET}'::g \
189 ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config/Makefile \
190 ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata.py
191}
192
193require python-${PYTHON_MAJMIN}-manifest.inc
194
195# manual dependency additions
196RPROVIDES_${PN}-core = "${PN}"
197RRECOMMENDS_${PN}-core = "${PN}-readline"
198RRECOMMENDS_${PN}-crypt = "openssl"
199RRECOMMENDS_${PN}-crypt_class-nativesdk = "nativesdk-openssl"
200
201FILES_${PN}-2to3 += "${bindir}/2to3-${PYTHON_MAJMIN}"
202FILES_${PN}-pydoc += "${bindir}/pydoc${PYTHON_MAJMIN} ${bindir}/pydoc3"
203FILES_${PN}-idle += "${bindir}/idle3 ${bindir}/idle${PYTHON_MAJMIN}"
204
205PACKAGES =+ "${PN}-pyvenv"
206FILES_${PN}-pyvenv += "${bindir}/pyvenv-${PYTHON_MAJMIN} ${bindir}/pyvenv"
207
208# package libpython3
209PACKAGES =+ "libpython3 libpython3-staticdev"
210FILES_libpython3 = "${libdir}/libpython*.so.*"
211FILES_libpython3-staticdev += "${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_BINABI}/libpython${PYTHON_BINABI}.a"
212
213# catch debug extensions (isn't that already in python-core-dbg?)
214FILES_${PN}-dbg += "${libdir}/python${PYTHON_MAJMIN}/lib-dynload/.debug"
215
216# catch all the rest (unsorted)
217PACKAGES += "${PN}-misc"
218RDEPENDS_${PN}-misc += "${PN}-core"
219FILES_${PN}-misc = "${libdir}/python${PYTHON_MAJMIN}"
220
221# catch manpage
222PACKAGES += "${PN}-man"
223FILES_${PN}-man = "${datadir}/man"
224
225BBCLASSEXTEND = "nativesdk"