Skip to content

Commit c253c5c

Browse files
committed
Updated build-and-test howto
[SVN r37585]
1 parent 8f263e1 commit c253c5c

File tree

12 files changed

+566
-202
lines changed

12 files changed

+566
-202
lines changed

doc/Jamfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@ for local b in $(bases)
1919
;
2020
}
2121

22+
exe tst : tst.cpp ;
23+
2224
alias htmls : $(bases) ;
2325
stage . : $(bases) ;

doc/building.html

Lines changed: 202 additions & 123 deletions
Large diffs are not rendered by default.

doc/building.rst

Lines changed: 85 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,15 @@ you invoke it, to make sure that Boost.Build is correctly locating
169169
all the parts of your Python installation. If it isn't, consider
170170
`Configuring Boost.Build`_ as detailed below.
171171

172+
If you're still having trouble, Someone on one of the following
173+
mailing lists may be able to help:
174+
175+
* The `Boost.Build mailing list`__ for issues related to Boost.Build
176+
* The Python `C++ Sig`__ for issues specifically related to Boost.Python
177+
178+
__ ../../../more/mailing_lists.htm#jamboost
179+
__ ../../../more/mailing_lists.htm#cplussig
180+
172181
In Case Everything Seemed to Work
173182
---------------------------------
174183

@@ -409,10 +418,12 @@ extension-suffix
409418
don't need to use this. Usually this suffix is only used when
410419
targeting a Windows debug build of Python, and will be set
411420
automatically for you based on the value of the
412-
``<python-debugging>`` feature. However, at least one Linux
421+
|python-debugging|_ feature. However, at least one Linux
413422
distribution (Ubuntu Feisty Fawn) has a specially configured
414423
`python-dbg`__ package that claims to use such a suffix.
415424

425+
.. |python-debugging| replace:: ``<python-debugging>``
426+
416427
__ https://wiki.ubuntu.com/PyDbgBuilds
417428

418429

@@ -454,6 +465,17 @@ significant.
454465
: <toolset>intel # condition
455466
;
456467

468+
469+
- If you have downloaded the Python sources and built both the
470+
normal and the “\ `python debugging`_\ ” builds from source on
471+
Windows, you might see::
472+
473+
using python : 2.5 : C:\\src\\Python-2.5\\PCBuild\\python ;
474+
using python : 2.5 : C:\\src\\Python-2.5\\PCBuild\\python_d
475+
: # includes
476+
: # libs
477+
: <python-debugging>on ;
478+
457479
- You can set up your user-config.jam so a bjam built under Windows
458480
can build/test both Windows and Cygwin_ python extensions. Just pass
459481
``<target-os>cygwin`` in the ``condition`` parameter
@@ -539,14 +561,63 @@ any of the following cases:
539561
use the types exposed by your statically-linked extension
540562
modules (and vice-versa).
541563

542-
Testing Boost.Python
543-
====================
564+
``#include`` Issues
565+
===================
544566

567+
1. If you should ever have occasion to ``#include "python.h"``
568+
directly in a translation unit of a program using Boost.Python,
569+
use ``#include "boost/python/detail/wrap_python.hpp"`` instead.
570+
It handles several issues necessary for use with Boost.Python,
571+
one of which is mentioned in the next section.
545572

