diff --git a/doc/building.html b/doc/building.html index c664ba61..94f39955 100644 --- a/doc/building.html +++ b/doc/building.html @@ -18,28 +18,35 @@
-

1   Requirements

-

Boost.Python requires Python 2.21 or newer.

+

1   Requirements

+

Boost.Python requires Python 2.21 or newer.

-

2   Background

+

2   Background

There are two basic models for combining C++ and Python:

-

3   Getting Boost.Python Binaries

+

3   Getting Boost.Python Binaries

Since Boost.Python is a separately-compiled (as opposed to header-only) library, its user relies on the services of a -Boost.Python library binary. The Boost Getting Started Guide -will walk you through the steps of installing one. If building -binaries from source, you might want to supply the ---with-python argument to bjam (or the ---with-libraries=python argument to configure), so only the -Boost.Python binary will be built, rather than all the Boost -binaries.

+Boost.Python library binary.

+
+

3.1   No-Install Quickstart

+

If you just want to get started quickly building and testing +Boost.Python extension modules, or embedding Python in an +executable, you don't need to worry about installing Boost.Python +binaries explicitly. These instructions use Boost.Build projects, +which will build those binaries as soon as they're needed. Your +first tests may take a little longer while you wait for +Boost.Python to build, but doing things this way will save you from +worrying about build intricacies like which library binaries to use +for a specific compiler configuration.

Note

Of course it's possible to use other build systems to @@ -84,67 +96,36 @@ Boost.Python” problems come from trying to use another build system.

If you want to use another system anyway, we suggest that you follow these instructions, and then invoke bjam with the --ofilename option to dump the build commands it executes +-a -ofilename option to dump the build commands it executes to a file, so you can see what your build system needs to do.

-

4   Choosing a Boost.Python Library Binary

-

The Boost.Python binary comes in both static and dynamic flavors. -Take care to choose the right flavor for your -application.2

-
-

4.1   The Dynamic Binary

-

The dynamic library is the safest and most-versatile choice:

-
    -
  • A single copy of the library code is used by all extension -modules built with a given toolset.3
  • -
  • The library contains a type conversion registry. Because one -registry is shared among all extension modules, instances of a -class exposed to Python in one dynamically-loaded extension -module can be passed to functions exposed in another such module.
  • -
-
-
-

4.2   The Static Binary

-

It might be appropriate to use the static Boost.Python library in -any of the following cases:

-
    -
  • You are extending python and the types exposed in your -dynamically-loaded extension module don't need to be used by any -other Boost.Python extension modules, and you don't care if the -core library code is duplicated among them.
  • -
  • You are embedding python in your application and either:
      -
    • You are targeting a Unix variant OS other than MacOS or AIX, -where the dynamically-loaded extension modules can “see” the -Boost.Python library symbols that are part of the executable.
    • -
    • Or, you have statically linked some Boost.Python extension -modules into your application and you don't care if any -dynamically-loaded Boost.Python extension modules are able to -use the types exposed by your statically-linked extension -modules (and vice-versa).
    • -
    -
  • -
+

3.2   Installing Boost.Python on your System

+

If you need a regular, installation of the Boost.Python library +binaries on your system, the Boost Getting Started Guide will +walk you through the steps of installing one. If building binaries +from source, you might want to supply the --with-python +argument to bjam (or the --with-libraries=python argument +to configure), so only the Boost.Python binary will be built, +rather than all the Boost binaries.

-

5   Configuring Boost.Build

+

4   Configuring Boost.Build

As described in the Boost.Build reference manual, a file called user-config.jam in your home -directory7 is used to +directory7 is used to describe the build resources available to the build system. You'll need to tell it about your Python installation.

Users of Unix-Variant OSes

If you are using a unix-variant OS and you ran Boost's configure script, it may have generated a -user-config.jam for you.4 If your configure/make sequence was successful and Boost.Python binaries +user-config.jam for you.4 If your configure/make sequence was successful and Boost.Python binaries were built, your user-config.jam file is probably already correct.

-
-

5.1   The Basics

If you have a fairly “standard” python installation for your platform, there's very little you need to do to describe it. Simply having

@@ -152,15 +133,31 @@ Simply having

import toolset : using ; using python ; -

in a user-config.jam file in your home directory7 -should be enough.6

