summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/python/python_2.7.16.bb
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/python/python_2.7.16.bb')
-rw-r--r--meta/recipes-devtools/python/python_2.7.16.bb264
1 files changed, 264 insertions, 0 deletions
diff --git a/meta/recipes-devtools/python/python_2.7.16.bb b/meta/recipes-devtools/python/python_2.7.16.bb
new file mode 100644
index 0000000000..7fe16f7e49
--- /dev/null
+++ b/meta/recipes-devtools/python/python_2.7.16.bb
@@ -0,0 +1,264 @@
1require python.inc
2
3DEPENDS = "python-native libffi bzip2 gdbm openssl \
4 readline sqlite3 zlib virtual/crypt"
5
6PR = "${INC_PR}"
7
8DISTRO_SRC_URI ?= "file://sitecustomize.py"
9DISTRO_SRC_URI_linuxstdbase = ""
10SRC_URI += "\
11 file://01-use-proper-tools-for-cross-build.patch \
12 file://03-fix-tkinter-detection.patch \
13 file://06-avoid_usr_lib_termcap_path_in_linking.patch \
14 ${DISTRO_SRC_URI} \
15 file://multilib.patch \
16 file://cgi_py.patch \
17 file://setup_py_skip_cross_import_check.patch \
18 file://add-md5module-support.patch \
19 file://host_include_contamination.patch \
20 file://fix_for_using_different_libdir.patch \
21 file://setuptweaks.patch \
22 file://check-if-target-is-64b-not-host.patch \
23 file://search_db_h_in_inc_dirs_and_avoid_warning.patch \
24 file://avoid_warning_about_tkinter.patch \
25 file://avoid_warning_for_sunos_specific_module.patch \
26 file://python-2.7.3-remove-bsdb-rpath.patch \
27 file://run-ptest \
28 file://parallel-makeinst-create-bindir.patch \
29 file://use_sysroot_ncurses_instead_of_host.patch \
30 file://add-CROSSPYTHONPATH-for-PYTHON_FOR_BUILD.patch \
31 file://pass-missing-libraries-to-Extension-for-mul.patch \
32 file://support_SOURCE_DATE_EPOCH_in_py_compile_2.7.patch \
33 file://float-endian.patch \
34"
35
36S = "${WORKDIR}/Python-${PV}"
37
38inherit autotools multilib_header python-dir pythonnative ptest
39
40CONFIGUREOPTS += " --with-system-ffi "
41
42EXTRA_OECONF += "ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=no ac_cv_working_tzset=yes"
43
44PACKAGECONFIG ??= "bdb"
45PACKAGECONFIG[bdb] = ",,db"
46
47do_configure_append() {
48 rm -f ${S}/Makefile.orig
49 autoreconf -Wcross --verbose --install --force --exclude=autopoint ../Python-${PV}/Modules/_ctypes/libffi
50}
51
52do_compile() {
53 # regenerate platform specific files, because they depend on system headers
54 cd ${S}/Lib/plat-linux2
55 include=${STAGING_INCDIR} ${STAGING_BINDIR_NATIVE}/python-native/python \
56 ${S}/Tools/scripts/h2py.py -i '(u_long)' \
57 ${STAGING_INCDIR}/dlfcn.h \
58 ${STAGING_INCDIR}/linux/cdrom.h \
59 ${STAGING_INCDIR}/netinet/in.h \
60 ${STAGING_INCDIR}/sys/types.h
61 sed -e 's,${STAGING_DIR_HOST},,g' -i *.py
62 cd -
63
64 # remove any bogus LD_LIBRARY_PATH
65 sed -i -e s,RUNSHARED=.*,RUNSHARED=, Makefile
66
67 if [ ! -f Makefile.orig ]; then
68 install -m 0644 Makefile Makefile.orig
69 fi
70 sed -i -e 's#^LDFLAGS=.*#LDFLAGS=${LDFLAGS} -L. -L${STAGING_LIBDIR}#g' \
71 -e 's,libdir=${libdir},libdir=${STAGING_LIBDIR},g' \
72 -e 's,libexecdir=${libexecdir},libexecdir=${STAGING_DIR_HOST}${libexecdir},g' \
73 -e 's,^LIBDIR=.*,LIBDIR=${STAGING_LIBDIR},g' \
74 -e 's,includedir=${includedir},includedir=${STAGING_INCDIR},g' \
75 -e 's,^INCLUDEDIR=.*,INCLUDE=${STAGING_INCDIR},g' \
76 -e 's,^CONFINCLUDEDIR=.*,CONFINCLUDE=${STAGING_INCDIR},g' \
77 Makefile
78 # save copy of it now, because if we do it in do_install and
79 # then call do_install twice we get Makefile.orig == Makefile.sysroot
80 install -m 0644 Makefile Makefile.sysroot
81
82 export CROSS_COMPILE="${TARGET_PREFIX}"
83 export PYTHONBUILDDIR="${B}"
84
85 oe_runmake HOSTPGEN=${STAGING_BINDIR_NATIVE}/python-native/pgen \
86 HOSTPYTHON=${STAGING_BINDIR_NATIVE}/python-native/python \
87 STAGING_LIBDIR=${STAGING_LIBDIR} \
88 STAGING_INCDIR=${STAGING_INCDIR} \
89 STAGING_BASELIBDIR=${STAGING_BASELIBDIR} \
90 OPT="${CFLAGS}"
91}
92
93do_install() {
94 # make install needs the original Makefile, or otherwise the inclues would
95 # go to ${D}${STAGING...}/...
96 install -m 0644 Makefile.orig Makefile
97
98 export CROSS_COMPILE="${TARGET_PREFIX}"
99 export PYTHONBUILDDIR="${B}"
100
101 # After swizzling the makefile, we need to run the build again.
102 # install can race with the build so we have to run this first, then install
103 oe_runmake HOSTPGEN=${STAGING_BINDIR_NATIVE}/python-native/pgen \
104 HOSTPYTHON=${STAGING_BINDIR_NATIVE}/python-native/python \
105 CROSSPYTHONPATH=${STAGING_LIBDIR_NATIVE}/python${PYTHON_MAJMIN}/lib-dynload/ \
106 STAGING_LIBDIR=${STAGING_LIBDIR} \
107 STAGING_INCDIR=${STAGING_INCDIR} \
108 STAGING_BASELIBDIR=${STAGING_BASELIBDIR} \
109 DESTDIR=${D} LIBDIR=${libdir}
110
111 oe_runmake HOSTPGEN=${STAGING_BINDIR_NATIVE}/python-native/pgen \
112 HOSTPYTHON=${STAGING_BINDIR_NATIVE}/python-native/python \
113 CROSSPYTHONPATH=${STAGING_LIBDIR_NATIVE}/python${PYTHON_MAJMIN}/lib-dynload/ \
114 STAGING_LIBDIR=${STAGING_LIBDIR} \
115 STAGING_INCDIR=${STAGING_INCDIR} \
116 STAGING_BASELIBDIR=${STAGING_BASELIBDIR} \
117 DESTDIR=${D} LIBDIR=${libdir} install
118
119 install -m 0644 Makefile.sysroot ${D}/${libdir}/python${PYTHON_MAJMIN}/config/Makefile
120
121 if [ -e ${WORKDIR}/sitecustomize.py ]; then
122 install -m 0644 ${WORKDIR}/sitecustomize.py ${D}/${libdir}/python${PYTHON_MAJMIN}
123 fi
124
125 oe_multilib_header python${PYTHON_MAJMIN}/pyconfig.h
126
127 if [ -z "${@bb.utils.filter('PACKAGECONFIG', 'bdb', d)}" ]; then
128 rm -rf ${D}/${libdir}/python${PYTHON_MAJMIN}/bsddb
129 fi
130}
131
132do_install_append_class-nativesdk () {
133 create_wrapper ${D}${bindir}/python2.7 PYTHONHOME='${prefix}' TERMINFO_DIRS='${sysconfdir}/terminfo:/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo' PYTHONNOUSERSITE='1'
134}
135
136SSTATE_SCAN_FILES += "Makefile"
137PACKAGE_PREPROCESS_FUNCS += "py_package_preprocess"
138
139py_package_preprocess () {
140 # copy back the old Makefile to fix target package
141 install -m 0644 ${B}/Makefile.orig ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config/Makefile
142
143 # Remove references to buildmachine paths in target Makefile and _sysconfigdata
144 sed -i -e 's:--sysroot=${STAGING_DIR_TARGET}::g' -e s:'--with-libtool-sysroot=${STAGING_DIR_TARGET}'::g \
145 -e 's|${DEBUG_PREFIX_MAP}||g' \
146 -e 's:${HOSTTOOLS_DIR}/::g' \
147 -e 's:${RECIPE_SYSROOT_NATIVE}::g' \
148 -e 's:${RECIPE_SYSROOT}::g' \
149 -e 's:${BASE_WORKDIR}/${MULTIMACH_TARGET_SYS}::g' \
150 ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config/Makefile \
151 ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata.py
152 (cd ${PKGD}; python -m py_compile ./${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata.py)
153}
154
155PACKAGES_remove = "${PN}"
156
157# manual dependency additions
158RPROVIDES_${PN}-core = "${PN}"
159RRECOMMENDS_${PN}-core_append_class-nativesdk = " nativesdk-python-modules"
160RRECOMMENDS_${PN}-crypt = "openssl"
161
162# package libpython2
163PACKAGES =+ "lib${BPN}2"
164FILES_lib${BPN}2 = "${libdir}/libpython*.so.*"
165
166# catch all the rest (unsorted)
167PACKAGES += "${PN}-misc"
168FILES_${PN}-misc = "${libdir}/python${PYTHON_MAJMIN}"
169RDEPENDS_${PN}-modules += "${PN}-misc"
170
171# ptest
172RDEPENDS_${PN}-ptest = "${PN}-modules ${PN}-tests unzip"
173
174# catch manpage
175PACKAGES += "${PN}-man"
176FILES_${PN}-man = "${datadir}/man"
177
178# Nasty but if bdb isn't enabled the package won't be generated
179RDEPENDS_${PN}-modules_remove = "${@bb.utils.contains('PACKAGECONFIG', 'bdb', '', '${PN}-bsddb', d)}"
180
181RDEPENDS_${PN}-dev = ""
182
183BBCLASSEXTEND = "nativesdk"
184
185# We want bytecode precompiled .py files (.pyc's) by default
186# but the user may set it on their own conf
187
188INCLUDE_PYCS ?= "1"
189
190python(){
191 import collections, json
192
193 filename = os.path.join(d.getVar('THISDIR'), 'python', 'python2-manifest.json')
194 # This python changes the datastore based on the contents of a file, so mark
195 # that dependency.
196 bb.parse.mark_dependency(d, filename)
197
198 with open(filename) as manifest_file:
199 manifest_str = manifest_file.read()
200 json_start = manifest_str.find('# EOC') + 6
201 manifest_file.seek(json_start)
202 manifest_str = manifest_file.read()
203 python_manifest = json.loads(manifest_str, object_pairs_hook=collections.OrderedDict)
204
205 include_pycs = d.getVar('INCLUDE_PYCS')
206
207 packages = d.getVar('PACKAGES').split()
208 pn = d.getVar('PN')
209
210 newpackages=[]
211
212 for key in python_manifest:
213 pypackage= pn + '-' + key
214
215 if pypackage not in packages:
216 # We need to prepend, otherwise python-misc gets everything
217 # so we use a new variable
218 newpackages.append(pypackage)
219
220 # "Build" python's manifest FILES, RDEPENDS and SUMMARY
221 d.setVar('FILES_' + pypackage, '')
222 for value in python_manifest[key]['files']:
223 d.appendVar('FILES_' + pypackage, ' ' + value)
224 if include_pycs == '1':
225 if value.endswith('.py'):
226 d.appendVar('FILES_' + pypackage, ' ' + value + 'c')
227
228 for value in python_manifest[key]['rdepends']:
229 # Make it work with or without $PN
230 if '${PN}' in value:
231 value=value.split('-')[1]
232 d.appendVar('RDEPENDS_' + pypackage, ' ' + pn + '-' + value)
233 d.setVar('SUMMARY_' + pypackage, python_manifest[key]['summary'])
234
235 # Prepending so to avoid python-misc getting everything
236 packages = newpackages + packages
237 d.setVar('PACKAGES', ' '.join(packages))
238 d.setVar('ALLOW_EMPTY_${PN}-modules', '1')
239}
240
241# Files needed to create a new manifest
242SRC_URI += "file://create_manifest2.py file://get_module_deps2.py file://python2-manifest.json"
243
244do_create_manifest() {
245 # This task should be run with every new release of Python.
246 # We must ensure that PACKAGECONFIG enables everything when creating
247 # a new manifest, this is to base our new manifest on a complete
248 # native python build, containing all dependencies, otherwise the task
249 # wont be able to find the required files.
250 # e.g. BerkeleyDB is an optional build dependency so it may or may not
251 # be present, we must ensure it is.
252
253 cd ${WORKDIR}
254 # This needs to be executed by python-native and NOT by HOST's python
255 nativepython create_manifest2.py
256 cp python2-manifest.json.new ${THISDIR}/python/python2-manifest.json
257}
258
259# bitbake python -c create_manifest
260addtask do_create_manifest
261
262# Make sure we have native python ready when we create a new manifest
263do_create_manifest[depends] += "python:do_prepare_recipe_sysroot"
264do_create_manifest[depends] += "python:do_patch"