blob: 90103af8be51ac2ec2bd8f569668ad02979bfc4c [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001require python.inc
2EXTRANATIVEPATH += "bzip2-native"
3DEPENDS = "openssl-native bzip2-replacement-native zlib-native readline-native sqlite3-native expat-native gdbm-native db-native"
4
5SRC_URI += "\
6 file://05-enable-ctypes-cross-build.patch \
7 file://10-distutils-fix-swig-parameter.patch \
8 file://11-distutils-never-modify-shebang-line.patch \
9 file://0001-distutils-set-the-prefix-to-be-inside-staging-direct.patch \
Brad Bishopc342db32019-05-15 21:57:59 -040010 file://unixccompiler.patch \
11 file://nohostlibs.patch \
12 file://multilib.patch \
13 file://add-md5module-support.patch \
14 file://builddir.patch \
15 file://parallel-makeinst-create-bindir.patch \
16 file://revert_use_of_sysconfigdata.patch \
17 file://0001-python-native-fix-one-do_populate_sysroot-warning.patch \
18 "
19
20S = "${WORKDIR}/Python-${PV}"
21
22FILESEXTRAPATHS =. "${FILE_DIRNAME}/${PN}:"
23
24inherit native
25
26EXTRA_OECONF_append = " --bindir=${bindir}/${PN} --with-system-expat=${STAGING_DIR_HOST}"
27
28EXTRA_OEMAKE = '\
29 LIBC="" \
30 STAGING_LIBDIR=${STAGING_LIBDIR_NATIVE} \
31 STAGING_INCDIR=${STAGING_INCDIR_NATIVE} \
32'
33
34do_configure_append() {
35 autoreconf --verbose --install --force --exclude=autopoint ../Python-${PV}/Modules/_ctypes/libffi
36}
37
38# Regenerate all of the generated files
39# This ensures that pgen and friends get created during the compile phase
40do_compile_prepend() {
41 oe_runmake regen-all
42}
43
44do_install() {
45 oe_runmake 'DESTDIR=${D}' install
46 install -d ${D}${bindir}/${PN}
47 install -m 0755 Parser/pgen ${D}${bindir}/${PN}
48
49 # Make sure we use /usr/bin/env python
50 for PYTHSCRIPT in `grep -rIl ${bindir}/${PN}/python ${D}${bindir}/${PN}`; do
51 sed -i -e '1s|^#!.*|#!/usr/bin/env python|' $PYTHSCRIPT
52 done
53
54 # Add a symlink to the native Python so that scripts can just invoke
55 # "nativepython" and get the right one without needing absolute paths
56 # (these often end up too long for the #! parser in the kernel as the
57 # buffer is 128 bytes long).
58 ln -s python-native/python ${D}${bindir}/nativepython
59
60 # We don't want modules in ~/.local being used in preference to those
61 # installed in the native sysroot, so disable user site support.
62 sed -i -e 's,^\(ENABLE_USER_SITE = \).*,\1False,' ${D}${libdir}/python${PYTHON_MAJMIN}/site.py
63}
64
65python(){
66
67 # Read JSON manifest
68 import json
69 pythondir = d.getVar('THISDIR')
70 with open(pythondir+'/python/python2-manifest.json') as manifest_file:
71 manifest_str = manifest_file.read()
72 json_start = manifest_str.find('# EOC') + 6
73 manifest_file.seek(json_start)
74 manifest_str = manifest_file.read()
75 python_manifest = json.loads(manifest_str)
76
77 rprovides = d.getVar('RPROVIDES').split()
78
79 # Hardcoded since it cant be python-native-foo, should be python-foo-native
80 pn = 'python'
81
82 for key in python_manifest:
83 pypackage = pn + '-' + key + '-native'
84 if pypackage not in rprovides:
85 rprovides.append(pypackage)
86
87 d.setVar('RPROVIDES', ' '.join(rprovides))
88}