546-
Python Debug Builds
547-
===================
573+
2. Be sure not to ``#include`` any system headers before
574+
``wrap_python.hpp``. This restriction is actually imposed by
575+
Python, or more properly, by Python's interaction with your
576+
operating system. See
577+
http://docs.python.org/ext/simpleExample.html for details.
578+
579+
.. _python-debugging:
580+
.. _python debugging:
581+
582+
Python Debugging Builds
583+
=======================
584+
585+
Python can be built in a special “python debugging” configuration
586+
that adds extra checks and instrumentation that can be very useful
587+
for developers of extension modules. The data structures used by
588+
the debugging configuration contain additional members, so **a
589+
Python executable built with python debugging enabled cannot be
590+
used with an extension module or library compiled without it, and
591+
vice-versa.**
592+
593+
Since pre-built “python debugging” versions of the Python
594+
executable and libraries are not supplied with most distributions
595+
of Python, [#get-debug-build] and we didn't want to force our users
596+
to build them, Boost.Build does not automatically enable python
597+
debugging in its ``debug`` build variant (which is the default).
598+
Instead there is a special build property called
599+
``python-debugging`` that, when used as a build property, will
600+
define the right preprocessor symbols and select the right
601+
libraries to link with.
602+
603+
On unix-variant platforms, the debugging versions of Python's data
604+
structures will only be used if the symbol ``Py_DEBUG`` is defined.
605+
On many windows compilers, when extension modules are built with
606+
the preprocessor symbol ``_DEBUG``, Python defaults to force
607+
linking with a special debugging version of the Python DLL. Since
608+
that symbol is very commonly used even when Python is not present,
609+
Boost.Python temporarily undefines _DEBUG when Python.h
610+
is #included from ``boost/python/detail/wrap_python.hpp`` - unless
611+
``BOOST_DEBUG_PYTHON`` is defined. The upshot is that if you want
612+
“python debugging”and you aren't using Boost.Build, you should make
613+
sure ``BOOST_DEBUG_PYTHON`` is defined, or python debugging will be
614+
suppressed.
548615

616+
Testing Boost.Python
617+
====================
549618

619+
To run the full test suite for Boost.Python, invoke ``bjam`` in the
620+
``libs/python/test`` subdirectory of your Boost distribution.
550621

551622
Notes for MinGW (and Cygwin with -mno-cygwin) GCC Users
552623
=======================================================
@@ -586,8 +657,8 @@ __ http://www.python.org/doc/current/inst/index.html
586657
that feature.
587658
588659
.. [#toolset-specific] Because of the way most \*nix platforms
589-
share symbols among dynamically-loaded objects, I'm not
590-
certainextension modules built with different compiler toolsets
660+
share symbols among dynamically-loaded objects, I'm not certain
661+
that extension modules built with different compiler toolsets
591662
will always use different copies of the Boost.Python library
592663
when loaded into the same Python instance. Not using different
593664
libraries could be a good thing if the compilers have compatible
@@ -614,3 +685,10 @@ __ http://www.python.org/doc/current/inst/index.html
614685
615686
into a `command prompt`_ window.
616687
688+
.. [#get-debug-build] On Unix and similar platforms, a debugging
689+
python and associated libraries are built by adding
690+
``--with-pydebug`` when configuring the Python build. On
691+
Windows, the debugging version of Python is generated by
692+
the "Win32 Debug" target of the Visual Studio project in the
693+
PCBuild subdirectory of a full Python source code distribution.
694+
You may also find

example/Attic/project.zip

-1.43 KB
Binary file not shown.

example/Jamfile.v2

Lines changed: 0 additions & 36 deletions
This file was deleted.

example/Jamrules

Lines changed: 0 additions & 36 deletions
This file was deleted.

example/quickstart/Jamroot

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright David Abrahams 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+
5+
# Specify the path to the Boost project. If you move this project,
6+
# adjust the path to refer to the Boost root directory.
7+
use-project boost
8+
: ../../../.. ;
9+
10+
# Set up the project-wide requirements that everything uses the
11+
# boost_python library defined in the project whose global ID is
12+
# /boost/python.
13+
project
14+
: requirements <library>/boost/python//boost_python ;
15+
16+
# Declare a Python extension called hello.
17+
python-extension extending : extending.cpp ;
18+
19+
# Declare an executable called embedding that embeds Python
20+
exe embedding : embedding.cpp /python//python ;
21+
22+
import testing ;
23+
24+
# Declare a test of the extension module
25+
testing.make-test run-pyd : extending test_extending.py : : test_ext ;
26+
27+
# Declare a test of the embedding application
28+
testing.run embedding
29+
: # any ordinary arguments
30+
: script.py # any arguments that should be treated as relative paths
31+
: # requirements
32+
: test_embed ; # name of test
33+

example/quickstart/boost-build.jam

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright David Abrahams 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+
5+
# Edit this path to point at the tools/build/v2 subdirectory of your
6+
# Boost installation. Absolute paths work, too.
7+
boost-build ../../../../tools/build/v2 ;

0 commit comments

Comments
 (0)