diff options
Diffstat (limited to 'meta/recipes-devtools/python/python3_3.5.4.bb')
-rw-r--r-- | meta/recipes-devtools/python/python3_3.5.4.bb | 308 |
1 files changed, 308 insertions, 0 deletions
diff --git a/meta/recipes-devtools/python/python3_3.5.4.bb b/meta/recipes-devtools/python/python3_3.5.4.bb new file mode 100644 index 0000000000..4c7a22527c --- /dev/null +++ b/meta/recipes-devtools/python/python3_3.5.4.bb | |||
@@ -0,0 +1,308 @@ | |||
1 | require recipes-devtools/python/python.inc | ||
2 | |||
3 | DEPENDS = "python3-native libffi bzip2 gdbm openssl readline sqlite3 zlib virtual/libintl xz" | ||
4 | |||
5 | PR = "${INC_PR}.0" | ||
6 | PYTHON_MAJMIN = "3.5" | ||
7 | PYTHON_BINABI= "${PYTHON_MAJMIN}m" | ||
8 | DISTRO_SRC_URI ?= "file://sitecustomize.py" | ||
9 | DISTRO_SRC_URI_linuxstdbase = "" | ||
10 | SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.xz \ | ||
11 | file://python-config.patch \ | ||
12 | file://0001-cross-compile-support.patch \ | ||
13 | file://030-fixup-include-dirs.patch \ | ||
14 | file://070-dont-clean-ipkg-install.patch \ | ||
15 | file://080-distutils-dont_adjust_files.patch \ | ||
16 | file://130-readline-setup.patch \ | ||
17 | file://150-fix-setupterm.patch \ | ||
18 | file://0001-h2py-Fix-issue-13032-where-it-fails-with-UnicodeDeco.patch \ | ||
19 | file://tweak-MULTIARCH-for-powerpc-linux-gnuspe.patch \ | ||
20 | file://support_SOURCE_DATE_EPOCH_in_py_compile.patch \ | ||
21 | ${DISTRO_SRC_URI} \ | ||
22 | " | ||
23 | |||
24 | SRC_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://sysconfig.py-add-_PYTHON_PROJECT_SRC.patch \ | ||
36 | file://setup.py-check-cross_compiling-when-get-FLAGS.patch \ | ||
37 | file://configure.ac-fix-LIBPL.patch \ | ||
38 | file://0001-Issue-21272-Use-_sysconfigdata.py-to-initialize-dist.patch \ | ||
39 | file://pass-missing-libraries-to-Extension-for-mul.patch \ | ||
40 | " | ||
41 | SRC_URI[md5sum] = "fb2780baa260b4e51cbea814f111f303" | ||
42 | SRC_URI[sha256sum] = "94d93bfabb3b109f8a10365a325f920f9ec98c6e2380bf228f9700a14054c84c" | ||
43 | |||
44 | LIC_FILES_CHKSUM = "file://LICENSE;md5=f741e51de91d4eeea5930b9c3c7fa69d" | ||
45 | |||
46 | # exclude pre-releases for both python 2.x and 3.x | ||
47 | UPSTREAM_CHECK_REGEX = "[Pp]ython-(?P<pver>\d+(\.\d+)+).tar" | ||
48 | |||
49 | S = "${WORKDIR}/Python-${PV}" | ||
50 | |||
51 | inherit autotools multilib_header python3native pkgconfig | ||
52 | |||
53 | CONFIGUREOPTS += " --with-system-ffi " | ||
54 | |||
55 | CACHED_CONFIGUREVARS = "ac_cv_have_chflags=no \ | ||
56 | ac_cv_have_lchflags=no \ | ||
57 | ac_cv_have_long_long_format=yes \ | ||
58 | ac_cv_buggy_getaddrinfo=no \ | ||
59 | ac_cv_file__dev_ptmx=yes \ | ||
60 | ac_cv_file__dev_ptc=no \ | ||
61 | " | ||
62 | |||
63 | TARGET_CC_ARCH += "-DNDEBUG -fno-inline" | ||
64 | SDK_CC_ARCH += "-DNDEBUG -fno-inline" | ||
65 | EXTRA_OEMAKE += "CROSS_COMPILE=yes" | ||
66 | EXTRA_OECONF += "CROSSPYTHONPATH=${STAGING_LIBDIR_NATIVE}/python${PYTHON_MAJMIN}/lib-dynload/ --without-ensurepip" | ||
67 | |||
68 | export CROSS_COMPILE = "${TARGET_PREFIX}" | ||
69 | export _PYTHON_PROJECT_BASE = "${B}" | ||
70 | export _PYTHON_PROJECT_SRC = "${S}" | ||
71 | export CCSHARED = "-fPIC" | ||
72 | |||
73 | # Fix cross compilation of different modules | ||
74 | export CROSSPYTHONPATH = "${STAGING_LIBDIR_NATIVE}/python${PYTHON_MAJMIN}/lib-dynload/:${B}/build/lib.linux-${TARGET_ARCH}-${PYTHON_MAJMIN}:${S}/Lib:${S}/Lib/plat-linux" | ||
75 | |||
76 | # No ctypes option for python 3 | ||
77 | PYTHONLSBOPTS = "" | ||
78 | |||
79 | do_configure_append() { | ||
80 | rm -f ${S}/Makefile.orig | ||
81 | autoreconf -Wcross --verbose --install --force --exclude=autopoint ../Python-${PV}/Modules/_ctypes/libffi | ||
82 | } | ||
83 | |||
84 | do_compile() { | ||
85 | # regenerate platform specific files, because they depend on system headers | ||
86 | cd ${S}/Lib/plat-linux* | ||
87 | include=${STAGING_INCDIR} ${STAGING_BINDIR_NATIVE}/python3-native/python3 \ | ||
88 | ${S}/Tools/scripts/h2py.py -i '(u_long)' \ | ||
89 | ${STAGING_INCDIR}/dlfcn.h \ | ||
90 | ${STAGING_INCDIR}/linux/cdrom.h \ | ||
91 | ${STAGING_INCDIR}/netinet/in.h \ | ||
92 | ${STAGING_INCDIR}/sys/types.h | ||
93 | sed -e 's,${STAGING_DIR_HOST},,g' -i *.py | ||
94 | cd - | ||
95 | |||
96 | |||
97 | # remove any bogus LD_LIBRARY_PATH | ||
98 | sed -i -e s,RUNSHARED=.*,RUNSHARED=, Makefile | ||
99 | |||
100 | if [ ! -f Makefile.orig ]; then | ||
101 | install -m 0644 Makefile Makefile.orig | ||
102 | fi | ||
103 | sed -i -e 's,^CONFIGURE_LDFLAGS=.*,CONFIGURE_LDFLAGS=-L. -L${STAGING_LIBDIR},g' \ | ||
104 | -e 's,libdir=${libdir},libdir=${STAGING_LIBDIR},g' \ | ||
105 | -e 's,libexecdir=${libexecdir},libexecdir=${STAGING_DIR_HOST}${libexecdir},g' \ | ||
106 | -e 's,^LIBDIR=.*,LIBDIR=${STAGING_LIBDIR},g' \ | ||
107 | -e 's,includedir=${includedir},includedir=${STAGING_INCDIR},g' \ | ||
108 | -e 's,^INCLUDEDIR=.*,INCLUDE=${STAGING_INCDIR},g' \ | ||
109 | -e 's,^CONFINCLUDEDIR=.*,CONFINCLUDE=${STAGING_INCDIR},g' \ | ||
110 | Makefile | ||
111 | # save copy of it now, because if we do it in do_install and | ||
112 | # then call do_install twice we get Makefile.orig == Makefile.sysroot | ||
113 | install -m 0644 Makefile Makefile.sysroot | ||
114 | |||
115 | oe_runmake HOSTPGEN=${STAGING_BINDIR_NATIVE}/python3-native/pgen \ | ||
116 | HOSTPYTHON=${STAGING_BINDIR_NATIVE}/python3-native/python3 \ | ||
117 | STAGING_LIBDIR=${STAGING_LIBDIR} \ | ||
118 | STAGING_BASELIBDIR=${STAGING_BASELIBDIR} \ | ||
119 | STAGING_INCDIR=${STAGING_INCDIR} \ | ||
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 | LIB=${baselib} \ | ||
130 | ARCH=${TARGET_ARCH} \ | ||
131 | OPT="${CFLAGS}" | ||
132 | } | ||
133 | |||
134 | do_install() { | ||
135 | # make install needs the original Makefile, or otherwise the inclues would | ||
136 | # go to ${D}${STAGING...}/... | ||
137 | install -m 0644 Makefile.orig Makefile | ||
138 | |||
139 | install -d ${D}${libdir}/pkgconfig | ||
140 | install -d ${D}${libdir}/python${PYTHON_MAJMIN}/config | ||
141 | |||
142 | # rerun the build once again with original makefile this time | ||
143 | # run install in a separate step to avoid compile/install race | ||
144 | oe_runmake HOSTPGEN=${STAGING_BINDIR_NATIVE}/python3-native/pgen \ | ||
145 | HOSTPYTHON=${STAGING_BINDIR_NATIVE}/python3-native/python3 \ | ||
146 | STAGING_LIBDIR=${STAGING_LIBDIR} \ | ||
147 | STAGING_INCDIR=${STAGING_INCDIR} \ | ||
148 | STAGING_BASELIBDIR=${STAGING_BASELIBDIR} \ | ||
149 | LIB=${baselib} \ | ||
150 | ARCH=${TARGET_ARCH} \ | ||
151 | DESTDIR=${D} LIBDIR=${libdir} | ||
152 | |||
153 | oe_runmake HOSTPGEN=${STAGING_BINDIR_NATIVE}/python3-native/pgen \ | ||
154 | HOSTPYTHON=${STAGING_BINDIR_NATIVE}/python3-native/python3 \ | ||
155 | STAGING_LIBDIR=${STAGING_LIBDIR} \ | ||
156 | STAGING_INCDIR=${STAGING_INCDIR} \ | ||
157 | STAGING_BASELIBDIR=${STAGING_BASELIBDIR} \ | ||
158 | LIB=${baselib} \ | ||
159 | ARCH=${TARGET_ARCH} \ | ||
160 | DESTDIR=${D} LIBDIR=${libdir} install | ||
161 | |||
162 | # avoid conflict with 2to3 from Python 2 | ||
163 | rm -f ${D}/${bindir}/2to3 | ||
164 | |||
165 | install -m 0644 Makefile.sysroot ${D}/${libdir}/python${PYTHON_MAJMIN}/config/Makefile | ||
166 | install -m 0644 Makefile.sysroot ${D}/${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_MAJMIN}${PYTHON_ABI}/Makefile | ||
167 | |||
168 | if [ -e ${WORKDIR}/sitecustomize.py ]; then | ||
169 | install -m 0644 ${WORKDIR}/sitecustomize.py ${D}/${libdir}/python${PYTHON_MAJMIN} | ||
170 | fi | ||
171 | |||
172 | oe_multilib_header python${PYTHON_BINABI}/pyconfig.h | ||
173 | } | ||
174 | |||
175 | do_install_append_class-nativesdk () { | ||
176 | create_wrapper ${D}${bindir}/python${PYTHON_MAJMIN} TERMINFO_DIRS='${sysconfdir}/terminfo:/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo' | ||
177 | } | ||
178 | |||
179 | SSTATE_SCAN_FILES += "Makefile" | ||
180 | PACKAGE_PREPROCESS_FUNCS += "py_package_preprocess" | ||
181 | |||
182 | py_package_preprocess () { | ||
183 | # copy back the old Makefile to fix target package | ||
184 | install -m 0644 ${B}/Makefile.orig ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config/Makefile | ||
185 | install -m 0644 ${B}/Makefile.orig ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_MAJMIN}${PYTHON_ABI}/Makefile | ||
186 | # Remove references to buildmachine paths in target Makefile and _sysconfigdata | ||
187 | sed -i -e 's:--sysroot=${STAGING_DIR_TARGET}::g' -e s:'--with-libtool-sysroot=${STAGING_DIR_TARGET}'::g \ | ||
188 | -e 's|${DEBUG_PREFIX_MAP}||g' \ | ||
189 | -e 's:${HOSTTOOLS_DIR}/::g' \ | ||
190 | -e 's:${RECIPE_SYSROOT_NATIVE}::g' \ | ||
191 | -e 's:${RECIPE_SYSROOT}::g' \ | ||
192 | -e 's:${BASE_WORKDIR}/${MULTIMACH_TARGET_SYS}::g' \ | ||
193 | ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config/Makefile \ | ||
194 | ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_MAJMIN}${PYTHON_ABI}/Makefile \ | ||
195 | ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata.py | ||
196 | } | ||
197 | |||
198 | # manual dependency additions | ||
199 | RPROVIDES_${PN}-modules = "${PN}" | ||
200 | RRECOMMENDS_${PN}-crypt = "openssl" | ||
201 | RRECOMMENDS_${PN}-crypt_class-nativesdk = "nativesdk-openssl" | ||
202 | |||
203 | FILES_${PN}-2to3 += "${bindir}/2to3-${PYTHON_MAJMIN}" | ||
204 | FILES_${PN}-pydoc += "${bindir}/pydoc${PYTHON_MAJMIN} ${bindir}/pydoc3" | ||
205 | FILES_${PN}-idle += "${bindir}/idle3 ${bindir}/idle${PYTHON_MAJMIN}" | ||
206 | |||
207 | PACKAGES =+ "${PN}-pyvenv" | ||
208 | FILES_${PN}-pyvenv += "${bindir}/pyvenv-${PYTHON_MAJMIN} ${bindir}/pyvenv" | ||
209 | |||
210 | # package libpython3 | ||
211 | PACKAGES =+ "libpython3 libpython3-staticdev" | ||
212 | FILES_libpython3 = "${libdir}/libpython*.so.*" | ||
213 | FILES_libpython3-staticdev += "${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_BINABI}/libpython${PYTHON_BINABI}.a" | ||
214 | INSANE_SKIP_${PN}-dev += "dev-elf" | ||
215 | |||
216 | # catch all the rest (unsorted) | ||
217 | PACKAGES += "${PN}-misc" | ||
218 | RDEPENDS_${PN}-misc += "${PN}-core ${PN}-email ${PN}-codecs" | ||
219 | RDEPENDS_${PN}-modules += "${PN}-misc" | ||
220 | FILES_${PN}-misc = "${libdir}/python${PYTHON_MAJMIN}" | ||
221 | |||
222 | # catch manpage | ||
223 | PACKAGES += "${PN}-man" | ||
224 | FILES_${PN}-man = "${datadir}/man" | ||
225 | |||
226 | BBCLASSEXTEND = "nativesdk" | ||
227 | |||
228 | RPROVIDES_${PN} += "${PN}-modules" | ||
229 | |||
230 | # We want bytecode precompiled .py files (.pyc's) by default | ||
231 | # but the user may set it on their own conf | ||
232 | INCLUDE_PYCS ?= "1" | ||
233 | |||
234 | python(){ | ||
235 | import json | ||
236 | |||
237 | filename = os.path.join(d.getVar('THISDIR'), 'python3', 'python3-manifest.json') | ||
238 | # This python changes the datastore based on the contents of a file, so mark | ||
239 | # that dependency. | ||
240 | bb.parse.mark_dependency(d, filename) | ||
241 | |||
242 | with open(filename) as manifest_file: | ||
243 | python_manifest=json.load(manifest_file) | ||
244 | |||
245 | include_pycs = d.getVar('INCLUDE_PYCS') | ||
246 | |||
247 | packages = d.getVar('PACKAGES').split() | ||
248 | pn = d.getVar('PN') | ||
249 | |||
250 | newpackages=[] | ||
251 | for key in python_manifest: | ||
252 | pypackage= pn + '-' + key | ||
253 | |||
254 | if pypackage not in packages: | ||
255 | # We need to prepend, otherwise python-misc gets everything | ||
256 | # so we use a new variable | ||
257 | newpackages.append(pypackage) | ||
258 | |||
259 | # "Build" python's manifest FILES, RDEPENDS and SUMMARY | ||
260 | d.setVar('FILES_' + pypackage, '') | ||
261 | for value in python_manifest[key]['files']: | ||
262 | d.appendVar('FILES_' + pypackage, ' ' + value) | ||
263 | |||
264 | # Add cached files | ||
265 | if include_pycs == '1': | ||
266 | for value in python_manifest[key]['cached']: | ||
267 | d.appendVar('FILES_' + pypackage, ' ' + value) | ||
268 | |||
269 | d.setVar('RDEPENDS_' + pypackage, '') | ||
270 | for value in python_manifest[key]['rdepends']: | ||
271 | # Make it work with or without $PN | ||
272 | if '${PN}' in value: | ||
273 | value=value.split('-')[1] | ||
274 | d.appendVar('RDEPENDS_' + pypackage, ' ' + pn + '-' + value) | ||
275 | d.setVar('SUMMARY_' + pypackage, python_manifest[key]['summary']) | ||
276 | |||
277 | # We need to ensure staticdev packages match for files first so we sort in reverse | ||
278 | newpackages.sort(reverse=True) | ||
279 | # Prepending so to avoid python-misc getting everything | ||
280 | packages = newpackages + packages | ||
281 | d.setVar('PACKAGES', ' '.join(packages)) | ||
282 | d.setVar('ALLOW_EMPTY_${PN}-modules', '1') | ||
283 | } | ||
284 | |||
285 | # Files needed to create a new manifest | ||
286 | SRC_URI += "file://create_manifest3.py file://get_module_deps3.py file://python3-manifest.json" | ||
287 | |||
288 | do_create_manifest() { | ||
289 | # This task should be run with every new release of Python. | ||
290 | # We must ensure that PACKAGECONFIG enables everything when creating | ||
291 | # a new manifest, this is to base our new manifest on a complete | ||
292 | # native python build, containing all dependencies, otherwise the task | ||
293 | # wont be able to find the required files. | ||
294 | # e.g. BerkeleyDB is an optional build dependency so it may or may not | ||
295 | # be present, we must ensure it is. | ||
296 | |||
297 | cd ${WORKDIR} | ||
298 | # This needs to be executed by python-native and NOT by HOST's python | ||
299 | nativepython3 create_manifest3.py | ||
300 | cp python3-manifest.json.new ${THISDIR}/python3/python3-manifest.json | ||
301 | } | ||
302 | |||
303 | # bitbake python -c create_manifest | ||
304 | addtask do_create_manifest | ||
305 | |||
306 | # Make sure we have native python ready when we create a new manifest | ||
307 | do_create_manifest[depends] += "python3:do_prepare_recipe_sysroot" | ||
308 | do_create_manifest[depends] += "python3:do_patch" | ||