diff options
author | Ross Burton <ross.burton@intel.com> | 2017-03-24 16:09:19 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-03-27 08:15:06 +0100 |
commit | 814e960d379ec38ab32c161e4028fde66bab0dd9 (patch) | |
tree | b02e5d3a24dd78b37416b5496fde3c6481165107 /meta | |
parent | d51913264f47dc8140fc3519963c0663807ae277 (diff) | |
download | poky-814e960d379ec38ab32c161e4028fde66bab0dd9.tar.gz |
boost: port boost-python to Python 3
As Python 3 is the default Python version, change Boost to build against Python
3 instead of Python 2 if enabled. It's not simple to support both, so this
means that support for building boost-python against Python 2 has been removed.
This involves backporting a number of patches upstream to fix Python 3 support,
and telling Boost precisely where to find the Python headers and libraries so
that it doesn't try to invoke the host Python to determine these values.
[ YOCTO #11104 ]
(From OE-Core rev: 0f5418eb0ce12811b16d2e3c28c28140a509f685)
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/recipes-support/boost/boost.inc | 36 | ||||
-rw-r--r-- | meta/recipes-support/boost/boost/py3.patch | 269 | ||||
-rw-r--r-- | meta/recipes-support/boost/boost_1.63.0.bb | 1 |
3 files changed, 287 insertions, 19 deletions
diff --git a/meta/recipes-support/boost/boost.inc b/meta/recipes-support/boost/boost.inc index 87b6b884f2..dcadcbcc42 100644 --- a/meta/recipes-support/boost/boost.inc +++ b/meta/recipes-support/boost/boost.inc | |||
@@ -42,16 +42,15 @@ PACKAGECONFIG ??= "locale" | |||
42 | PACKAGECONFIG[locale] = ",,icu" | 42 | PACKAGECONFIG[locale] = ",,icu" |
43 | PACKAGECONFIG[graph_parallel] = ",,,boost-mpi mpich" | 43 | PACKAGECONFIG[graph_parallel] = ",,,boost-mpi mpich" |
44 | PACKAGECONFIG[mpi] = ",,mpich" | 44 | PACKAGECONFIG[mpi] = ",,mpich" |
45 | PACKAGECONFIG[python] = ",,python python3" | 45 | PACKAGECONFIG[python] = ",,python3" |
46 | 46 | ||
47 | BOOST_LIBS += "\ | 47 | BOOST_LIBS += "\ |
48 | ${@bb.utils.filter('PACKAGECONFIG', 'locale', d)} \ | 48 | ${@bb.utils.filter('PACKAGECONFIG', 'locale python', d)} \ |
49 | ${@bb.utils.contains('PACKAGECONFIG', 'graph_parallel', 'graph_parallel mpi', \ | 49 | ${@bb.utils.contains('PACKAGECONFIG', 'graph_parallel', 'graph_parallel mpi', \ |
50 | bb.utils.filter('PACKAGECONFIG', 'mpi', d), d)} \ | 50 | bb.utils.filter('PACKAGECONFIG', 'mpi', d), d)} \ |
51 | ${@bb.utils.contains('PACKAGECONFIG', 'python', 'python python3', '', d)} \ | ||
52 | " | 51 | " |
53 | 52 | ||
54 | inherit python-dir | 53 | inherit python3-dir |
55 | PYTHON_ROOT = "${STAGING_DIR_HOST}/${prefix}" | 54 | PYTHON_ROOT = "${STAGING_DIR_HOST}/${prefix}" |
56 | 55 | ||
57 | # Make a package for each library, plus -dev | 56 | # Make a package for each library, plus -dev |
@@ -59,19 +58,12 @@ PACKAGES = "${PN}-dbg ${BOOST_PACKAGES}" | |||
59 | python __anonymous () { | 58 | python __anonymous () { |
60 | packages = [] | 59 | packages = [] |
61 | extras = [] | 60 | extras = [] |
62 | for lib in d.getVar('BOOST_LIBS').split( ): | 61 | for lib in d.getVar('BOOST_LIBS').split(): |
63 | # BJAM does not know '--with-python3' (only --with-python) | 62 | extras.append("--with-%s" % lib) |
64 | if lib != "python3": | ||
65 | extras.append("--with-%s" % lib) | ||
66 | pkg = "boost-%s" % lib.replace("_", "-") | 63 | pkg = "boost-%s" % lib.replace("_", "-") |
67 | packages.append(pkg) | 64 | packages.append(pkg) |
68 | if lib == "python": | 65 | if not d.getVar("FILES_%s" % pkg): |
69 | # special: python*.so matches python3.so !! | 66 | d.setVar("FILES_%s" % pkg, "${libdir}/libboost_%s*.so.*" % lib) |
70 | if not d.getVar("FILES_%s" % pkg): | ||
71 | d.setVar("FILES_%s" % pkg, "${libdir}/libboost_%s.so.*" % lib) | ||
72 | else: | ||
73 | if not d.getVar("FILES_%s" % pkg): | ||
74 | d.setVar("FILES_%s" % pkg, "${libdir}/libboost_%s*.so.*" % lib) | ||
75 | d.setVar("BOOST_PACKAGES", " ".join(packages)) | 67 | d.setVar("BOOST_PACKAGES", " ".join(packages)) |
76 | d.setVar("BJAM_EXTRA", " ".join(extras)) | 68 | d.setVar("BJAM_EXTRA", " ".join(extras)) |
77 | } | 69 | } |
@@ -186,15 +178,21 @@ do_configure() { | |||
186 | # D2194:Fixing the failure of "error: duplicate initialization of gcc with the following parameters" during compilation. | 178 | # D2194:Fixing the failure of "error: duplicate initialization of gcc with the following parameters" during compilation. |
187 | rm -f ${WORKDIR}/user-config.jam | 179 | rm -f ${WORKDIR}/user-config.jam |
188 | echo 'using gcc : 4.3.1 : ${CXX} : <cflags>"${CFLAGS}" <cxxflags>"${CXXFLAGS}" <linkflags>"${LDFLAGS}" ;' >> ${WORKDIR}/user-config.jam | 180 | echo 'using gcc : 4.3.1 : ${CXX} : <cflags>"${CFLAGS}" <cxxflags>"${CXXFLAGS}" <linkflags>"${LDFLAGS}" ;' >> ${WORKDIR}/user-config.jam |
189 | echo "using python : ${PYTHON_BASEVERSION} : : ${STAGING_INCDIR}/python${PYTHON_BASEVERSION} ;" >> ${WORKDIR}/user-config.jam | 181 | |
190 | echo "using python : 3.5 : : ${STAGING_INCDIR}/python3.5m ;" >> ${WORKDIR}/user-config.jam | 182 | # If we want Python then we need to tell Boost *exactly* where to find it |
183 | if ${@bb.utils.contains('BOOST_LIBS', 'python', 'true', 'false', d)}; then | ||
184 | echo "using python : ${PYTHON_BASEVERSION} : ${STAGING_DIR_HOST}${bindir}/python3 : ${STAGING_DIR_HOST}${includedir}/${PYTHON_DIR}${PYTHON_ABI} : ${STAGING_DIR_HOST}${libdir}/${PYTHON_DIR} ;" >> ${WORKDIR}/user-config.jam | ||
185 | fi | ||
191 | 186 | ||
192 | if ${@bb.utils.contains('BOOST_LIBS', 'mpi', 'true', 'false', d)}; then | 187 | if ${@bb.utils.contains('BOOST_LIBS', 'mpi', 'true', 'false', d)}; then |
193 | echo "using mpi : : <find-shared-library>mpi ;" >> ${WORKDIR}/user-config.jam | 188 | echo "using mpi : : <find-shared-library>mpi ;" >> ${WORKDIR}/user-config.jam |
194 | fi | 189 | fi |
195 | 190 | ||
196 | CC="${BUILD_CC}" CFLAGS="${BUILD_CFLAGS}" ./bootstrap.sh --with-bjam=bjam --with-toolset=gcc --with-python-root=${PYTHON_ROOT} | 191 | CC="${BUILD_CC}" CFLAGS="${BUILD_CFLAGS}" ./bootstrap.sh --with-bjam=bjam --with-toolset=gcc |
197 | sed -i '/^using python/d' ${S}/project-config.jam | 192 | |
193 | # Boost can't be trusted to find Python on it's own, so remove any mention | ||
194 | # of it from the boost configuration | ||
195 | sed -i '/using python/d' ${S}/project-config.jam | ||
198 | } | 196 | } |
199 | 197 | ||
200 | do_compile() { | 198 | do_compile() { |
diff --git a/meta/recipes-support/boost/boost/py3.patch b/meta/recipes-support/boost/boost/py3.patch new file mode 100644 index 0000000000..2b1ff1865e --- /dev/null +++ b/meta/recipes-support/boost/boost/py3.patch | |||
@@ -0,0 +1,269 @@ | |||
1 | Backport fixes from upstream (as of boost super-module commit 0d52b9) to improve | ||
2 | the building of the Boost Python module with Python 3. | ||
3 | |||
4 | Upstream-Status: Backport | ||
5 | Signed-off-by: Ross Burton <ross.burton@intel.com> | ||
6 | |||
7 | diff --git a/build/Jamfile b/build/Jamfile | ||
8 | index 313fdab..f14dc11 100644 | ||
9 | --- a/libs/python/build/Jamfile | ||
10 | +++ b/libs/python/build/Jamfile | ||
11 | @@ -6,6 +6,7 @@ import os ; | ||
12 | import indirect ; | ||
13 | import modules ; | ||
14 | import feature ; | ||
15 | +import property ; | ||
16 | |||
17 | import python ; | ||
18 | |||
19 | @@ -30,21 +31,8 @@ else | ||
20 | ; | ||
21 | } | ||
22 | |||
23 | -rule find-py3-version | ||
24 | -{ | ||
25 | - local versions = [ feature.values python ] ; | ||
26 | - local py3ver ; | ||
27 | - for local v in $(versions) | ||
28 | - { | ||
29 | - if $(v) >= 3.0 | ||
30 | - { | ||
31 | - py3ver = $(v) ; | ||
32 | - } | ||
33 | - } | ||
34 | - return $(py3ver) ; | ||
35 | -} | ||
36 | - | ||
37 | -py3-version = [ find-py3-version ] ; | ||
38 | +py2-version = [ py-version 2 ] ; | ||
39 | +py3-version = [ py-version 3 ] ; | ||
40 | |||
41 | project boost/python | ||
42 | : source-location ../src | ||
43 | @@ -52,11 +40,17 @@ project boost/python | ||
44 | |||
45 | rule cond ( test ? : yes * : no * ) { if $(test) { return $(yes) ; } else { return $(no) ; } } | ||
46 | rule unless ( test ? : yes * : no * ) { if ! $(test) { return $(yes) ; } else { return $(no) ; } } | ||
47 | +local rule eq ( a : b ) { if $(a) = $(b) { return 1 ; } } | ||
48 | |||
49 | -rule lib_boost_python ( is-py3 ? ) | ||
50 | -{ | ||
51 | +lib_boost_python(2) = boost_python ; | ||
52 | +lib_boost_python(3) = boost_python3 ; | ||
53 | |||
54 | - lib [ cond $(is-py3) : boost_python3 : boost_python ] | ||
55 | +lib_boost_python($(py2-version)) = $(lib_boost_python(2)) ; | ||
56 | +lib_boost_python($(py3-version)) = $(lib_boost_python(3)) ; | ||
57 | + | ||
58 | +rule lib_boost_python ( version ) | ||
59 | +{ | ||
60 | + lib $(lib_boost_python($(version))) | ||
61 | : # sources | ||
62 | numeric.cpp | ||
63 | list.cpp | ||
64 | @@ -112,11 +106,13 @@ rule lib_boost_python ( is-py3 ? ) | ||
65 | <dependency>config-warning | ||
66 | |||
67 | <python-debugging>on:<define>BOOST_DEBUG_PYTHON | ||
68 | - [ cond $(is-py3) : <python>$(py3-version) ] | ||
69 | + <python>$(version) | ||
70 | |||
71 | -<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag | ||
72 | <tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).python-tag | ||
73 | |||
74 | + <conditional>@python.require-py | ||
75 | + | ||
76 | : # default build | ||
77 | <link>shared | ||
78 | : # usage requirements | ||
79 | @@ -125,51 +121,68 @@ rule lib_boost_python ( is-py3 ? ) | ||
80 | ; | ||
81 | } | ||
82 | |||
83 | -rule lib_boost_numpy ( is-py3 ? ) | ||
84 | +lib_boost_numpy(2) = boost_numpy ; | ||
85 | +lib_boost_numpy(3) = boost_numpy3 ; | ||
86 | + | ||
87 | +lib_boost_numpy($(py2-version)) = $(lib_boost_python(2)) ; | ||
88 | +lib_boost_numpy($(py3-version)) = $(lib_boost_python(3)) ; | ||
89 | + | ||
90 | +rule lib_boost_numpy ( version ) | ||
91 | { | ||
92 | numpy-include = [ python.numpy-include ] ; | ||
93 | - lib [ cond $(is-py3) : boost_numpy3 : boost_numpy ] | ||
94 | + lib $(lib_boost_numpy($(version))) | ||
95 | : # sources | ||
96 | numpy/dtype.cpp | ||
97 | numpy/matrix.cpp | ||
98 | numpy/ndarray.cpp | ||
99 | - numpy/numpy.cpp | ||
100 | - numpy/scalars.cpp | ||
101 | - numpy/ufunc.cpp | ||
102 | + numpy/numpy.cpp | ||
103 | + numpy/scalars.cpp | ||
104 | + numpy/ufunc.cpp | ||
105 | : # requirements | ||
106 | + <link>static:<define>BOOST_NUMPY_STATIC_LIB | ||
107 | + <define>BOOST_NUMPY_SOURCE | ||
108 | [ cond [ python.numpy ] : <library>/python//python_for_extensions ] | ||
109 | [ unless [ python.numpy ] : <build>no ] | ||
110 | - <include>$(numpy-include) | ||
111 | - <library>boost_python | ||
112 | + <include>$(numpy-include) | ||
113 | + <library>$(lib_boost_python($(version))) | ||
114 | <python-debugging>on:<define>BOOST_DEBUG_PYTHON | ||
115 | - [ cond $(is-py3) : <python>$(py3-version) ] | ||
116 | + <python>$(version) | ||
117 | |||
118 | -<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag | ||
119 | <tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).python-tag | ||
120 | |||
121 | + <conditional>@python.require-py | ||
122 | + | ||
123 | : # default build | ||
124 | <link>shared | ||
125 | : # usage requirements | ||
126 | + <link>static:<define>BOOST_NUMPY_STATIC_LIB | ||
127 | <python-debugging>on:<define>BOOST_DEBUG_PYTHON | ||
128 | ; | ||
129 | } | ||
130 | |||
131 | -libraries = boost_python ; | ||
132 | -libraries3 = boost_python3 ; | ||
133 | -if [ python.numpy ] | ||
134 | -{ | ||
135 | - libraries += boost_numpy ; | ||
136 | - libraries3 += boost_numpy3 ; | ||
137 | -} | ||
138 | - | ||
139 | -lib_boost_python ; | ||
140 | -lib_boost_numpy ; | ||
141 | +libraries = ; | ||
142 | |||
143 | -if $(py3-version) | ||
144 | +for local N in 2 3 | ||
145 | { | ||
146 | - lib_boost_python yes ; | ||
147 | - lib_boost_numpy yes ; | ||
148 | - libraries += $(libraries3) ; | ||
149 | + if $(py$(N)-version) | ||
150 | + { | ||
151 | + lib_boost_python $(py$(N)-version) ; | ||
152 | + libraries += $(lib_boost_python($(py$(N)-version))) ; | ||
153 | + } | ||
154 | + else | ||
155 | + { | ||
156 | + alias $(lib_boost_python($(N))) ; | ||
157 | + } | ||
158 | + if $(py$(N)-version) && [ python.numpy ] | ||
159 | + { | ||
160 | + lib_boost_numpy $(py$(N)-version) ; | ||
161 | + libraries += $(lib_boost_numpy($(py$(N)-version))) ; | ||
162 | + } | ||
163 | + else | ||
164 | + { | ||
165 | + alias $(lib_boost_numpy($(N))) ; | ||
166 | + } | ||
167 | } | ||
168 | |||
169 | boost-install $(libraries) ; | ||
170 | diff --git a/src/tools/python.jam b/src/tools/python.jam | ||
171 | index cc13385..bf300b8 100644 | ||
172 | --- a/tools/build/src/tools/python.jam | ||
173 | +++ b/tools/build/src/tools/python.jam | ||
174 | @@ -34,6 +34,7 @@ import path ; | ||
175 | import feature ; | ||
176 | import set ; | ||
177 | import builtin ; | ||
178 | +import property-set ; | ||
179 | |||
180 | |||
181 | # Make this module a project. | ||
182 | @@ -60,6 +61,10 @@ lib rt ; | ||
183 | # installed in the development system's default paths. | ||
184 | feature.feature pythonpath : : free optional path ; | ||
185 | |||
186 | +# The best configured version of Python 2 and 3. | ||
187 | +py2-version = ; | ||
188 | +py3-version = ; | ||
189 | + | ||
190 | # Initializes the Python toolset. Note that all parameters are optional. | ||
191 | # | ||
192 | # - version -- the version of Python to use. Should be in Major.Minor format, | ||
193 | @@ -861,6 +866,11 @@ local rule configure ( version ? : cmd-or-prefix ? : includes * : libraries ? : | ||
194 | if ! $(version) in [ feature.values python ] | ||
195 | { | ||
196 | feature.extend python : $(version) ; | ||
197 | + py$(major-minor[1])-version ?= $(version) ; | ||
198 | + if $(py$(major-minor[1])-version) < $(version) | ||
199 | + { | ||
200 | + py$(major-minor[1])-version = $(version) ; | ||
201 | + } | ||
202 | } | ||
203 | target-requirements += <python>$(version:E=default) ; | ||
204 | } | ||
205 | @@ -916,6 +926,9 @@ local rule configure ( version ? : cmd-or-prefix ? : includes * : libraries ? : | ||
206 | } | ||
207 | } | ||
208 | |||
209 | + # In case we added duplicate requirements from what the user specified. | ||
210 | + target-requirements = [ sequence.unique $(target-requirements) ] ; | ||
211 | + | ||
212 | # Global, but conditional, requirements to give access to the interpreter | ||
213 | # for general utilities, like other toolsets, that run Python scripts. | ||
214 | toolset.add-requirements | ||
215 | @@ -934,19 +947,6 @@ local rule configure ( version ? : cmd-or-prefix ? : includes * : libraries ? : | ||
216 | toolset.add-requirements <target-os>$(target-os):<python>$(version:E=default) ; | ||
217 | } | ||
218 | |||
219 | - # We also set a default requirement that assigns the first python configured | ||
220 | - # for a particular target OS as the default. This makes it so that we can | ||
221 | - # select a python interpreter with only knowledge of the target OS. And hence | ||
222 | - # can configure different Pythons based on the target OS only. | ||
223 | - local toolset-requirements = [ toolset.requirements ] ; | ||
224 | - local toolset-target-os-requirements | ||
225 | - = [ property.evaluate-conditionals-in-context | ||
226 | - [ $(toolset-requirements).raw ] : <target-os>$(target-os) ] ; | ||
227 | - if ! <python> in $(toolset-target-os-requirements:G) | ||
228 | - { | ||
229 | - toolset.add-requirements <target-os>$(target-os):<python>$(version:E=default) ; | ||
230 | - } | ||
231 | - | ||
232 | # Register the right suffix for extensions. | ||
233 | register-extension-suffix $(extension-suffix) : $(target-requirements) ; | ||
234 | |||
235 | @@ -1038,6 +1038,22 @@ local rule configure ( version ? : cmd-or-prefix ? : includes * : libraries ? : | ||
236 | : $(usage-requirements) | ||
237 | ; | ||
238 | } | ||
239 | + | ||
240 | +} | ||
241 | + | ||
242 | +# Conditional rule specification that will prevent building of a target | ||
243 | +# if there is no matching python configuration available with the given | ||
244 | +# required properties. | ||
245 | +rule require-py ( properties * ) | ||
246 | +{ | ||
247 | + local py-ext-target = [ $(.project).find python_for_extensions ] ; | ||
248 | + local property-set = [ property-set.create $(properties) ] ; | ||
249 | + property-set = [ $(property-set).expand ] ; | ||
250 | + local py-ext-alternative = [ $(py-ext-target).select-alternatives $(property-set) ] ; | ||
251 | + if ! $(py-ext-alternative) | ||
252 | + { | ||
253 | + return <build>no ; | ||
254 | + } | ||
255 | } | ||
256 | |||
257 | |||
258 | @@ -1298,5 +1314,11 @@ rule numpy-test ( name : sources * : requirements * ) | ||
259 | : $(name) ] ; | ||
260 | } | ||
261 | |||
262 | +rule py-version ( n ) | ||
263 | +{ | ||
264 | + return $(py$(n)-version) ; | ||
265 | +} | ||
266 | + | ||
267 | IMPORT $(__name__) : bpl-test : : bpl-test ; | ||
268 | IMPORT $(__name__) : numpy-test : : numpy-test ; | ||
269 | +IMPORT $(__name__) : py-version : : py-version ; | ||
diff --git a/meta/recipes-support/boost/boost_1.63.0.bb b/meta/recipes-support/boost/boost_1.63.0.bb index dd30934091..1107686bca 100644 --- a/meta/recipes-support/boost/boost_1.63.0.bb +++ b/meta/recipes-support/boost/boost_1.63.0.bb | |||
@@ -11,4 +11,5 @@ SRC_URI += "\ | |||
11 | file://0001-Apply-boost-1.62.0-no-forced-flags.patch.patch \ | 11 | file://0001-Apply-boost-1.62.0-no-forced-flags.patch.patch \ |
12 | file://0003-Don-t-set-up-arch-instruction-set-flags-we-do-that-o.patch \ | 12 | file://0003-Don-t-set-up-arch-instruction-set-flags-we-do-that-o.patch \ |
13 | file://0002-Don-t-set-up-m32-m64-we-do-that-ourselves.patch \ | 13 | file://0002-Don-t-set-up-m32-m64-we-do-that-ourselves.patch \ |
14 | file://py3.patch \ | ||
14 | " | 15 | " |