blob: c7bc4f3b0afc4f1c0243469b2b25a8fd52da6c2f [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001require recipes-devtools/python/python3.inc
2
3DISTRO_SRC_URI ?= "file://sitecustomize.py"
4DISTRO_SRC_URI_linuxstdbase = ""
5SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.xz \
6file://12-distutils-prefix-is-inside-staging-area.patch \
7file://python-config.patch \
8file://030-fixup-include-dirs.patch \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08009file://080-distutils-dont_adjust_files.patch \
10file://130-readline-setup.patch \
11file://150-fix-setupterm.patch \
12file://python-3.3-multilib.patch \
13file://03-fix-tkinter-detection.patch \
14file://avoid_warning_about_tkinter.patch \
15file://0001-h2py-Fix-issue-13032-where-it-fails-with-UnicodeDeco.patch \
16file://sysroot-include-headers.patch \
17file://unixccompiler.patch \
18${DISTRO_SRC_URI} \
19file://sysconfig.py-add-_PYTHON_PROJECT_SRC.patch \
20file://setup.py-check-cross_compiling-when-get-FLAGS.patch \
21file://0001-Do-not-use-the-shell-version-of-python-config-that-w.patch \
22file://support_SOURCE_DATE_EPOCH_in_py_compile.patch \
23file://regen-all.patch \
24file://0001-Issue-28043-SSLContext-has-improved-default-settings.patch \
25file://0002-bpo-29136-Add-TLS-1.3-cipher-suites-and-OP_NO_TLSv1_.patch \
26file://0003-bpo-32947-Fixes-for-TLS-1.3-and-OpenSSL-1.1.1-GH-876.patch \
27file://0004-bpo-33570-TLS-1.3-ciphers-for-OpenSSL-1.1.1-GH-6976.patch \
28file://0005-bpo-30714-ALPN-changes-for-OpenSSL-1.1.0f-2305.patch \
29"
30
31EXTRANATIVEPATH += "bzip2-native"
32DEPENDS = "openssl-native bzip2-replacement-native zlib-native readline-native sqlite3-native gdbm-native"
33
34inherit native
35
36EXTRA_OECONF_append = " --bindir=${bindir}/${PN} --without-ensurepip"
37
38EXTRA_OEMAKE = '\
39 LIBC="" \
40 STAGING_LIBDIR=${STAGING_LIBDIR_NATIVE} \
41 STAGING_INCDIR=${STAGING_INCDIR_NATIVE} \
42 LIB=${baselib} \
43 ARCH=${TARGET_ARCH} \
44'
45
46do_configure_append() {
47 autoreconf --verbose --install --force --exclude=autopoint ../Python-${PV}/Modules/_ctypes/libffi
48 sed -i -e 's,#define HAVE_GETRANDOM 1,/\* #undef HAVE_GETRANDOM \*/,' ${B}/pyconfig.h
49}
50
51# Regenerate all of the generated files
52# This ensures that pgen and friends get created during the compile phase
53#
54do_compile_prepend() {
55 # Assuming https://bugs.python.org/issue33080 has been addressed in Makefile.
56 oe_runmake regen-all
57}
58
59do_install() {
60 install -d ${D}${libdir}/pkgconfig
61 oe_runmake 'DESTDIR=${D}' install
62 if [ -e ${WORKDIR}/sitecustomize.py ]; then
63 install -m 0644 ${WORKDIR}/sitecustomize.py ${D}/${libdir}/python${PYTHON_MAJMIN}
64 fi
65 install -d ${D}${bindir}/${PN}
66 install -m 0755 Parser/pgen ${D}${bindir}/${PN}
67
68 # Make sure we use /usr/bin/env python
69 for PYTHSCRIPT in `grep -rIl ${bindir}/${PN}/python ${D}${bindir}/${PN}`; do
70 sed -i -e '1s|^#!.*|#!/usr/bin/env python3|' $PYTHSCRIPT
71 done
72
73 # Add a symlink to the native Python so that scripts can just invoke
74 # "nativepython" and get the right one without needing absolute paths
75 # (these often end up too long for the #! parser in the kernel as the
76 # buffer is 128 bytes long).
77 ln -s python3-native/python3 ${D}${bindir}/nativepython3
78}
79
80python(){
81
82 # Read JSON manifest
83 import json
Brad Bishop977dc1a2019-02-06 16:01:43 -050084 pythondir = d.getVar('THISDIR')
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080085 with open(pythondir+'/python3/python3-manifest.json') as manifest_file:
86 python_manifest=json.load(manifest_file)
87
88 rprovides = d.getVar('RPROVIDES').split()
89
90 # Hardcoded since it cant be python3-native-foo, should be python3-foo-native
91 pn = 'python3'
92
93 for key in python_manifest:
94 pypackage = pn + '-' + key + '-native'
95 if pypackage not in rprovides:
96 rprovides.append(pypackage)
97
98 d.setVar('RPROVIDES', ' '.join(rprovides))
99}