diff options
Diffstat (limited to 'meta/recipes-devtools/python/python3_3.7.2.bb')
-rw-r--r-- | meta/recipes-devtools/python/python3_3.7.2.bb | 287 |
1 files changed, 287 insertions, 0 deletions
diff --git a/meta/recipes-devtools/python/python3_3.7.2.bb b/meta/recipes-devtools/python/python3_3.7.2.bb new file mode 100644 index 0000000000..e05ab42b0c --- /dev/null +++ b/meta/recipes-devtools/python/python3_3.7.2.bb | |||
@@ -0,0 +1,287 @@ | |||
1 | SUMMARY = "The Python Programming Language" | ||
2 | HOMEPAGE = "http://www.python.org" | ||
3 | LICENSE = "PSFv2" | ||
4 | SECTION = "devel/python" | ||
5 | |||
6 | LIC_FILES_CHKSUM = "file://LICENSE;md5=f257cc14f81685691652a3d3e1b5d754" | ||
7 | |||
8 | SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.xz \ | ||
9 | file://run-ptest \ | ||
10 | file://create_manifest3.py \ | ||
11 | file://get_module_deps3.py \ | ||
12 | file://python3-manifest.json \ | ||
13 | file://check_build_completeness.py \ | ||
14 | file://cgi_py.patch \ | ||
15 | file://0001-Do-not-add-usr-lib-termcap-to-linker-flags-to-avoid-.patch \ | ||
16 | ${@bb.utils.contains('PACKAGECONFIG', 'tk', '', 'file://avoid_warning_about_tkinter.patch', d)} \ | ||
17 | file://0001-Do-not-use-the-shell-version-of-python-config-that-w.patch \ | ||
18 | file://python-config.patch \ | ||
19 | file://0001-Makefile.pre-use-qemu-wrapper-when-gathering-profile.patch \ | ||
20 | file://0001-Do-not-hardcode-lib-as-location-for-site-packages-an.patch \ | ||
21 | file://0001-python3-use-cc_basename-to-replace-CC-for-checking-c.patch \ | ||
22 | file://0002-Don-t-do-runtime-test-to-get-float-byte-order.patch \ | ||
23 | file://0003-setup.py-pass-missing-libraries-to-Extension-for-mul.patch \ | ||
24 | " | ||
25 | |||
26 | SRC_URI_append_class-native = " \ | ||
27 | file://0001-distutils-sysconfig-append-STAGING_LIBDIR-python-sys.patch \ | ||
28 | file://12-distutils-prefix-is-inside-staging-area.patch \ | ||
29 | " | ||
30 | |||
31 | SRC_URI[md5sum] = "df6ec36011808205beda239c72f947cb" | ||
32 | SRC_URI[sha256sum] = "d83fe8ce51b1bb48bbcf0550fd265b9a75cdfdfa93f916f9e700aef8444bf1bb" | ||
33 | |||
34 | # exclude pre-releases for both python 2.x and 3.x | ||
35 | UPSTREAM_CHECK_REGEX = "[Pp]ython-(?P<pver>\d+(\.\d+)+).tar" | ||
36 | |||
37 | CVE_PRODUCT = "python" | ||
38 | |||
39 | PYTHON_MAJMIN = "3.7" | ||
40 | PYTHON_BINABI = "${PYTHON_MAJMIN}m" | ||
41 | |||
42 | S = "${WORKDIR}/Python-${PV}" | ||
43 | |||
44 | BBCLASSEXTEND = "native nativesdk" | ||
45 | |||
46 | inherit autotools pkgconfig qemu ptest multilib_header update-alternatives | ||
47 | |||
48 | MULTILIB_SUFFIX = "${@d.getVar('base_libdir',1).split('/')[-1]}" | ||
49 | |||
50 | ALTERNATIVE_${PN}-dev = "python-config" | ||
51 | ALTERNATIVE_LINK_NAME[python-config] = "${bindir}/python${PYTHON_BINABI}-config" | ||
52 | ALTERNATIVE_TARGET[python-config] = "${bindir}/python${PYTHON_BINABI}-config-${MULTILIB_SUFFIX}" | ||
53 | |||
54 | |||
55 | DEPENDS = "bzip2-replacement-native libffi bzip2 gdbm openssl sqlite3 zlib virtual/libintl xz virtual/crypt util-linux libtirpc libnsl2" | ||
56 | DEPENDS_append_class-target = " python3-native" | ||
57 | DEPENDS_append_class-nativesdk = " python3-native" | ||
58 | |||
59 | EXTRA_OECONF = " --without-ensurepip --enable-shared" | ||
60 | EXTRA_OECONF_append_class-native = " --bindir=${bindir}/${PN}" | ||
61 | |||
62 | |||
63 | EXTRANATIVEPATH += "python3-native" | ||
64 | |||
65 | CACHED_CONFIGUREVARS = " \ | ||
66 | ac_cv_file__dev_ptmx=yes \ | ||
67 | ac_cv_file__dev_ptc=no \ | ||
68 | " | ||
69 | |||
70 | PACKAGECONFIG_class-target ??= "readline ${@bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', 'pgo', '', d)}" | ||
71 | PACKAGECONFIG_class-native ??= "readline" | ||
72 | PACKAGECONFIG_class-nativesdk ??= "readline" | ||
73 | PACKAGECONFIG[readline] = ",,readline" | ||
74 | # Use profile guided optimisation by running PyBench inside qemu-user | ||
75 | PACKAGECONFIG[pgo] = "--enable-optimizations,,qemu-helper-native" | ||
76 | PACKAGECONFIG[tk] = ",,tk" | ||
77 | |||
78 | CPPFLAGS_append = " -I${STAGING_INCDIR}/ncursesw -I${STAGING_INCDIR}/uuid" | ||
79 | |||
80 | EXTRA_OEMAKE = '\ | ||
81 | STAGING_LIBDIR=${STAGING_LIBDIR} \ | ||
82 | STAGING_INCDIR=${STAGING_INCDIR} \ | ||
83 | LIB=${baselib} \ | ||
84 | ' | ||
85 | |||
86 | do_compile_prepend_class-target() { | ||
87 | if ${@bb.utils.contains('PACKAGECONFIG', 'pgo', 'true', 'false', d)}; then | ||
88 | qemu_binary="${@qemu_wrapper_cmdline(d, '${STAGING_DIR_TARGET}', ['${B}', '${STAGING_DIR_TARGET}/${base_libdir}'])}" | ||
89 | cat >pgo-wrapper <<EOF | ||
90 | #!/bin/sh | ||
91 | cd ${B} | ||
92 | $qemu_binary "\$@" | ||
93 | EOF | ||
94 | chmod +x pgo-wrapper | ||
95 | fi | ||
96 | } | ||
97 | |||
98 | do_install_prepend() { | ||
99 | ${WORKDIR}/check_build_completeness.py ${T}/log.do_compile | ||
100 | } | ||
101 | |||
102 | do_install_append_class-target() { | ||
103 | oe_multilib_header python${PYTHON_BINABI}/pyconfig.h | ||
104 | } | ||
105 | |||
106 | do_install_append_class-native() { | ||
107 | # Make sure we use /usr/bin/env python | ||
108 | for PYTHSCRIPT in `grep -rIl ${bindir}/${PN}/python ${D}${bindir}/${PN}`; do | ||
109 | sed -i -e '1s|^#!.*|#!/usr/bin/env python3|' $PYTHSCRIPT | ||
110 | done | ||
111 | # Add a symlink to the native Python so that scripts can just invoke | ||
112 | # "nativepython" and get the right one without needing absolute paths | ||
113 | # (these often end up too long for the #! parser in the kernel as the | ||
114 | # buffer is 128 bytes long). | ||
115 | ln -s python3-native/python3 ${D}${bindir}/nativepython3 | ||
116 | } | ||
117 | |||
118 | do_install_append() { | ||
119 | mkdir -p ${D}${libdir}/python-sysconfigdata | ||
120 | sysconfigfile=`find ${D} -name _sysconfig*.py` | ||
121 | cp $sysconfigfile ${D}${libdir}/python-sysconfigdata/_sysconfigdata.py | ||
122 | |||
123 | sed -i \ | ||
124 | -e "s,^ 'LIBDIR'.*, 'LIBDIR': '${STAGING_LIBDIR}'\,,g" \ | ||
125 | -e "s,^ 'INCLUDEDIR'.*, 'INCLUDEDIR': '${STAGING_INCDIR}'\,,g" \ | ||
126 | -e "s,^ 'CONFINCLUDEDIR'.*, 'CONFINCLUDEDIR': '${STAGING_INCDIR}'\,,g" \ | ||
127 | ${D}${libdir}/python-sysconfigdata/_sysconfigdata.py | ||
128 | } | ||
129 | |||
130 | SSTATE_SCAN_FILES += "Makefile _sysconfigdata.py" | ||
131 | PACKAGE_PREPROCESS_FUNCS += "py_package_preprocess" | ||
132 | |||
133 | py_package_preprocess () { | ||
134 | # Remove references to buildmachine paths in target Makefile and _sysconfigdata | ||
135 | sed -i -e 's:--sysroot=${STAGING_DIR_TARGET}::g' -e s:'--with-libtool-sysroot=${STAGING_DIR_TARGET}'::g \ | ||
136 | -e 's|${DEBUG_PREFIX_MAP}||g' \ | ||
137 | -e 's:${HOSTTOOLS_DIR}/::g' \ | ||
138 | -e 's:${RECIPE_SYSROOT_NATIVE}::g' \ | ||
139 | -e 's:${RECIPE_SYSROOT}::g' \ | ||
140 | -e 's:${BASE_WORKDIR}/${MULTIMACH_TARGET_SYS}::g' \ | ||
141 | ${PKGD}/${prefix}/lib/python${PYTHON_MAJMIN}/config-${PYTHON_MAJMIN}${PYTHON_ABI}*/Makefile \ | ||
142 | ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata*.py \ | ||
143 | ${PKGD}/${bindir}/python${PYTHON_BINABI}-config | ||
144 | |||
145 | # Recompile _sysconfigdata after modifying it | ||
146 | cd ${PKGD} | ||
147 | sysconfigfile=`find . -name _sysconfigdata_*.py` | ||
148 | ${STAGING_BINDIR_NATIVE}/python3-native/python3 \ | ||
149 | -c "from py_compile import compile; compile('$sysconfigfile')" | ||
150 | ${STAGING_BINDIR_NATIVE}/python3-native/python3 \ | ||
151 | -c "from py_compile import compile; compile('$sysconfigfile', optimize=1)" | ||
152 | ${STAGING_BINDIR_NATIVE}/python3-native/python3 \ | ||
153 | -c "from py_compile import compile; compile('$sysconfigfile', optimize=2)" | ||
154 | cd - | ||
155 | |||
156 | mv ${PKGD}/${bindir}/python${PYTHON_BINABI}-config ${PKGD}/${bindir}/python${PYTHON_BINABI}-config-${MULTILIB_SUFFIX} | ||
157 | |||
158 | #Remove the unneeded copy of target sysconfig data | ||
159 | rm -rf ${PKGD}/${libdir}/python-sysconfigdata | ||
160 | } | ||
161 | |||
162 | # We want bytecode precompiled .py files (.pyc's) by default | ||
163 | # but the user may set it on their own conf | ||
164 | INCLUDE_PYCS ?= "1" | ||
165 | |||
166 | python(){ | ||
167 | import collections, json | ||
168 | |||
169 | filename = os.path.join(d.getVar('THISDIR'), 'python3', 'python3-manifest.json') | ||
170 | # This python changes the datastore based on the contents of a file, so mark | ||
171 | # that dependency. | ||
172 | bb.parse.mark_dependency(d, filename) | ||
173 | |||
174 | with open(filename) as manifest_file: | ||
175 | manifest_str = manifest_file.read() | ||
176 | json_start = manifest_str.find('# EOC') + 6 | ||
177 | manifest_file.seek(json_start) | ||
178 | manifest_str = manifest_file.read() | ||
179 | python_manifest = json.loads(manifest_str, object_pairs_hook=collections.OrderedDict) | ||
180 | |||
181 | # First set RPROVIDES for -native case | ||
182 | # Hardcoded since it cant be python3-native-foo, should be python3-foo-native | ||
183 | pn = 'python3' | ||
184 | rprovides = d.getVar('RPROVIDES').split() | ||
185 | |||
186 | for key in python_manifest: | ||
187 | pypackage = pn + '-' + key + '-native' | ||
188 | if pypackage not in rprovides: | ||
189 | rprovides.append(pypackage) | ||
190 | |||
191 | d.setVar('RPROVIDES_class-native', ' '.join(rprovides)) | ||
192 | |||
193 | # Then work on the target | ||
194 | include_pycs = d.getVar('INCLUDE_PYCS') | ||
195 | |||
196 | packages = d.getVar('PACKAGES').split() | ||
197 | pn = d.getVar('PN') | ||
198 | |||
199 | newpackages=[] | ||
200 | for key in python_manifest: | ||
201 | pypackage= pn + '-' + key | ||
202 | |||
203 | if pypackage not in packages: | ||
204 | # We need to prepend, otherwise python-misc gets everything | ||
205 | # so we use a new variable | ||
206 | newpackages.append(pypackage) | ||
207 | |||
208 | # "Build" python's manifest FILES, RDEPENDS and SUMMARY | ||
209 | d.setVar('FILES_' + pypackage, '') | ||
210 | for value in python_manifest[key]['files']: | ||
211 | d.appendVar('FILES_' + pypackage, ' ' + value) | ||
212 | |||
213 | # Add cached files | ||
214 | if include_pycs == '1': | ||
215 | for value in python_manifest[key]['cached']: | ||
216 | d.appendVar('FILES_' + pypackage, ' ' + value) | ||
217 | |||
218 | for value in python_manifest[key]['rdepends']: | ||
219 | # Make it work with or without $PN | ||
220 | if '${PN}' in value: | ||
221 | value=value.split('-')[1] | ||
222 | d.appendVar('RDEPENDS_' + pypackage, ' ' + pn + '-' + value) | ||
223 | d.setVar('SUMMARY_' + pypackage, python_manifest[key]['summary']) | ||
224 | |||
225 | # Prepending so to avoid python-misc getting everything | ||
226 | packages = newpackages + packages | ||
227 | d.setVar('PACKAGES', ' '.join(packages)) | ||
228 | d.setVar('ALLOW_EMPTY_${PN}-modules', '1') | ||
229 | } | ||
230 | |||
231 | # Files needed to create a new manifest | ||
232 | |||
233 | do_create_manifest() { | ||
234 | # This task should be run with every new release of Python. | ||
235 | # We must ensure that PACKAGECONFIG enables everything when creating | ||
236 | # a new manifest, this is to base our new manifest on a complete | ||
237 | # native python build, containing all dependencies, otherwise the task | ||
238 | # wont be able to find the required files. | ||
239 | # e.g. BerkeleyDB is an optional build dependency so it may or may not | ||
240 | # be present, we must ensure it is. | ||
241 | |||
242 | cd ${WORKDIR} | ||
243 | # This needs to be executed by python-native and NOT by HOST's python | ||
244 | nativepython3 create_manifest3.py ${PYTHON_MAJMIN} | ||
245 | cp python3-manifest.json.new ${THISDIR}/python3/python3-manifest.json | ||
246 | } | ||
247 | |||
248 | # bitbake python -c create_manifest | ||
249 | addtask do_create_manifest | ||
250 | |||
251 | # Make sure we have native python ready when we create a new manifest | ||
252 | do_create_manifest[depends] += "${PN}:do_prepare_recipe_sysroot" | ||
253 | do_create_manifest[depends] += "${PN}:do_patch" | ||
254 | |||
255 | # manual dependency additions | ||
256 | RPROVIDES_${PN}-modules = "${PN}" | ||
257 | RRECOMMENDS_${PN}-core_append_class-nativesdk = " nativesdk-python3-modules" | ||
258 | RRECOMMENDS_${PN}-crypt_append_class-target = " openssl ca-certificates" | ||
259 | RRECOMMENDS_${PN}-crypt_append_class-nativesdk = " openssl ca-certificates" | ||
260 | |||
261 | FILES_${PN}-pydoc += "${bindir}/pydoc${PYTHON_MAJMIN} ${bindir}/pydoc3" | ||
262 | FILES_${PN}-idle += "${bindir}/idle3 ${bindir}/idle${PYTHON_MAJMIN}" | ||
263 | |||
264 | # provide python-pyvenv from python3-venv | ||
265 | RPROVIDES_${PN}-venv += "python3-pyvenv" | ||
266 | |||
267 | # package libpython3 | ||
268 | PACKAGES =+ "libpython3 libpython3-staticdev" | ||
269 | FILES_libpython3 = "${libdir}/libpython*.so.*" | ||
270 | FILES_libpython3-staticdev += "${prefix}/lib/python${PYTHON_MAJMIN}/config-${PYTHON_BINABI}-*/libpython${PYTHON_BINABI}.a" | ||
271 | INSANE_SKIP_${PN}-dev += "dev-elf" | ||
272 | |||
273 | # catch all the rest (unsorted) | ||
274 | PACKAGES += "${PN}-misc" | ||
275 | RDEPENDS_${PN}-misc += "python3-core python3-email python3-codecs" | ||
276 | RDEPENDS_${PN}-modules_append_class-target = " python3-misc" | ||
277 | RDEPENDS_${PN}-modules_append_class-nativesdk = " python3-misc" | ||
278 | FILES_${PN}-misc = "${libdir}/python${PYTHON_MAJMIN} ${libdir}/python${PYTHON_MAJMIN}/lib-dynload" | ||
279 | |||
280 | # catch manpage | ||
281 | PACKAGES += "${PN}-man" | ||
282 | FILES_${PN}-man = "${datadir}/man" | ||
283 | |||
284 | RDEPENDS_${PN}-ptest = "${PN}-modules ${PN}-tests unzip bzip2" | ||
285 | RDEPENDS_${PN}-tkinter += "${@bb.utils.contains('PACKAGECONFIG', 'tk', 'tk', '', d)}" | ||
286 | RDEPENDS_${PN}-dev = "" | ||
287 | |||