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