+

in a user-config.jam file in your home directory7 +should be enough.6 For more complicated setups, +see Advanced Configuration.

+
+

Note

+

You might want to pass the --debug-configuration +option to bjam the first few times you invoke it, to make +sure that Boost.Build is correctly locating all the parts of +your Python installation. If it isn't, consider passing some of +the optional Python configuration parameters detailed below.

+
-

5.2   Advanced Configuration

-

On the other hand, if you have several versions of Python -installed, or Python is installed in an unusual way, you may want -to supply any or all of the following optional parameters to -using python:

+

5   Building an Extension Module

+
+ +
+

7   Advanced Configuration

+

If you have several versions of Python installed, or Python is +installed in an unusual way, you may want to supply any or all of +the following optional parameters to using python.

+
+

7.1   Python Configuration Parameters

version
the version of Python to use. Should be in Major.Minor @@ -194,7 +191,7 @@ distribution (Ubuntu Feisty Fawn) has a specially configured
-

5.3   Advanced Configuration Examples

+

7.2   Examples

Note that in the examples below, case and especially whitespace are significant.

    @@ -244,7 +241,7 @@ using python ; using python : : c:\\cygwin\\bin\\python2.5 : : : <target-os>cygwin ;

    when you put target-os=cygwin in your build request, it should build -with the cygwin version of python:5

    +with the cygwin version of python:5

    bjam target-os=cygwin toolset=gcc

    @@ -270,11 +267,66 @@ bjam target-os=cygwin/python=2.4
+
+
+
+

8   Choosing a Boost.Python Library Binary

+

If—instead of letting Boost.Build construct and link withthe right +libraries automatically—you choose to use a pre-built Boost.Python +library, you'll need to think about which one to link with. The +Boost.Python binary comes in both static and dynamic flavors. Take +care to choose the right flavor for your application.2

+
+

8.1   The Dynamic Binary

+

The dynamic library is the safest and most-versatile choice:

+
    +
  • A single copy of the library code is used by all extension +modules built with a given toolset.3
  • +
  • The library contains a type conversion registry. Because one +registry is shared among all extension modules, instances of a +class exposed to Python in one dynamically-loaded extension +module can be passed to functions exposed in another such module.
  • +
+
+
+

8.2   The Static Binary

+

It might be appropriate to use the static Boost.Python library in +any of the following cases:

+
    +
  • You are extending python and the types exposed in your +dynamically-loaded extension module don't need to be used by any +other Boost.Python extension modules, and you don't care if the +core library code is duplicated among them.
  • +
  • You are embedding python in your application and either:
      +
    • You are targeting a Unix variant OS other than MacOS or AIX, +where the dynamically-loaded extension modules can “see” the +Boost.Python library symbols that are part of the executable.
    • +
    • Or, you have statically linked some Boost.Python extension +modules into your application and you don't care if any +dynamically-loaded Boost.Python extension modules are able to +use the types exposed by your statically-linked extension +modules (and vice-versa).
    • +
    +
  • +
+
+
+
+

9   Notes for MinGW (and Cygwin with -mno-cygwin) GCC Users

+

If you are using a version of Python prior to 2.4.1 with a MinGW +prior to 3.0.0 (with binutils-2.13.90-20030111-1), you will need to +create a MinGW-compatible version of the Python library; the one +shipped with Python will only work with a Microsoft-compatible +linker. Follow the instructions in the “Non-Microsoft” section of +the “Building Extensions: Tips And Tricks” chapter in Installing +Python Modules to create libpythonXX.a, where XX +corresponds to the major and minor version numbers of your Python +installation.


- +
-
[1]Note that although we tested earlier versions of +
[1]Note that although we tested earlier versions of Boost.Python with Python 2.2, and we don't think we've done anything to break compatibility, this release of Boost.Python may not have been tested with versions of Python earlier than @@ -285,7 +337,7 @@ supported.
-
[2]

Information about how to identify the +

[2]

