Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | require recipes-devtools/python/python.inc |
| 2 | |
| 3 | DEPENDS = "python3-native libffi bzip2 db gdbm openssl readline sqlite3 zlib virtual/libintl xz" |
| 4 | PR = "${INC_PR}.0" |
| 5 | PYTHON_MAJMIN = "3.4" |
| 6 | PYTHON_BINABI= "${PYTHON_MAJMIN}m" |
| 7 | DISTRO_SRC_URI ?= "file://sitecustomize.py" |
| 8 | DISTRO_SRC_URI_linuxstdbase = "" |
| 9 | SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.xz \ |
| 10 | file://python-config.patch \ |
| 11 | file://000-cross-compile.patch \ |
| 12 | file://020-dont-compile-python-files.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://110-enable-zlib.patch \ |
| 17 | file://130-readline-setup.patch \ |
| 18 | file://150-fix-setupterm.patch \ |
| 19 | file://0001-h2py-Fix-issue-13032-where-it-fails-with-UnicodeDeco.patch \ |
| 20 | file://makerace.patch \ |
| 21 | ${DISTRO_SRC_URI} \ |
| 22 | " |
| 23 | |
| 24 | SRC_URI += "\ |
| 25 | file://03-fix-tkinter-detection.patch \ |
| 26 | file://04-default-is-optimized.patch \ |
| 27 | file://avoid_warning_about_tkinter.patch \ |
| 28 | file://cgi_py.patch \ |
| 29 | file://host_include_contamination.patch \ |
| 30 | file://python-3.3-multilib.patch \ |
| 31 | file://shutil-follow-symlink-fix.patch \ |
| 32 | file://sysroot-include-headers.patch \ |
| 33 | file://unixccompiler.patch \ |
| 34 | file://avoid-ncursesw-include-path.patch \ |
| 35 | file://python3-use-CROSSPYTHONPATH-for-PYTHON_FOR_BUILD.patch \ |
| 36 | file://python3-setup.py-no-host-headers-libs.patch \ |
| 37 | file://sysconfig.py-add-_PYTHON_PROJECT_SRC.patch \ |
| 38 | file://setup.py-check-cross_compiling-when-get-FLAGS.patch \ |
| 39 | file://setup.py-find-libraries-in-staging-dirs.patch \ |
| 40 | " |
| 41 | SRC_URI[md5sum] = "7d092d1bba6e17f0d9bd21b49e441dd5" |
| 42 | SRC_URI[sha256sum] = "b5b3963533768d5fc325a4d7a6bd6f666726002d696f1d399ec06b043ea996b8" |
| 43 | |
| 44 | LIC_FILES_CHKSUM = "file://LICENSE;md5=dd98d01d471fac8d8dbdd975229dba03" |
| 45 | |
| 46 | S = "${WORKDIR}/Python-${PV}" |
| 47 | |
| 48 | inherit autotools multilib_header python3native pkgconfig |
| 49 | |
| 50 | CONFIGUREOPTS += " --with-system-ffi " |
| 51 | |
| 52 | CACHED_CONFIGUREVARS = "ac_cv_have_chflags=no \ |
| 53 | ac_cv_have_lchflags=no \ |
| 54 | ac_cv_have_long_long_format=yes \ |
| 55 | ac_cv_buggy_getaddrinfo=no \ |
| 56 | ac_cv_file__dev_ptmx=yes \ |
| 57 | ac_cv_file__dev_ptc=no \ |
| 58 | " |
| 59 | # The 3 lines below are copied from the libffi recipe, ctypes ships its own copy of the libffi sources |
| 60 | #Somehow gcc doesn't set __SOFTFP__ when passing -mfloatabi=softp :( |
| 61 | TARGET_CC_ARCH_append_armv6 = " -D__SOFTFP__" |
| 62 | TARGET_CC_ARCH_append_armv7a = " -D__SOFTFP__" |
| 63 | TARGET_CC_ARCH += "-DNDEBUG -fno-inline" |
| 64 | EXTRA_OEMAKE += "CROSS_COMPILE=yes" |
| 65 | EXTRA_OECONF += "CROSSPYTHONPATH=${STAGING_LIBDIR_NATIVE}/python${PYTHON_MAJMIN}/lib-dynload/ --without-ensurepip" |
| 66 | |
| 67 | export CROSS_COMPILE = "${TARGET_PREFIX}" |
| 68 | export _PYTHON_PROJECT_BASE = "${B}" |
| 69 | export _PYTHON_PROJECT_SRC = "${S}" |
| 70 | export CCSHARED = "-fPIC" |
| 71 | |
| 72 | # Fix ctypes cross compilation |
| 73 | export CROSSPYTHONPATH = "${B}/build/lib.linux-${TARGET_ARCH}-${PYTHON_MAJMIN}:${S}/Lib:${S}/Lib/plat-linux" |
| 74 | |
| 75 | # No ctypes option for python 3 |
| 76 | PYTHONLSBOPTS = "" |
| 77 | |
| 78 | do_configure_append() { |
| 79 | rm -f ${S}/Makefile.orig |
| 80 | autoreconf -Wcross --verbose --install --force --exclude=autopoint ../Python-${PV}/Modules/_ctypes/libffi |
| 81 | } |
| 82 | |
| 83 | do_compile() { |
| 84 | # regenerate platform specific files, because they depend on system headers |
| 85 | cd ${S}/Lib/plat-linux* |
| 86 | include=${STAGING_INCDIR} ${STAGING_BINDIR_NATIVE}/python3-native/python3 \ |
| 87 | ${S}/Tools/scripts/h2py.py -i '(u_long)' \ |
| 88 | ${STAGING_INCDIR}/dlfcn.h \ |
| 89 | ${STAGING_INCDIR}/linux/cdrom.h \ |
| 90 | ${STAGING_INCDIR}/netinet/in.h \ |
| 91 | ${STAGING_INCDIR}/sys/types.h |
| 92 | sed -e 's,${STAGING_DIR_HOST},,g' -i *.py |
| 93 | cd - |
| 94 | |
| 95 | |
| 96 | # remove any bogus LD_LIBRARY_PATH |
| 97 | sed -i -e s,RUNSHARED=.*,RUNSHARED=, Makefile |
| 98 | |
| 99 | if [ ! -f Makefile.orig ]; then |
| 100 | install -m 0644 Makefile Makefile.orig |
| 101 | fi |
| 102 | sed -i -e 's,^CONFIGURE_LDFLAGS=.*,CONFIGURE_LDFLAGS=-L. -L${STAGING_LIBDIR},g' \ |
| 103 | -e 's,libdir=${libdir},libdir=${STAGING_LIBDIR},g' \ |
| 104 | -e 's,libexecdir=${libexecdir},libexecdir=${STAGING_DIR_HOST}${libexecdir},g' \ |
| 105 | -e 's,^LIBDIR=.*,LIBDIR=${STAGING_LIBDIR},g' \ |
| 106 | -e 's,includedir=${includedir},includedir=${STAGING_INCDIR},g' \ |
| 107 | -e 's,^INCLUDEDIR=.*,INCLUDE=${STAGING_INCDIR},g' \ |
| 108 | -e 's,^CONFINCLUDEDIR=.*,CONFINCLUDE=${STAGING_INCDIR},g' \ |
| 109 | Makefile |
| 110 | # save copy of it now, because if we do it in do_install and |
| 111 | # then call do_install twice we get Makefile.orig == Makefile.sysroot |
| 112 | install -m 0644 Makefile Makefile.sysroot |
| 113 | |
| 114 | oe_runmake HOSTPGEN=${STAGING_BINDIR_NATIVE}/python3-native/pgen \ |
| 115 | HOSTPYTHON=${STAGING_BINDIR_NATIVE}/python3-native/python3 \ |
| 116 | STAGING_LIBDIR=${STAGING_LIBDIR} \ |
| 117 | STAGING_BASELIBDIR=${STAGING_BASELIBDIR} \ |
| 118 | STAGING_INCDIR=${STAGING_INCDIR} \ |
| 119 | BUILD_SYS=${BUILD_SYS} HOST_SYS=${HOST_SYS} \ |
| 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 | BUILD_SYS=${BUILD_SYS} HOST_SYS=${HOST_SYS} \ |
| 130 | LIB=${baselib} \ |
| 131 | ARCH=${TARGET_ARCH} \ |
| 132 | OPT="${CFLAGS}" |
| 133 | } |
| 134 | |
| 135 | do_install() { |
| 136 | # make install needs the original Makefile, or otherwise the inclues would |
| 137 | # go to ${D}${STAGING...}/... |
| 138 | install -m 0644 Makefile.orig Makefile |
| 139 | |
| 140 | install -d ${D}${libdir}/pkgconfig |
| 141 | install -d ${D}${libdir}/python${PYTHON_MAJMIN}/config |
| 142 | |
| 143 | # rerun the build once again with original makefile this time |
| 144 | # run install in a separate step to avoid compile/install race |
| 145 | oe_runmake HOSTPGEN=${STAGING_BINDIR_NATIVE}/python3-native/pgen \ |
| 146 | HOSTPYTHON=${STAGING_BINDIR_NATIVE}/python3-native/python3 \ |
| 147 | STAGING_LIBDIR=${STAGING_LIBDIR} \ |
| 148 | STAGING_INCDIR=${STAGING_INCDIR} \ |
| 149 | STAGING_BASELIBDIR=${STAGING_BASELIBDIR} \ |
| 150 | BUILD_SYS=${BUILD_SYS} HOST_SYS=${HOST_SYS} \ |
| 151 | LIB=${baselib} \ |
| 152 | ARCH=${TARGET_ARCH} \ |
| 153 | DESTDIR=${D} LIBDIR=${libdir} |
| 154 | |
| 155 | oe_runmake HOSTPGEN=${STAGING_BINDIR_NATIVE}/python3-native/pgen \ |
| 156 | HOSTPYTHON=${STAGING_BINDIR_NATIVE}/python3-native/python3 \ |
| 157 | STAGING_LIBDIR=${STAGING_LIBDIR} \ |
| 158 | STAGING_INCDIR=${STAGING_INCDIR} \ |
| 159 | STAGING_BASELIBDIR=${STAGING_BASELIBDIR} \ |
| 160 | BUILD_SYS=${BUILD_SYS} HOST_SYS=${HOST_SYS} \ |
| 161 | LIB=${baselib} \ |
| 162 | ARCH=${TARGET_ARCH} \ |
| 163 | DESTDIR=${D} LIBDIR=${libdir} install |
| 164 | |
| 165 | # avoid conflict with 2to3 from Python 2 |
| 166 | rm -f ${D}/${bindir}/2to3 |
| 167 | |
| 168 | install -m 0644 Makefile.sysroot ${D}/${libdir}/python${PYTHON_MAJMIN}/config/Makefile |
| 169 | |
| 170 | if [ -e ${WORKDIR}/sitecustomize.py ]; then |
| 171 | install -m 0644 ${WORKDIR}/sitecustomize.py ${D}/${libdir}/python${PYTHON_MAJMIN} |
| 172 | fi |
| 173 | |
| 174 | oe_multilib_header python${PYTHON_BINABI}/pyconfig.h |
| 175 | } |
| 176 | |
| 177 | do_install_append_class-nativesdk () { |
| 178 | create_wrapper ${D}${bindir}/python${PYTHON_MAJMIN} TERMINFO_DIRS='${sysconfdir}/terminfo:/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo' |
| 179 | } |
| 180 | |
| 181 | SSTATE_SCAN_FILES += "Makefile" |
| 182 | PACKAGE_PREPROCESS_FUNCS += "py_package_preprocess" |
| 183 | |
| 184 | py_package_preprocess () { |
| 185 | # copy back the old Makefile to fix target package |
| 186 | install -m 0644 ${B}/Makefile.orig ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config/Makefile |
| 187 | # Remove references to buildmachine paths in target Makefile and _sysconfigdata |
| 188 | sed -i -e 's:--sysroot=${STAGING_DIR_TARGET}::g' -e s:'--with-libtool-sysroot=${STAGING_DIR_TARGET}'::g \ |
| 189 | ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config/Makefile \ |
| 190 | ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata.py |
| 191 | } |
| 192 | |
| 193 | require python-${PYTHON_MAJMIN}-manifest.inc |
| 194 | |
| 195 | # manual dependency additions |
| 196 | RPROVIDES_${PN}-core = "${PN}" |
| 197 | RRECOMMENDS_${PN}-core = "${PN}-readline" |
| 198 | RRECOMMENDS_${PN}-crypt = "openssl" |
| 199 | RRECOMMENDS_${PN}-crypt_class-nativesdk = "nativesdk-openssl" |
| 200 | |
| 201 | FILES_${PN}-2to3 += "${bindir}/2to3-${PYTHON_MAJMIN}" |
| 202 | FILES_${PN}-pydoc += "${bindir}/pydoc${PYTHON_MAJMIN} ${bindir}/pydoc3" |
| 203 | FILES_${PN}-idle += "${bindir}/idle3 ${bindir}/idle${PYTHON_MAJMIN}" |
| 204 | |
| 205 | PACKAGES =+ "${PN}-pyvenv" |
| 206 | FILES_${PN}-pyvenv += "${bindir}/pyvenv-${PYTHON_MAJMIN} ${bindir}/pyvenv" |
| 207 | |
| 208 | # package libpython3 |
| 209 | PACKAGES =+ "libpython3 libpython3-staticdev" |
| 210 | FILES_libpython3 = "${libdir}/libpython*.so.*" |
| 211 | FILES_libpython3-staticdev += "${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_BINABI}/libpython${PYTHON_BINABI}.a" |
| 212 | |
| 213 | # catch debug extensions (isn't that already in python-core-dbg?) |
| 214 | FILES_${PN}-dbg += "${libdir}/python${PYTHON_MAJMIN}/lib-dynload/.debug" |
| 215 | |
| 216 | # catch all the rest (unsorted) |
| 217 | PACKAGES += "${PN}-misc" |
| 218 | RDEPENDS_${PN}-misc += "${PN}-core" |
| 219 | FILES_${PN}-misc = "${libdir}/python${PYTHON_MAJMIN}" |
| 220 | |
| 221 | # catch manpage |
| 222 | PACKAGES += "${PN}-man" |
| 223 | FILES_${PN}-man = "${datadir}/man" |
| 224 | |
| 225 | BBCLASSEXTEND = "nativesdk" |