1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Configuring Boost.Build</title> 5<link rel="stylesheet" href="../boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../index.html" title="Boost.Python"> 8<link rel="up" href="../building.html" title="Chapter 2. Building and Testing"> 9<link rel="prev" href="installing_boost_python_on_your_.html" title="Installing Boost.Python on your System"> 10<link rel="next" href="choosing_a_boost_python_library_.html" title="Choosing a Boost.Python Library Binary"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/boost.png"></td></tr></table> 14<hr> 15<div class="spirit-nav"> 16<a accesskey="p" href="installing_boost_python_on_your_.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="choosing_a_boost_python_library_.html"><img src="../images/next.png" alt="Next"></a> 17</div> 18<div class="section"> 19<div class="titlepage"><div><div><h3 class="title"> 20<a name="building.configuring_boost_build"></a><a class="link" href="configuring_boost_build.html" title="Configuring Boost.Build">Configuring Boost.Build</a> 21</h3></div></div></div> 22<div class="toc"><dl class="toc"> 23<dt><span class="section"><a href="configuring_boost_build.html#building.configuring_boost_build.python_configuration_parameters">Python 24 Configuration Parameters</a></span></dt> 25<dt><span class="section"><a href="configuring_boost_build.html#building.configuring_boost_build.examples">Examples</a></span></dt> 26</dl></div> 27<p> 28 As described in the <a href="http://www.boost.org/build/doc/html/bbv2/overview/configuration.html" target="_top">Boost.Build 29 Reference Manual</a>, a file called <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code> in 30 your home directory is used to specify the tools and libraries available 31 to the build system. You may need to create or edit <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code> to 32 tell Boost.Build how to invoke Python, <code class="computeroutput"><span class="preprocessor">#include</span></code> 33 its headers, and link with its libraries. 34 </p> 35<div class="note"><table border="0" summary="Note"> 36<tr> 37<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../images/note.png"></td> 38<th align="left">Note</th> 39</tr> 40<tr><td align="left" valign="top"><p> 41 If you are using a unix-variant OS and you ran Boost's <code class="computeroutput"><span class="identifier">configure</span></code> 42 script, it may have generated a <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code> 43 for you. <a href="#ftn.building.configuring_boost_build.f0" class="footnote" name="building.configuring_boost_build.f0"><sup class="footnote">[2]</sup></a> If your <code class="computeroutput"><span class="identifier">configure</span></code>/<code class="computeroutput"><span class="identifier">make</span></code> sequence was successful and Boost.Python 44 binaries were built, your <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code> 45 file is probably already correct. 46 </p></td></tr> 47</table></div> 48<p> 49 If you have one fairly “standard” python installation for your platform, 50 you might not need to do anything special to describe it. If you haven't 51 configured python in <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code> (and 52 you don't specify <code class="computeroutput"><span class="special">--</span><span class="identifier">without</span><span class="special">-</span><span class="identifier">python</span></code> 53 on the Boost.Build command line), Boost.Build will automatically execute 54 the equivalent of 55 </p> 56<pre class="programlisting"><span class="identifier">import</span> <span class="identifier">toolset</span> <span class="special">:</span> <span class="keyword">using</span> <span class="special">;</span> 57<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">;</span> 58</pre> 59<p> 60 which automatically looks for Python in the most likely places. However, 61 that only happens when using the Boost.Python project file (e.g. when referred 62 to by another project as in the quickstart method). If instead you are linking 63 against separately-compiled Boost.Python binaries, you should set up a <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code> file 64 with at least the minimal incantation above. 65 </p> 66<div class="section"> 67<div class="titlepage"><div><div><h4 class="title"> 68<a name="building.configuring_boost_build.python_configuration_parameters"></a><a class="link" href="configuring_boost_build.html#building.configuring_boost_build.python_configuration_parameters" title="Python Configuration Parameters">Python 69 Configuration Parameters</a> 70</h4></div></div></div> 71<p> 72 If you have several versions of Python installed, or Python is installed 73 in an unusual way, you may want to supply any or all of the following optional 74 parameters to <code class="computeroutput"><span class="keyword">using</span> <span class="identifier">python</span></code>. 75 </p> 76<div class="variablelist"> 77<p class="title"><b></b></p> 78<dl class="variablelist"> 79<dt><span class="term">version</span></dt> 80<dd><p> 81 the version of Python to use. Should be in Major.Minor format, for 82 example, <code class="computeroutput"><span class="number">2.3</span></code>. Do not 83 include the subminor version (i.e. <span class="bold"><strong>not</strong></span> 84 <code class="computeroutput"><span class="number">2.5</span><span class="special">.</span><span class="number">1</span></code>). If you have multiple Python versions 85 installed, the version will usually be the only configuration argument 86 required. 87 </p></dd> 88<dt><span class="term">cmd-or-prefix</span></dt> 89<dd><p> 90 preferably, a command that invokes a Python interpreter. Alternatively, 91 the installation prefix for Python libraries and header files. Only 92 use the alternative formulation if there is no appropriate Python 93 executable available. 94 </p></dd> 95<dt><span class="term"><span class="bold"><strong>includes</strong></span></span></dt> 96<dd><p> 97 the <code class="computeroutput"><span class="preprocessor">#include</span></code> paths 98 for Python headers. Normally the correct path(s) will be automatically 99 deduced from <code class="computeroutput"><span class="identifier">version</span></code> 100 and/or <code class="computeroutput"><span class="identifier">cmd</span><span class="special">-</span><span class="keyword">or</span><span class="special">-</span><span class="identifier">prefix</span></code>. 101 </p></dd> 102<dt><span class="term"><span class="bold"><strong>libraries</strong></span></span></dt> 103<dd><p> 104 the path to Python library binaries. On MacOS/Darwin, you can also 105 pass the path of the Python framework. Normally the correct path(s) 106 will be automatically deduced from <code class="computeroutput"><span class="identifier">version</span></code> 107 and/or <code class="computeroutput"><span class="identifier">cmd</span><span class="special">-</span><span class="keyword">or</span><span class="special">-</span><span class="identifier">prefix</span></code>. 108 </p></dd> 109<dt><span class="term"><span class="bold"><strong>condition</strong></span></span></dt> 110<dd><p> 111 if specified, should be a set of Boost.Build properties that are 112 matched against the build configuration when Boost.Build selects 113 a Python configuration to use. See examples below for details. 114 </p></dd> 115<dt><span class="term"><span class="bold"><strong>extension-suffix</strong></span></span></dt> 116<dd><p> 117 A string to append to the name of extension modules before the true 118 filename extension. You almost certainly don't need to use this. 119 Usually this suffix is only used when targeting a Windows debug build 120 of Python, and will be set automatically for you based on the value 121 of the <a class="link" href="python_debugging_builds.html" title="Python Debugging Builds"><python-debugging></a> 122 feature. However, at least one Linux distribution (Ubuntu Feisty 123 Fawn) has a specially configured <a href="https://wiki.ubuntu.com/PyDbgBuilds" target="_top"><python-dbg></a> 124 package that claims to use such a suffix. 125 </p></dd> 126</dl> 127</div> 128</div> 129<div class="section"> 130<div class="titlepage"><div><div><h4 class="title"> 131<a name="building.configuring_boost_build.examples"></a><a class="link" href="configuring_boost_build.html#building.configuring_boost_build.examples" title="Examples">Examples</a> 132</h4></div></div></div> 133<p> 134 Note that in the examples below, case and <span class="bold"><strong>especially 135 whitespace</strong></span> are significant. 136 </p> 137<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 138<li class="listitem"> 139<p class="simpara"> 140 If you have both python 2.5 and python 2.4 installed, <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code> might contain 141 </p> 142<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.5</span> <span class="special">;</span> <span class="special">#</span> <span class="identifier">Make</span> <span class="identifier">both</span> <span class="identifier">versions</span> <span class="identifier">of</span> <span class="identifier">Python</span> <span class="identifier">available</span> 143<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.4</span> <span class="special">;</span> <span class="special">#</span> <span class="identifier">To</span> <span class="identifier">build</span> <span class="identifier">with</span> <span class="identifier">python</span> <span class="number">2.4</span><span class="special">,</span> <span class="identifier">add</span> <span class="identifier">python</span><span class="special">=</span><span class="number">2.4</span> 144 <span class="preprocessor"># to</span> <span class="identifier">your</span> <span class="identifier">command</span> <span class="identifier">line</span><span class="special">.</span> 145</pre> 146<p class="simpara"> 147 The first version configured (2.5) becomes the default. To build against 148 python 2.4, add <code class="computeroutput"><span class="identifier">python</span><span class="special">=</span><span class="number">2.4</span></code> 149 to the <code class="computeroutput"><span class="identifier">bjam</span></code> command 150 line. 151 </p> 152</li> 153<li class="listitem"> 154<p class="simpara"> 155 If you have python installed in an unusual location, you might supply 156 the path to the interpreter in the <code class="computeroutput"><span class="identifier">cmd</span><span class="special">-</span><span class="keyword">or</span><span class="special">-</span><span class="identifier">prefix</span></code> 157 parameter: 158 </p> 159<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="special">:</span> <span class="special">/</span><span class="identifier">usr</span><span class="special">/</span><span class="identifier">local</span><span class="special">/</span><span class="identifier">python</span><span class="special">-</span><span class="number">2.6</span><span class="special">-</span><span class="identifier">beta</span><span class="special">/</span><span class="identifier">bin</span><span class="special">/</span><span class="identifier">python</span> <span class="special">;</span> 160</pre> 161</li> 162<li class="listitem"> 163<p class="simpara"> 164 If you have a separate build of Python for use with a particular toolset, 165 you might supply that toolset in the <code class="computeroutput"><span class="identifier">condition</span></code> 166 parameter: 167 </p> 168<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">python</span> <span class="special">;</span> <span class="special">#</span> <span class="identifier">use</span> <span class="keyword">for</span> <span class="identifier">most</span> <span class="identifier">toolsets</span> 169 170<span class="preprocessor"># Use</span> <span class="identifier">with</span> <span class="identifier">Intel</span> <span class="identifier">C</span><span class="special">++</span> <span class="identifier">toolset</span> 171<span class="keyword">using</span> <span class="identifier">python</span> 172 <span class="special">:</span> <span class="special">#</span> <span class="identifier">version</span> 173 <span class="special">:</span> <span class="identifier">c</span><span class="special">:\\</span><span class="identifier">Devel</span><span class="special">\\</span><span class="identifier">Python</span><span class="special">-</span><span class="number">2.5</span><span class="special">-</span><span class="identifier">IntelBuild</span><span class="special">\\</span><span class="identifier">PCBuild</span><span class="special">\\</span><span class="identifier">python</span> <span class="special">#</span> <span class="identifier">cmd</span><span class="special">-</span><span class="keyword">or</span><span class="special">-</span><span class="identifier">prefix</span> 174 <span class="special">:</span> <span class="special">#</span> <span class="identifier">includes</span> 175 <span class="special">:</span> <span class="special">#</span> <span class="identifier">libraries</span> 176 <span class="special">:</span> <span class="special"><</span><span class="identifier">toolset</span><span class="special">></span><span class="identifier">intel</span> <span class="special">#</span> <span class="identifier">condition</span> 177 <span class="special">;</span> 178</pre> 179</li> 180<li class="listitem"> 181<p class="simpara"> 182 If you have downloaded the Python sources and built both the normal 183 and the <a class="link" href="python_debugging_builds.html" title="Python Debugging Builds">"python 184 debugging"</a> builds from source on Windows, you might see: 185 </p> 186<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.5</span> <span class="special">:</span> <span class="identifier">C</span><span class="special">:\\</span><span class="identifier">src</span><span class="special">\\</span><span class="identifier">Python</span><span class="special">-</span><span class="number">2.5</span><span class="special">\\</span><span class="identifier">PCBuild</span><span class="special">\\</span><span class="identifier">python</span> <span class="special">;</span> 187<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.5</span> <span class="special">:</span> <span class="identifier">C</span><span class="special">:\\</span><span class="identifier">src</span><span class="special">\\</span><span class="identifier">Python</span><span class="special">-</span><span class="number">2.5</span><span class="special">\\</span><span class="identifier">PCBuild</span><span class="special">\\</span><span class="identifier">python_d</span> 188 <span class="special">:</span> <span class="special">#</span> <span class="identifier">includes</span> 189 <span class="special">:</span> <span class="special">#</span> <span class="identifier">libs</span> 190 <span class="special">:</span> <span class="special"><</span><span class="identifier">python</span><span class="special">-</span><span class="identifier">debugging</span><span class="special">></span><span class="identifier">on</span> <span class="special">;</span> 191</pre> 192</li> 193<li class="listitem"> 194<p class="simpara"> 195 You can set up your user-config.jam so a bjam built under Windows can 196 build/test both Windows and Cygwin_ python extensions. Just pass <code class="computeroutput"><span class="special"><</span><span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">></span><span class="identifier">cygwin</span></code> 197 in the <code class="computeroutput"><span class="identifier">condition</span></code> parameter 198 for the cygwin python installation: 199 </p> 200<pre class="programlisting"><span class="preprocessor"># windows</span> <span class="identifier">installation</span> 201<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">;</span> 202 203<span class="preprocessor"># cygwin</span> <span class="identifier">installation</span> 204<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="special">:</span> <span class="identifier">c</span><span class="special">:\\</span><span class="identifier">cygwin</span><span class="special">\\</span><span class="identifier">bin</span><span class="special">\\</span><span class="identifier">python2</span><span class="special">.</span><span class="number">5</span> <span class="special">:</span> <span class="special">:</span> <span class="special">:</span> <span class="special"><</span><span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">></span><span class="identifier">cygwin</span> <span class="special">;</span> 205</pre> 206<p class="simpara"> 207 when you put target-os=cygwin in your build request, it should build 208 with the cygwin version of python: <a name="flavor"></a>_ 209 </p> 210<pre class="programlisting"><span class="identifier">bjam</span> <span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">=</span><span class="identifier">cygwin</span> <span class="identifier">toolset</span><span class="special">=</span><span class="identifier">gcc</span> 211</pre> 212<p class="simpara"> 213 This is supposed to work the other way, too (targeting windows python 214 with a <a href="http://cygwin.com" target="_top">Cygwin</a> bjam) but it seems 215 as though the support in Boost.Build's toolsets for building that way 216 is broken at the time of this writing. 217 </p> 218</li> 219<li class="listitem"> 220<p class="simpara"> 221 Note that because of <a href="http://zigzag.cs.msu.su/boost.build/wiki/AlternativeSelection" target="_top">the 222 way Boost.Build currently selects target alternatives</a>, you 223 might have be very explicit in your build requests. For example, given: 224 </p> 225<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.5</span> <span class="special">;</span> <span class="special">#</span> <span class="identifier">a</span> <span class="identifier">regular</span> <span class="identifier">windows</span> <span class="identifier">build</span> 226<span class="keyword">using</span> <span class="identifier">python</span> <span class="special">:</span> <span class="number">2.4</span> <span class="special">:</span> <span class="special">:</span> <span class="special">:</span> <span class="special">:</span> <span class="special"><</span><span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">></span><span class="identifier">cygwin</span> <span class="special">;</span> 227</pre> 228<p class="simpara"> 229 building with 230 </p> 231<pre class="programlisting"><span class="identifier">bjam</span> <span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">=</span><span class="identifier">cygwin</span> 232</pre> 233<p class="simpara"> 234 will yield an error. Instead, you'll need to write 235 </p> 236<pre class="programlisting"><span class="identifier">bjam</span> <span class="identifier">target</span><span class="special">-</span><span class="identifier">os</span><span class="special">=</span><span class="identifier">cygwin</span><span class="special">/</span><span class="identifier">python</span><span class="special">=</span><span class="number">2.4</span> 237</pre> 238</li> 239</ul></div> 240</div> 241<div class="footnotes"> 242<br><hr style="width:100; text-align:left;margin-left: 0"> 243<div id="ftn.building.configuring_boost_build.f0" class="footnote"><p><a href="#building.configuring_boost_build.f0" class="para"><sup class="para">[2] </sup></a> 244 <code class="computeroutput"><span class="identifier">configure</span></code> overwrites 245 the existing <code class="computeroutput"><span class="identifier">user</span><span class="special">-</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">jam</span></code> in your home directory (if any) 246 after making a backup of the old version. 247 </p></div> 248</div> 249</div> 250<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 251<td align="left"></td> 252<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David 253 Abrahams, Stefan Seefeld<br>Copyright © 2002-2015 David Abrahams, Stefan Seefeld<p> 254 Distributed under the Boost Software License, Version 1.0. (See accompanying 255 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 256 </p> 257</div></td> 258</tr></table> 259<hr> 260<div class="spirit-nav"> 261<a accesskey="p" href="installing_boost_python_on_your_.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../building.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="choosing_a_boost_python_library_.html"><img src="../images/next.png" alt="Next"></a> 262</div> 263</body> 264</html> 265