Skip to content

Commit

Permalink
boost: build extra boost_pythonXX libs, add python_executableXX options
Browse files Browse the repository at this point in the history
Boost b2 supports building Boost.Python for multiple python versions.
(https://www.boost.org/doc/libs/1_79_0/libs/python/doc/html/building/configuring_boost_build.html)

Pass option `boost:pythonXY_executable` to enable building
boost_python for X.Y of python.

For example when in a python 3.10 environment, adding these options:

    -o boost:python27_executable=`which python2.7` \
    -o boost:python36_executable=`which python3.6` \
    ...

Will build libboost_python310 (the default), libboost_python27 and libboost_python36.
  • Loading branch information
markferry committed Aug 3, 2022
1 parent b5c3140 commit f1977f9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions recipes/boost/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
"wave",
)

PYTHON_VERSIONS = ("2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10")


class BoostConan(ConanFile):
name = "boost"
Expand Down Expand Up @@ -105,6 +107,8 @@ class BoostConan(ConanFile):
"system_use_utf8": [True, False],
}
options.update({"without_{}".format(_name): [True, False] for _name in CONFIGURE_OPTIONS})
# extra boost_python libs to build
options.update({"python{}_executable".format(_name.replace('.', '')): "ANY" for _name in PYTHON_VERSIONS})

default_options = {
"shared": False,
Expand Down Expand Up @@ -143,6 +147,8 @@ class BoostConan(ConanFile):
}
default_options.update({"without_{}".format(_name): False for _name in CONFIGURE_OPTIONS})
default_options.update({"without_{}".format(_name): True for _name in ("graph_parallel", "mpi", "python")})
# extra boost_python libs to build
default_options.update({"python{}_executable".format(_name.replace('.', '')): "None" for _name in PYTHON_VERSIONS})

short_paths = True
no_copy_source = True
Expand Down Expand Up @@ -1072,6 +1078,11 @@ def create_python_config(python_tool):

contents += create_python_config(self._python)

for version in PYTHON_VERSIONS:
option = self.options.get_safe("python{}_executable".format(version.replace('.', '')))
if option:
contents += create_python_config(PythonTool(version, option.value, self))

if not self.options.without_mpi:
# https://www.boost.org/doc/libs/1_72_0/doc/html/mpi/getting_started.html
contents += "\nusing mpi ;"
Expand Down

0 comments on commit f1977f9

Please sign in to comment.