|
Boost.PythonBuilding and Testing |
すべての Boost.Python 拡張モジュールは boost_python
共有ライブラリとリンクしなければならない。
boost_python
をビルドするには
通常 boost をインストールしたディレクトリ配下の
libs/python/build
から
Boost.Build
を使用しなさい。
(もしすでに boost をトップレベルからビルドしているなら、
仕事は終わっているので、これは効果がない)
Variable Name | Semantics | Default | Notes |
---|---|---|---|
PYTHON_ROOT |
The root directory of your Python installation | Windows: c:/tools/python
Unix: /usr/local |
On Unix, this is the --with-prefix= directory used
to configure Python |
PYTHON_VERSION |
The The 2-part python Major.Minor version number | 2.2 |
Be sure not to include a third number, e.g. not
"2.2.1 ", even if that's the version you have. |
PYTHON_INCLUDES |
path to Python #include directories |
Autoconfigured from PYTHON_ROOT |
|
PYTHON_LIB_PATH |
path to Python library object. | Autoconfigured from PYTHON_ROOT |
|
PYTHON_STDLIB_PATH |
path to Python standard library modules | Autoconfigured from PYTHON_ROOT |
|
CYGWIN_ROOT |
path to the user's Cygwin installation | Cygwin only. This and the following two settings are useful when building with multiple toolsets on Windows, since Cygwin requires a different build of Python. | |
GCC_PYTHON_ROOT |
path to the user's Cygwin Python installation | $(CYGWIN_ROOT)/usr/local |
Cygwin only |
GCC_DEBUG_PYTHON_ROOT |
path to the user's Cygwin pydebug build |
$(CYGWIN_ROOT)/usr/local/pydebug |
Cygwin only |
ビルドすると libs/python/build/bin-stage
が boost root
あるいは $(ALL_LOCATE_TARGET)
で指定したサブディレクトリに作成される。
ライブラリは各々のツール毎にユニークなディレクトリに作成され、
変化するものはファイルシステムのどこかに作成される。
そして便利なものは bin-stage
ディレクトリにコピーされる。
そのため複数のツールセットを一回でビルドすると、
後のツールセット・プロジェクトがそれより前の bin-stage
にあるツールセットを上書きする。
Boost.Python をビルドしテストするには libs/python/test
ディレクトリから始める。そして呼び出す。
これは Boost.Python version 1 のテストと例題をすべてアップデートする。 テストはデフォルトでは比較的情報が少ない。 より多くの情報を得るには、これを試しなさい。bjam -sTOOLS=toolset test
これは各々のテスト毎に Python のコードを出力し、テストが通った時に期待される出力がなされる。bjam -sTOOLS=toolset -sPYTHON_TEST_ARGS=-v test
libs/python/example
は最低限の例題を含んでいる(多くの特別なソースと供に)。
サブプロジェクトの例題をコピーするには、
libs/python
の中に libs/python/my_project
というサブディレクトリを作る。libs/python/example/Jamfile
をその新しいディレクトリにコピーする。subproject
"
ルール呼び出しを最上位にするとか、ソースやターゲットの名称変更をしたいだろう。このアーカイブ
が役立つ。
Jamfile と Jamrules ファイルを修正する必要があるだろう。
それらは Boost のインストール設定と新しいプロジェクトの相対位置に依存する。
拡張モジュールの自動テストはこの設定手段では利用できないことに注意しなさい。
ビルド
変数の設定により選択できる。
release
(optimization, -DNDEBUG)debug
(no optimization -D_DEBUG)debug-python
(no optimization, -D_DEBUG
-DBOOST_DEBUG_PYTHON)
boost_python
ライブラリの最初の二つの variant はデフォルトでビルドされる。
そしてデフォルトの Python 配布と互換である。
debug-python
variant は Python デバッグバージョンの特別なビルドに一致する。
Unix プラットフォーム上では、Python をビルドする時に configure 設定で --with-pydebug
を付け加えることにより、この python (デバッグ版)がビルドされる。
Windows 上では、Python 配布のサブディレクトリ PCBuild
の中にある
Visual C++ 6.0 プロジェクト PCBuild.dsw
のターゲットを
"Win32 Debug" にすることでデバッギング版 Python を作成できる。
拡張モジュールを Python デバッギング可能ビルドしたものは、非デバッグビルド Python
にリンクレベルで 非互換 である。
Python を実際にデバッグビルドする人は少ないので(それは標準の配布には入っていない)。
標準 debug
形式は普通の Python に互換のモジュールをビルドする。
多くの Windws コンパイラで、拡張モジュールが -D_DEBUG 付きでビルドされた場合
Python はスペシャルデバッグ版 Python DLL としいてリンクすることはない。
Python をデフォルトで Windows にインストールした場合、このデバッグ DLLは供給されない。
そのため、BOOST_DEBUG_PYTHON
を定義しないで Python.h をインクルードする場合
Boost.Python は一時的に _DEBUG を未定義にし、
boost/python/detail/wrap_python.hpp
を使用する。
もしデバッグ版ライブラリを使用して、特別実行時チェックを利用したい場合、Python
デバッグを再度可能にするため #define BOOST_DEBUG_PYTHON を定義し、boost_python
の debug-python
形式とリンクしなさい。
もし #define BOOST_DEBUG_PYTHON を定義しない場合、
拡張モジュールの中のどのソースファイルも通常の Python.h の代わりに
#include <boost/python/detail/wrap_python.hpp>
をインクルードしていることを確認しなさい。
さもないと、リンク非互換になるだろう。
© Copyright David Abrahams 2002. Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided ``as is'' without express or implied warranty, and with no claim as to its suitability for any purpose.
Updated: O8 October, 2002 (David Abrahams)