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