• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright David Abrahams 2001-2006. Distributed under the Boost
2# Software License, Version 1.0. (See accompanying
3# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4
5import os ;
6import indirect ;
7import modules ;
8import feature ;
9import property ;
10import python ;
11
12if ! [ python.configured ] && ! ( --without-python in  [ modules.peek : ARGV ] )
13{
14    # Attempt default configuration of python
15    import toolset : using ;
16    using python ;
17}
18
19if [ python.configured ] || ( --without-python in  [ modules.peek : ARGV ] )
20{
21    alias config-warning ;
22}
23else
24{
25    message config-warning
26        : "warning: No python installation configured and autoconfiguration"
27        : "note: failed.  See http://www.boost.org/libs/python/doc/building.html"
28        : "note: for configuration instructions or pass --without-python to"
29        : "note: suppress this message and silently skip all Boost.Python targets"
30        ;
31}
32
33if [ python.configured ]
34{
35project boost/python
36  : source-location ../src
37  ;
38
39rule cond ( test ? : yes * : no * ) { if $(test) { return $(yes) ; } else { return $(no) ; } }
40rule unless ( test ? : yes * : no * ) { if ! $(test) { return $(yes) ; } else { return $(no) ; } }
41local rule eq ( a : b ) { if $(a) = $(b) { return 1 ; } }
42
43lib boost_python
44    : # sources
45    list.cpp
46    long.cpp
47    dict.cpp
48    tuple.cpp
49    str.cpp
50    slice.cpp
51
52    converter/from_python.cpp
53    converter/registry.cpp
54    converter/type_id.cpp
55    object/enum.cpp
56    object/class.cpp
57    object/function.cpp
58    object/inheritance.cpp
59    object/life_support.cpp
60    object/pickle_support.cpp
61    errors.cpp
62    module.cpp
63    converter/builtin_converters.cpp
64    converter/arg_to_python_base.cpp
65    object/iterator.cpp
66    object/stl_iterator.cpp
67    object_protocol.cpp
68    object_operators.cpp
69    wrapper.cpp
70    import.cpp
71    exec.cpp
72    object/function_doc_signature.cpp
73    :   # requirements
74        <link>static:<define>BOOST_PYTHON_STATIC_LIB
75        <define>BOOST_PYTHON_SOURCE
76
77        # On Windows, all code using Python has to link to the Python
78        # import library.
79        #
80        # On *nix we never link libboost_python to libpython.  When
81        # extending Python, all Python symbols are provided by the
82        # Python interpreter executable.  When embedding Python, the
83        # client executable is expected to explicitly link to
84        # /python//python (the target representing libpython) itself.
85        #
86        # python_for_extensions is a target defined by Boost.Build to
87        # provide the Python include paths, and on Windows, the Python
88        # import library, as usage requirements.
89        [ cond [ python.configured ] : <library>/python//python_for_extensions ]
90
91        # we prevent building when there is no python available
92        # as it's not possible anyway, and to cause dependents to
93        # fail to build
94        [ unless [ python.configured ] : <build>no ]
95        <dependency>config-warning
96        <python-debugging>on:<define>BOOST_DEBUG_PYTHON
97        -<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
98        <tag>@$(__name__).python-tag
99        <conditional>@python.require-py
100
101    :   # default build
102        <link>shared
103    :   # usage requirements
104        <link>static:<define>BOOST_PYTHON_STATIC_LIB
105        <python-debugging>on:<define>BOOST_DEBUG_PYTHON
106    ;
107
108numpy-include = [ python.numpy-include ] ;
109lib boost_numpy
110    : # sources
111    numpy/dtype.cpp
112    numpy/matrix.cpp
113    numpy/ndarray.cpp
114    numpy/numpy.cpp
115    numpy/scalars.cpp
116    numpy/ufunc.cpp
117    :   # requirements
118        <link>static:<define>BOOST_NUMPY_STATIC_LIB
119        <define>BOOST_NUMPY_SOURCE
120        [ cond [ python.numpy ] : <library>/python//python_for_extensions ]
121        [ unless [ python.numpy ] : <build>no ]
122        <include>$(numpy-include)
123        <library>boost_python
124        <python-debugging>on:<define>BOOST_DEBUG_PYTHON
125        -<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
126	<tag>@$(__name__).python-tag
127        <conditional>@python.require-py
128
129    :   # default build
130        <link>shared
131    :   # usage requirements
132        <link>static:<define>BOOST_NUMPY_STATIC_LIB
133        <python-debugging>on:<define>BOOST_DEBUG_PYTHON
134    ;
135
136# boost-install creates `stage` and `install` targets
137#
138# `stage` stages (builds and copies into `stage/lib`) the given libraries
139#   `boost_python` and `boost_numpy` and their dependencies and is similar
140#   to issuing `b2 --with-python stage` from top level
141#
142# `install` installs the two libraries and their dependencies and is similar
143#   to issuing `b2 --with-python install` from top level
144
145boost-install boost_python boost_numpy ;
146
147}
148else
149{
150
151# When Python isn't configured, the above `boost-install` is not executed,
152# so we create empty `stage` and `install` targets that do nothing but issue
153# a warning message unless `--without-python` is given
154
155alias stage : config-warning ;
156explicit stage ;
157
158alias install : config-warning ;
159explicit install ;
160
161}
162