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