Information about how to identify the static and dynamic builds of Boost.Python:

  • on Windows
  • @@ -300,7 +352,7 @@ that feature.

    -
    [3]Because of the way most *nix platforms +
    [3]Because of the way most *nix platforms share symbols among dynamically-loaded objects, I'm not certainextension modules built with different compiler toolsets will always use different copies of the Boost.Python library @@ -317,7 +369,7 @@ happens.
    - @@ -325,7 +377,7 @@ happens.
    [4]configure overwrites the existing +
    [4]configure overwrites the existing user-config.jam in your home directory (if any) after making a backup of the old version.
    - @@ -334,14 +386,14 @@ have a MinGW GCC installed.
    [5]Note that the <target-os>cygwin feature is +
    [5]Note that the <target-os>cygwin feature is different from the <flavor>cygwin subfeature of the gcc toolset, and you might need handle both explicitly if you also have a MinGW GCC installed.
    -
    [6]Create the user-config.jam file if you don't +
    [6]Create the user-config.jam file if you don't already have one.
    -
    [7](1, 2)

    Windows users, your home directory can be +

    [7](1, 2)

    Windows users, your home directory can be found by typing:

     ECHO %HOMEDRIVE%%HOMEPATH%
    @@ -352,11 +404,10 @@ ECHO %HOMEDRIVE%%HOMEPATH%
     
    - diff --git a/doc/building.rst b/doc/building.rst index 9ee245f8..7e93c338 100644 --- a/doc/building.rst +++ b/doc/building.rst @@ -70,15 +70,22 @@ Getting Boost.Python Binaries Since Boost.Python is a separately-compiled (as opposed to `header-only`_) library, its user relies on the services of a -Boost.Python library binary. The Boost `Getting Started Guide`_ -will walk you through the steps of installing one. If building -binaries from source, you might want to supply the -``--with-python`` argument to ``bjam`` (or the -``--with-libraries=python`` argument to ``configure``), so only the -Boost.Python binary will be built, rather than all the Boost -binaries. +Boost.Python library binary. -.. _`Getting Started Guide`: ../../../more/getting_started/index.html +.. _header-only: ../../../more/getting_started/windows.html#header-only-libraries + +No-Install Quickstart +--------------------- + +If you just want to get started quickly building and testing +Boost.Python extension modules, or embedding Python in an +executable, you don't need to worry about installing Boost.Python +binaries explicitly. These instructions use Boost.Build_ projects, +which will build those binaries as soon as they're needed. Your +first tests may take a little longer while you wait for +Boost.Python to build, but doing things this way will save you from +worrying about build intricacies like which library binaries to use +for a specific compiler configuration. .. Note:: Of course it's possible to use other build systems to build Boost.Python and its extensions, but they are not @@ -88,53 +95,23 @@ binaries. If you want to use another system anyway, we suggest that you follow these instructions, and then invoke ``bjam`` with the - ``-o``\ *filename* option to dump the build commands it executes + ``-a -o``\ *filename* option to dump the build commands it executes to a file, so you can see what your build system needs to do. -Choosing a Boost.Python Library Binary -====================================== +.. _Boost.Build: ../../../tools/build -The Boost.Python binary comes in both static and dynamic flavors. -Take care to choose the right flavor for your -application. [#naming]_ +Installing Boost.Python on your System +-------------------------------------- -The Dynamic Binary ------------------- +If you need a regular, installation of the Boost.Python library +binaries on your system, the Boost `Getting Started Guide`_ will +walk you through the steps of installing one. If building binaries +from source, you might want to supply the ``--with-python`` +argument to ``bjam`` (or the ``--with-libraries=python`` argument +to ``configure``), so only the Boost.Python binary will be built, +rather than all the Boost binaries. -The dynamic library is the safest and most-versatile choice: - -- A single copy of the library code is used by all extension - modules built with a given toolset. [#toolset-specific]_ - -- The library contains a type conversion registry. Because one - registry is shared among all extension modules, instances of a - class exposed to Python in one dynamically-loaded extension - module can be passed to functions exposed in another such module. - -The Static Binary ------------------ - -It might be appropriate to use the static Boost.Python library in -any of the following cases: - -- You are extending_ python and the types exposed in your - dynamically-loaded extension module don't need to be used by any - other Boost.Python extension modules, and you don't care if the - core library code is duplicated among them. - -- You are embedding_ python in your application and either: - - - You are targeting a Unix variant OS other than MacOS or AIX, - where the dynamically-loaded extension modules can “see” the - Boost.Python library symbols that are part of the executable. - - - Or, you have statically linked some Boost.Python extension - modules into your application and you don't care if any - dynamically-loaded Boost.Python extension modules are able to - use the types exposed by your statically-linked extension - modules (and vice-versa). - -.. _header-only: ../../../more/getting_started/windows.html#header-only-libraries +.. _`Getting Started Guide`: ../../../more/getting_started/index.html Configuring Boost.Build ======================= @@ -156,9 +133,6 @@ __ http://www.boost.orgdoc/html/bbv2/advanced.html#bbv2.advanced.configuration were built, your ``user-config.jam`` file is probably already correct. -The Basics ----------- - If you have a fairly “standard” python installation for your platform, there's very little you need to do to describe it. Simply having :: @@ -168,15 +142,32 @@ Simply having :: using python ; in a ``user-config.jam`` file in your home directory [#home-dir]_ -should be enough. [#user-config.jam]_ +should be enough. [#user-config.jam]_ For more complicated setups, +see `Advanced Configuration`_. + +.. Note:: You might want to pass the ``--debug-configuration`` + option to ``bjam`` the first few times you invoke it, to make + sure that Boost.Build is correctly locating all the parts of + your Python installation. If it isn't, consider passing some of + the optional `Python configuration parameters`_ detailed below. + +Building an Extension Module +============================ + + +Testing +======= + Advanced Configuration ----------------------- +====================== -On the other hand, if you have several versions of Python -installed, or Python is installed in an unusual way, you may want -to supply any or all of the following optional parameters to -``using python``: +If you have several versions of Python installed, or Python is +installed in an unusual way, you may want to supply any or all of +the following optional parameters to ``using python``. + +Python Configuration Parameters +------------------------------- version the version of Python to use. Should be in Major.Minor @@ -215,8 +206,9 @@ extension-suffix __ https://wiki.ubuntu.com/PyDbgBuilds -Advanced Configuration Examples -------------------------------- + +Examples +-------- Note that in the examples below, case and *especially whitespace* are significant. @@ -293,6 +285,66 @@ significant. __ http://zigzag.cs.msu.su/boost.build/wiki/AlternativeSelection +Choosing a Boost.Python Library Binary +====================================== + +If—instead of letting Boost.Build construct and link withthe right +libraries automatically—you choose to use a pre-built Boost.Python +library, you'll need to think about which one to link with. The +Boost.Python binary comes in both static and dynamic flavors. Take +care to choose the right flavor for your application. [#naming]_ + +The Dynamic Binary +------------------ + +The dynamic library is the safest and most-versatile choice: + +- A single copy of the library code is used by all extension + modules built with a given toolset. [#toolset-specific]_ + +- The library contains a type conversion registry. Because one + registry is shared among all extension modules, instances of a + class exposed to Python in one dynamically-loaded extension + module can be passed to functions exposed in another such module. + +The Static Binary +----------------- + +It might be appropriate to use the static Boost.Python library in +any of the following cases: + +- You are extending_ python and the types exposed in your + dynamically-loaded extension module don't need to be used by any + other Boost.Python extension modules, and you don't care if the + core library code is duplicated among them. + +- You are embedding_ python in your application and either: + + - You are targeting a Unix variant OS other than MacOS or AIX, + where the dynamically-loaded extension modules can “see” the + Boost.Python library symbols that are part of the executable. + + - Or, you have statically linked some Boost.Python extension + modules into your application and you don't care if any + dynamically-loaded Boost.Python extension modules are able to + use the types exposed by your statically-linked extension + modules (and vice-versa). + +Notes for MinGW (and Cygwin with -mno-cygwin) GCC Users +======================================================= + +If you are using a version of Python prior to 2.4.1 with a MinGW +prior to 3.0.0 (with binutils-2.13.90-20030111-1), you will need to +create a MinGW-compatible version of the Python library; the one +shipped with Python will only work with a Microsoft-compatible +linker. Follow the instructions in the “Non-Microsoft” section of +the “Building Extensions: Tips And Tricks” chapter in `Installing +Python Modules`__ to create ``libpythonXX.a``, where ``XX`` +corresponds to the major and minor version numbers of your Python +installation. + +__ http://www.python.org/doc/current/inst/index.html + ----------------------------- .. [#2.2] Note that although we tested earlier versions of