mirror of
https://github.com/boostorg/python.git
synced 2026-01-19 16:32:16 +00:00
Compare commits
1 Commits
boost-1.25
...
boost-1.24
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0bb719356b |
136
build/Jamfile
136
build/Jamfile
@@ -5,16 +5,13 @@
|
||||
#
|
||||
# Boost.Python build and test Jamfile
|
||||
#
|
||||
# To run all tests quietly: jam test
|
||||
# To run all tests with verbose output: jam -sPYTHON_TEST_ARGS=-v test
|
||||
#
|
||||
# Declares the following targets:
|
||||
# 1. libboost_python, a static link library to be linked with all
|
||||
# Boost.Python modules
|
||||
#
|
||||
# 2. pairs of test targets of the form <name>.test and <name>.run
|
||||
# <name>.test runs the test when it is out-of-date, and the "test"
|
||||
# pseudotarget depends on it. <name>.run runs
|
||||
# <name>.test runs the test when it is out-of-date, and the "all" target
|
||||
# depends on it so that it it is built by default. <name>.run runs
|
||||
# a test unconditionally, and can be used to force a test to run.. Each
|
||||
# test target builds one or more Boost.Python modules and runs a Python
|
||||
# script to test them. The test names are:
|
||||
@@ -41,12 +38,6 @@
|
||||
#
|
||||
# subproject-specific environment/command-line variables:
|
||||
#
|
||||
# PYTHON - How to invoke the Python interpreter. Defaults to "python"
|
||||
#
|
||||
# PYTHON_ROOT - Windows only: where Python is installed. Defaults to "c:/tools/python"
|
||||
#
|
||||
# PYTHON_VERSION - Version of Python. Defaults to "2.1" on Windows, "1.5" on Unix
|
||||
#
|
||||
# PYTHON_TEST_ARGS - specifies arguments to be passed to test scripts on
|
||||
# the command line. "-v" can be useful if you want to
|
||||
# see the output of successful tests.
|
||||
@@ -58,21 +49,12 @@
|
||||
# declare the location of this subproject relative to the root
|
||||
subproject libs/python/build ;
|
||||
|
||||
# grab variables from command-line or environment.
|
||||
local PYTHON_VERSION = $(PYTHON_VERSION) ;
|
||||
local PYTHON_ROOT = $(PYTHON_ROOT) ;
|
||||
local PYTHON_INCLUDES = $(PYTHON_INCLUDES) ;
|
||||
local PYTHON_LIBS = $(PYTHON_LIBS) ;
|
||||
local PYTHON_LIB_PATH = $(PYTHON_LIB_PATH) ;
|
||||
local PYTHON_PROPERTIES = $(PYTHON_PROPERTIES) ;
|
||||
|
||||
# Do some OS-specific setup
|
||||
if $(NT)
|
||||
{
|
||||
PYTHON_VERSION ?= 2.1 ;
|
||||
PYTHON_ROOT ?= c:/tools/python ;
|
||||
PYTHON_INCLUDES ?= <include>$(PYTHON_ROOT)/include <gcc><*><include>/usr/include/python$(PYTHON_VERSION) ;
|
||||
PYTHON_LIBS ?= c:/cygnus/lib/python$(PYTHON_VERSION)/config/libpython$(PYTHON_VERSION).dll.a ;
|
||||
PYTHON_INCLUDES ?= <include>$(PYTHON_ROOT)/include <gcc><*><include>/usr/include/python2.1 ;
|
||||
PYTHON_LIBS ?= c:/cygnus/lib/python2.1/config/libpython2.1.dll.a ;
|
||||
PYTHON_LIB_PATH = $(PYTHON_ROOT)/libs ;
|
||||
|
||||
# common properties required for compiling any Python module.
|
||||
@@ -82,20 +64,17 @@ if $(NT)
|
||||
<runtime-link>dynamic
|
||||
;
|
||||
|
||||
SHELL_SET ?= "set " ;
|
||||
SHELL_EXPORT ?= ; # shell variables are exported by default
|
||||
}
|
||||
else if $(UNIX)
|
||||
{
|
||||
PYTHON_VERSION ?= 1.5 ;
|
||||
PYTHON_INCLUDES ?= <include>/usr/include/python$(PYTHON_VERSION) ;
|
||||
PYTHON_LIBS ?= /usr/lib/python$(PYTHON_VERSION)/config/libpython$(PYTHON_VERSION).a ;
|
||||
PYTHON_INCLUDES ?= <include>/usr/include/python1.5 ;
|
||||
PYTHON_LIBS ?= /usr/lib/python1.5/config/libpython1.5.a ;
|
||||
SHELL_SET ?= "" ;
|
||||
SHELL_EXPORT ?= "export " ;
|
||||
}
|
||||
|
||||
# how do we invoke python?
|
||||
local PYTHON = $(PYTHON) ;
|
||||
PYTHON ?= python ;
|
||||
PYTHON = [ FAppendSuffix $(PYTHON:G=<executable-grist>) : $(SUFEXE) ] ;
|
||||
SEARCH on $(PYTHON) = $(PATH) ;
|
||||
|
||||
#######################
|
||||
|
||||
#
|
||||
@@ -103,10 +82,10 @@ SEARCH on $(PYTHON) = $(PATH) ;
|
||||
#
|
||||
|
||||
# standard include requirements for anything using Boost.Python
|
||||
local BOOST_PYTHON_INCLUDES = <include>$(BOOST_ROOT) $(PYTHON_INCLUDES) ;
|
||||
BOOST_PYTHON_INCLUDES = <include>$(BOOST_ROOT) $(PYTHON_INCLUDES) ;
|
||||
|
||||
# Base names of the source files for libboost_python
|
||||
local CPP_SOURCES =
|
||||
CPP_SOURCES =
|
||||
classes conversions extension_class functions
|
||||
init_function module_builder objects types cross_module ;
|
||||
|
||||
@@ -138,25 +117,13 @@ rule boost-python
|
||||
: $(4) ; # pass on the default-BUILD, if any
|
||||
}
|
||||
|
||||
# boost-python-test name : sources : requirements : default-BUILD
|
||||
#
|
||||
# Just like boost-python, but the result becomes part of the test pseudotarget
|
||||
# instead of being built by 'all'
|
||||
rule boost-python-test
|
||||
{
|
||||
type-DEPENDS test : $(<) ;
|
||||
|
||||
local gSUPPRESS_FAKE_TARGETS = true ;
|
||||
boost-python $(1) : $(2) : $(3) : $(4) ;
|
||||
}
|
||||
|
||||
#######################
|
||||
|
||||
# boost-python-runtest target : python-script sources : requirements : local-build : args
|
||||
# boost-python-test target : python-script sources : requirements : local-build : args
|
||||
#
|
||||
# declare two python module tests: $(<).test which builds when out-of-date, and
|
||||
# $(<).run which builds unconditionally.
|
||||
rule boost-python-runtest
|
||||
rule boost-python-test
|
||||
{
|
||||
# tell Jam that the python script is relative to this directory
|
||||
SEARCH on $(>[1]) = $(SEARCH_SOURCE) ;
|
||||
@@ -164,25 +131,28 @@ rule boost-python-runtest
|
||||
# required command-line args can be specified in argument 5
|
||||
# The user can add additional arguments in PYTHON_TEST_ARGS.
|
||||
local gPYTHON_TEST_ARGS = $(5) $(PYTHON_TEST_ARGS) ;
|
||||
|
||||
|
||||
# declare the two subsidiary tests.
|
||||
declare-local-target $(<:S=.test) : $(>) : $(PYTHON_PROPERTIES) : $(4) : PYTHON_TEST ;
|
||||
declare-local-target $(<:S=.run) : $(>) : $(PYTHON_PROPERTIES) : $(4) : PYTHON_RUNTEST ;
|
||||
}
|
||||
|
||||
# how do we invoke python?
|
||||
PYTHON ?= python ;
|
||||
|
||||
# special rules for two new target types: PYTHON_TEST and PYTHON_RUNTEST.
|
||||
# These are identical except that PYTHON_TEST runs the test when out-of-date, and
|
||||
# PYTHON_RUNTEST runs the test unconditionally. These are used by boost-python-runtest.
|
||||
# PYTHON_RUNTEST runs the test unconditionally. These are used by boost-python-test.
|
||||
SUFPYTHON_TEST = .test ;
|
||||
gGENERATOR_FUNCTION(PYTHON_TEST) = python-test-target ;
|
||||
rule python-test-target # test-target : sources :
|
||||
{
|
||||
python-runtest-aux $(<) : $(>) ;
|
||||
python-test-aux $(<) : $(>) ;
|
||||
Clean clean : $(<) ; # remove the test-target as part of any clean operation
|
||||
type-DEPENDS test : $(<) ;
|
||||
MakeLocate $(<) : $(LOCATE_TARGET) ;
|
||||
}
|
||||
actions python-test-target bind PYTHON
|
||||
actions python-test-target
|
||||
{
|
||||
$(SHELL_SET)PYTHONPATH=$(PYTHONPATH)
|
||||
$(SHELL_EXPORT)PYTHONPATH
|
||||
@@ -193,18 +163,18 @@ SUFPYTHON_RUNTEST = .run ;
|
||||
gGENERATOR_FUNCTION(PYTHON_RUNTEST) = python-runtest-target ;
|
||||
rule python-runtest-target # test-target : sources :
|
||||
{
|
||||
python-runtest-aux $(<) : $(>) ;
|
||||
python-test-aux $(<) : $(>) ;
|
||||
NOTFILE $(<) ;
|
||||
ALWAYS $(<) ;
|
||||
}
|
||||
actions python-runtest-target bind PYTHON
|
||||
actions python-runtest-target
|
||||
{
|
||||
$(SHELL_SET)PYTHONPATH=$(PYTHONPATH)
|
||||
$(SHELL_EXPORT)PYTHONPATH
|
||||
$(PYTHON) "$(>)" $(ARGS)
|
||||
}
|
||||
|
||||
rule python-runtest-aux # target : sources
|
||||
rule python-test-aux # target : sources
|
||||
{
|
||||
DEPENDS $(<) : $(>) ;
|
||||
|
||||
@@ -226,60 +196,50 @@ rule python-runtest-aux # target : sources
|
||||
[ join-path $(TOP) libs python test ] # location of doctest
|
||||
$(PYTHONPATH) # base PYTHONPATH from environment
|
||||
: $(SPLITPATH) ] ; # platform path separator
|
||||
|
||||
PYTHON on $(<) = $(PYTHON) ;
|
||||
DEPENDS $(<) : $(PYTHON) ;
|
||||
}
|
||||
|
||||
############# comprehensive module and test ###########
|
||||
boost-python-test boost_python_test : ../test/comprehensive.cpp ;
|
||||
|
||||
boost-python-runtest comprehensive
|
||||
: [ join-path $(DOTDOT) test comprehensive.py ]
|
||||
<lib>boost_python_test ;
|
||||
boost-python boost_python_test : ../test/comprehensive.cpp ;
|
||||
boost-python-test comprehensive : [ join-path $(DOTDOT) test comprehensive.py ] <lib>boost_python_test ;
|
||||
|
||||
############# simple tests from ../example ############
|
||||
|
||||
rule boost-python-example-runtest
|
||||
rule boost-python-example-test
|
||||
{
|
||||
boost-python-test $(<) : ../example/$(<).cpp ;
|
||||
boost-python-runtest $(<) : [ join-path $(DOTDOT) example test_$(<).py ] <lib>$(<) ;
|
||||
boost-python $(<) : ../example/$(<).cpp ;
|
||||
boost-python-test $(<) : [ join-path $(DOTDOT) example test_$(<).py ] <lib>$(<) ;
|
||||
}
|
||||
|
||||
|
||||
boost-python-example-runtest abstract ;
|
||||
boost-python-example-runtest getting_started1 ;
|
||||
boost-python-example-runtest getting_started2 ;
|
||||
boost-python-example-runtest simple_vector ;
|
||||
boost-python-example-runtest do_it_yourself_convts ;
|
||||
boost-python-example-runtest pickle1 ;
|
||||
boost-python-example-runtest pickle2 ;
|
||||
boost-python-example-runtest pickle3 ;
|
||||
boost-python-example-test abstract ;
|
||||
boost-python-example-test getting_started1 ;
|
||||
boost-python-example-test getting_started2 ;
|
||||
boost-python-example-test simple_vector ;
|
||||
boost-python-example-test do_it_yourself_convts ;
|
||||
boost-python-example-test pickle1 ;
|
||||
boost-python-example-test pickle2 ;
|
||||
boost-python-example-test pickle3 ;
|
||||
|
||||
|
||||
boost-python-test ivect : ../example/ivect.cpp ;
|
||||
boost-python-test dvect : ../example/dvect.cpp ;
|
||||
boost-python-test noncopyable_export : ../example/noncopyable_export.cpp ;
|
||||
boost-python-test noncopyable_import : ../example/noncopyable_import.cpp ;
|
||||
boost-python ivect : ../example/ivect.cpp ;
|
||||
boost-python dvect : ../example/dvect.cpp ;
|
||||
boost-python noncopyable_export : ../example/noncopyable_export.cpp ;
|
||||
boost-python noncopyable_import : ../example/noncopyable_import.cpp ;
|
||||
|
||||
############## cross-module tests from ../example ##########
|
||||
|
||||
# A simple rule to build a test which depends on multiple modules in the PYTHONPATH
|
||||
rule boost-python-multi-example-runtest # test-name : python-file libs
|
||||
rule boost-python-multi-example-test # test-name : python-file libs
|
||||
{
|
||||
boost-python-runtest $(<)
|
||||
: ../example/tst_$(<).py <lib>$(>)
|
||||
: : : $(PYTHON_VECT_ITERATIONS) ;
|
||||
boost-python-test $(<) : ../example/tst_$(<).py <lib>$(>) : : : $(PYTHON_VECT_ITERATIONS) ;
|
||||
}
|
||||
|
||||
PYTHON_VECT_ITERATIONS ?= 10 ;
|
||||
|
||||
boost-python-multi-example-runtest dvect1 : ivect dvect ;
|
||||
boost-python-multi-example-runtest dvect2 : ivect dvect ;
|
||||
boost-python-multi-example-test dvect1 : ivect dvect ;
|
||||
boost-python-multi-example-test dvect2 : ivect dvect ;
|
||||
|
||||
boost-python-multi-example-runtest ivect1 : ivect dvect ;
|
||||
boost-python-multi-example-runtest ivect2 : ivect dvect ;
|
||||
boost-python-multi-example-test ivect1 : ivect dvect ;
|
||||
boost-python-multi-example-test ivect2 : ivect dvect ;
|
||||
|
||||
boost-python-multi-example-runtest
|
||||
noncopyable : noncopyable_import noncopyable_export ;
|
||||
boost-python-multi-example-test noncopyable : noncopyable_import noncopyable_export ;
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ bpl_exa + "/getting_started1.cpp",
|
||||
bpl_exa + "/getting_started2.cpp",
|
||||
bpl_exa + "/simple_vector.cpp",
|
||||
bpl_exa + "/do_it_yourself_convts.cpp",
|
||||
bpl_exa + "/nested.cpp",
|
||||
bpl_exa + "/pickle1.cpp",
|
||||
bpl_exa + "/pickle2.cpp",
|
||||
bpl_exa + "/pickle3.cpp",
|
||||
@@ -33,7 +32,6 @@ bpl_exa + "/test_getting_started1.py",
|
||||
bpl_exa + "/test_getting_started2.py",
|
||||
bpl_exa + "/test_simple_vector.py",
|
||||
bpl_exa + "/test_do_it_yourself_convts.py",
|
||||
bpl_exa + "/test_nested.py",
|
||||
bpl_exa + "/test_pickle1.py",
|
||||
bpl_exa + "/test_pickle2.py",
|
||||
bpl_exa + "/test_pickle3.py",
|
||||
@@ -70,7 +68,6 @@ defs = (
|
||||
"getting_started2",
|
||||
"simple_vector",
|
||||
"do_it_yourself_convts",
|
||||
"nested",
|
||||
"pickle1",
|
||||
"pickle2",
|
||||
"pickle3",
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
ROOT=$(HOME)
|
||||
BOOST=$(ROOT)/boost
|
||||
|
||||
PYEXE=PYTHONPATH=. /usr/local/Python-1.5.2/bin/python
|
||||
PYEXE=/usr/local/Python-1.5.2/bin/python
|
||||
PYINC=-I/usr/local/Python-1.5.2/include/python1.5
|
||||
#PYEXE=PYTHONPATH=. /usr/local/Python-2.1/bin/python
|
||||
#PYEXE=/usr/local/Python-2.1/bin/python
|
||||
#PYINC=-I/usr/local/Python-2.1/include/python2.1
|
||||
STLPORTINC=-I$(BOOST)/boost/compatibility/cpp_c_headers
|
||||
|
||||
@@ -44,7 +44,6 @@ DEPOBJ=$(OBJ) \
|
||||
getting_started1.o getting_started2.o \
|
||||
simple_vector.o \
|
||||
do_it_yourself_convts.o \
|
||||
nested.o \
|
||||
pickle1.o pickle2.o pickle3.o \
|
||||
noncopyable_export.o noncopyable_import.o \
|
||||
ivect.o dvect.o \
|
||||
@@ -58,7 +57,6 @@ all: libboost_python.a \
|
||||
getting_started1.so getting_started2.so \
|
||||
simple_vector.so \
|
||||
do_it_yourself_convts.so \
|
||||
nested.so \
|
||||
pickle1.so pickle2.so pickle3.so \
|
||||
noncopyable_export.so noncopyable_import.so \
|
||||
ivect.so dvect.so \
|
||||
@@ -86,9 +84,6 @@ simple_vector.so: $(OBJ) simple_vector.o
|
||||
do_it_yourself_convts.so: $(OBJ) do_it_yourself_convts.o
|
||||
$(LD) $(LDOPTS) $(OBJ) do_it_yourself_convts.o -o do_it_yourself_convts.so
|
||||
|
||||
nested.so: $(OBJ) nested.o
|
||||
$(LD) $(LDOPTS) $(OBJ) nested.o -o nested.so
|
||||
|
||||
pickle1.so: $(OBJ) pickle1.o
|
||||
$(LD) $(LDOPTS) $(OBJ) pickle1.o -o pickle1.so
|
||||
|
||||
@@ -131,7 +126,6 @@ test:
|
||||
$(PYEXE) test_getting_started2.py
|
||||
$(PYEXE) test_simple_vector.py
|
||||
$(PYEXE) test_do_it_yourself_convts.py
|
||||
$(PYEXE) test_nested.py
|
||||
$(PYEXE) test_pickle1.py
|
||||
$(PYEXE) test_pickle2.py
|
||||
$(PYEXE) test_pickle3.py
|
||||
@@ -148,7 +142,6 @@ clean:
|
||||
rm -f getting_started2.o getting_started2.so
|
||||
rm -f simple_vector.o simple_vector.so
|
||||
rm -f do_it_yourself_convts.o do_it_yourself_convts.so
|
||||
rm -f nested.o nested.so
|
||||
rm -f pickle1.o pickle1.so
|
||||
rm -f pickle2.o pickle2.so
|
||||
rm -f pickle3.o pickle3.so
|
||||
|
||||
@@ -19,9 +19,9 @@ BOOST=$(ROOT)/boost
|
||||
|
||||
PYEXE=PYTHONPATH=. /usr/bin/python
|
||||
PYINC=-I/usr/include/python1.5
|
||||
#PYEXE=PYTHONPATH=. /usr/local/Python-1.5.2/bin/python
|
||||
#PYEXE=/usr/local/Python-1.5.2/bin/python
|
||||
#PYINC=-I/usr/local/Python-1.5.2/include/python1.5
|
||||
#PYEXE=PYTHONPATH=. /usr/local/Python-2.1/bin/python
|
||||
#PYEXE=/usr/local/Python-2.1/bin/python
|
||||
#PYINC=-I/usr/local/Python-2.1/include/python2.1
|
||||
|
||||
STDOPTS=-fPIC -ftemplate-depth-21
|
||||
@@ -45,7 +45,6 @@ DEPOBJ=$(OBJ) \
|
||||
getting_started1.o getting_started2.o \
|
||||
simple_vector.o \
|
||||
do_it_yourself_convts.o \
|
||||
nested.o \
|
||||
pickle1.o pickle2.o pickle3.o \
|
||||
noncopyable_export.o noncopyable_import.o \
|
||||
ivect.o dvect.o \
|
||||
@@ -59,7 +58,6 @@ all: libboost_python.a \
|
||||
getting_started1.so getting_started2.so \
|
||||
simple_vector.so \
|
||||
do_it_yourself_convts.so \
|
||||
nested.so \
|
||||
pickle1.so pickle2.so pickle3.so \
|
||||
noncopyable_export.so noncopyable_import.so \
|
||||
ivect.so dvect.so \
|
||||
@@ -87,9 +85,6 @@ simple_vector.so: $(OBJ) simple_vector.o
|
||||
do_it_yourself_convts.so: $(OBJ) do_it_yourself_convts.o
|
||||
$(LD) $(LDOPTS) $(OBJ) do_it_yourself_convts.o -o do_it_yourself_convts.so
|
||||
|
||||
nested.so: $(OBJ) nested.o
|
||||
$(LD) $(LDOPTS) $(OBJ) nested.o -o nested.so
|
||||
|
||||
pickle1.so: $(OBJ) pickle1.o
|
||||
$(LD) $(LDOPTS) $(OBJ) pickle1.o -o pickle1.so
|
||||
|
||||
@@ -132,7 +127,6 @@ test:
|
||||
$(PYEXE) test_getting_started2.py
|
||||
$(PYEXE) test_simple_vector.py
|
||||
$(PYEXE) test_do_it_yourself_convts.py
|
||||
$(PYEXE) test_nested.py
|
||||
$(PYEXE) test_pickle1.py
|
||||
$(PYEXE) test_pickle2.py
|
||||
$(PYEXE) test_pickle3.py
|
||||
@@ -149,7 +143,6 @@ clean:
|
||||
rm -f getting_started2.o getting_started2.so
|
||||
rm -f simple_vector.o simple_vector.so
|
||||
rm -f do_it_yourself_convts.o do_it_yourself_convts.so
|
||||
rm -f nested.o nested.so
|
||||
rm -f pickle1.o pickle1.so
|
||||
rm -f pickle2.o pickle2.so
|
||||
rm -f pickle3.o pickle3.so
|
||||
|
||||
@@ -30,16 +30,13 @@
|
||||
# -fvtable-thunks eliminates the compiler warning, but
|
||||
# "import boost_python_test" still causes a crash.
|
||||
|
||||
ROOT=R:
|
||||
ROOT=L:
|
||||
BOOST_WIN="$(ROOT)\boost"
|
||||
BOOST_UNIX=$(HOME)/boost
|
||||
|
||||
PYEXE="C:\Program files\Python\python.exe"
|
||||
PYINC=-I"C:\usr\include\python1.5"
|
||||
PYLIB="C:\usr\lib\libpython15.a"
|
||||
#PYEXE="C:\Python21\python.exe"
|
||||
#PYINC=-I"C:\usr\include\python2.1"
|
||||
#PYLIB="C:\usr\lib\libpython21.a"
|
||||
|
||||
STDOPTS=-ftemplate-depth-21
|
||||
WARNOPTS=
|
||||
@@ -63,7 +60,6 @@ all: libboost_python.a \
|
||||
getting_started1.pyd getting_started2.pyd \
|
||||
simple_vector.pyd \
|
||||
do_it_yourself_convts.pyd \
|
||||
nested.pyd \
|
||||
pickle1.pyd pickle2.pyd pickle3.pyd \
|
||||
noncopyable_export.pyd noncopyable_import.pyd \
|
||||
ivect.pyd dvect.pyd \
|
||||
@@ -112,12 +108,6 @@ do_it_yourself_convts.pyd: $(OBJ) do_it_yourself_convts.o
|
||||
--def do_it_yourself_convts.def \
|
||||
$(OBJ) do_it_yourself_convts.o $(PYLIB)
|
||||
|
||||
nested.pyd: $(OBJ) nested.o
|
||||
dllwrap $(DLLWRAPOPTS) \
|
||||
--dllname nested.pyd \
|
||||
--def nested.def \
|
||||
$(OBJ) nested.o $(PYLIB)
|
||||
|
||||
pickle1.pyd: $(OBJ) pickle1.o
|
||||
dllwrap $(DLLWRAPOPTS) \
|
||||
--dllname pickle1.pyd \
|
||||
@@ -188,7 +178,6 @@ test:
|
||||
$(PYEXE) test_getting_started2.py
|
||||
$(PYEXE) test_simple_vector.py
|
||||
$(PYEXE) test_do_it_yourself_convts.py
|
||||
$(PYEXE) test_nested.py
|
||||
$(PYEXE) test_pickle1.py
|
||||
$(PYEXE) test_pickle2.py
|
||||
$(PYEXE) test_pickle3.py
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
ROOT=$(HOME)
|
||||
BOOST=$(ROOT)/boost
|
||||
|
||||
PYEXE=PYTHONPATH=. /usr/local/Python-1.5.2/bin/python
|
||||
PYEXE=/usr/local/Python-1.5.2/bin/python
|
||||
PYINC=-I/usr/local/Python-1.5.2/include/python1.5
|
||||
#PYEXE=PYTHONPATH=. /usr/local/Python-2.1/bin/python
|
||||
#PYEXE=/usr/local/Python-2.1/bin/python
|
||||
#PYINC=-I/usr/local/Python-2.1/include/python2.1
|
||||
#STLPORTINC=-I/usr/local/STLport-4.1b3/stlport
|
||||
#STLPORTINC=-I/usr/local/STLport-4.1b4/stlport
|
||||
@@ -55,7 +55,6 @@ DEPOBJ=$(OBJ) \
|
||||
getting_started1.o getting_started2.o \
|
||||
simple_vector.o \
|
||||
do_it_yourself_convts.o \
|
||||
nested.o \
|
||||
pickle1.o pickle2.o pickle3.o \
|
||||
noncopyable_export.o noncopyable_import.o \
|
||||
ivect.o dvect.o \
|
||||
@@ -69,7 +68,6 @@ all: libboost_python.a \
|
||||
getting_started1.so getting_started2.so \
|
||||
simple_vector.so \
|
||||
do_it_yourself_convts.so \
|
||||
nested.so \
|
||||
pickle1.so pickle2.so pickle3.so \
|
||||
noncopyable_export.so noncopyable_import.so \
|
||||
ivect.so dvect.so \
|
||||
@@ -101,9 +99,6 @@ simple_vector.so: $(OBJ) simple_vector.o
|
||||
do_it_yourself_convts.so: $(OBJ) do_it_yourself_convts.o
|
||||
$(LD) $(LDOPTS) $(OBJ) do_it_yourself_convts.o -o do_it_yourself_convts.so
|
||||
|
||||
nested.so: $(OBJ) nested.o
|
||||
$(LD) $(LDOPTS) $(OBJ) nested.o -o nested.so
|
||||
|
||||
pickle1.so: $(OBJ) pickle1.o
|
||||
$(LD) $(LDOPTS) $(OBJ) pickle1.o -o pickle1.so
|
||||
|
||||
@@ -146,7 +141,6 @@ test:
|
||||
$(PYEXE) test_getting_started2.py
|
||||
$(PYEXE) test_simple_vector.py
|
||||
$(PYEXE) test_do_it_yourself_convts.py
|
||||
$(PYEXE) test_nested.py
|
||||
$(PYEXE) test_pickle1.py
|
||||
$(PYEXE) test_pickle2.py
|
||||
$(PYEXE) test_pickle3.py
|
||||
@@ -163,7 +157,6 @@ clean:
|
||||
rm -f getting_started2.o getting_started2.so
|
||||
rm -f simple_vector.o simple_vector.so
|
||||
rm -f do_it_yourself_convts.o do_it_yourself_convts.so
|
||||
rm -f nested.o nested.so
|
||||
rm -f pickle1.o pickle1.so
|
||||
rm -f pickle2.o pickle2.so
|
||||
rm -f pickle3.o pickle3.so
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
# 12 Apr 01 new macro ROOT to simplify configuration (R.W. Grosse-Kunstleve)
|
||||
# Initial version: R.W. Grosse-Kunstleve
|
||||
|
||||
ROOT=R:
|
||||
ROOT=L:
|
||||
BOOST_WIN="$(ROOT)\boost"
|
||||
BOOST_UNIX=$(HOME)/boost
|
||||
|
||||
@@ -44,7 +44,6 @@ all: boost_python.lib \
|
||||
getting_started1.pyd getting_started2.pyd \
|
||||
simple_vector.pyd \
|
||||
do_it_yourself_convts.pyd \
|
||||
nested.pyd \
|
||||
pickle1.pyd pickle2.pyd pickle3.pyd \
|
||||
noncopyable_export.pyd noncopyable_import.pyd \
|
||||
ivect.pyd dvect.pyd \
|
||||
@@ -71,9 +70,6 @@ simple_vector.pyd: $(OBJ) simple_vector.obj
|
||||
do_it_yourself_convts.pyd: $(OBJ) do_it_yourself_convts.obj
|
||||
$(LD) $(LDOPTS) $(OBJ) do_it_yourself_convts.obj $(PYLIB) /export:initdo_it_yourself_convts /out:"do_it_yourself_convts.pyd"
|
||||
|
||||
nested.pyd: $(OBJ) nested.obj
|
||||
$(LD) $(LDOPTS) $(OBJ) nested.obj $(PYLIB) /export:initnested /out:"nested.pyd"
|
||||
|
||||
pickle1.pyd: $(OBJ) pickle1.obj
|
||||
$(LD) $(LDOPTS) $(OBJ) pickle1.obj $(PYLIB) /export:initpickle1 /out:"pickle1.pyd"
|
||||
|
||||
@@ -114,7 +110,6 @@ test:
|
||||
$(PYEXE) test_getting_started2.py
|
||||
$(PYEXE) test_simple_vector.py
|
||||
$(PYEXE) test_do_it_yourself_convts.py
|
||||
$(PYEXE) test_nested.py
|
||||
$(PYEXE) test_pickle1.py
|
||||
$(PYEXE) test_pickle2.py
|
||||
$(PYEXE) test_pickle3.py
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
// Example by Ralf W. Grosse-Kunstleve
|
||||
|
||||
/*
|
||||
This example shows how convert a nested Python tuple.
|
||||
*/
|
||||
|
||||
#include <boost/python/class_builder.hpp>
|
||||
#include <stdio.h>
|
||||
|
||||
namespace {
|
||||
|
||||
boost::python::list
|
||||
show_nested_tuples(boost::python::tuple outer)
|
||||
{
|
||||
boost::python::list result;
|
||||
for (int i = 0; i < outer.size(); i++) {
|
||||
boost::python::tuple inner(
|
||||
BOOST_PYTHON_CONVERSION::from_python(outer[i].get(),
|
||||
boost::python::type<boost::python::tuple>()));
|
||||
for (int j = 0; j < inner.size(); j++) {
|
||||
double x = BOOST_PYTHON_CONVERSION::from_python(inner[j].get(),
|
||||
boost::python::type<double>());
|
||||
char buf[128];
|
||||
sprintf(buf, "(%d,%d) %.6g", i, j, x);
|
||||
result.append(BOOST_PYTHON_CONVERSION::to_python(std::string(buf)));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BOOST_PYTHON_MODULE_INIT(nested)
|
||||
{
|
||||
try
|
||||
{
|
||||
boost::python::module_builder this_module("nested");
|
||||
this_module.def(show_nested_tuples, "show_nested_tuples");
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
boost::python::handle_exception();
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
r'''>>> import nested
|
||||
>>> s = nested.show_nested_tuples(((1,2,3), (4,5,6,7)))
|
||||
>>> for l in s:
|
||||
... print l
|
||||
(0,0) 1
|
||||
(0,1) 2
|
||||
(0,2) 3
|
||||
(1,0) 4
|
||||
(1,1) 5
|
||||
(1,2) 6
|
||||
(1,3) 7
|
||||
'''
|
||||
|
||||
def run(args = None):
|
||||
if args is not None:
|
||||
import sys
|
||||
sys.argv = args
|
||||
import doctest, test_nested
|
||||
return doctest.testmod(test_nested)
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
sys.exit(run()[0])
|
||||
@@ -21,10 +21,10 @@ namespace boost { namespace python { namespace detail {
|
||||
|
||||
// base_object - adds a constructor and non-virtual destructor to a
|
||||
// base Python type (e.g. PyObject, PyTypeObject).
|
||||
template <class PythonType>
|
||||
struct base_object : PythonType
|
||||
template <class python_type>
|
||||
struct base_object : python_type
|
||||
{
|
||||
typedef PythonType base_python_type;
|
||||
typedef python_type base_python_type;
|
||||
|
||||
// Initializes type and reference count. All other fields of base_python_type are 0
|
||||
base_object(PyTypeObject* type_obj);
|
||||
@@ -41,8 +41,8 @@ typedef base_object<PyTypeObject> python_type;
|
||||
//
|
||||
// base_object member function implementations
|
||||
//
|
||||
template <class PythonType>
|
||||
base_object<PythonType>::base_object(PyTypeObject* type_obj)
|
||||
template <class python_type>
|
||||
base_object<python_type>::base_object(PyTypeObject* type_obj)
|
||||
{
|
||||
base_python_type* bp = this;
|
||||
#if !defined(_MSC_VER) || defined(__STLPORT)
|
||||
@@ -53,8 +53,8 @@ base_object<PythonType>::base_object(PyTypeObject* type_obj)
|
||||
PyObject_INIT(bp, type_obj);
|
||||
}
|
||||
|
||||
template <class PythonType>
|
||||
inline base_object<PythonType>::~base_object()
|
||||
template <class python_type>
|
||||
inline base_object<python_type>::~base_object()
|
||||
{
|
||||
Py_DECREF(ob_type);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,14 @@
|
||||
namespace boost { namespace python {
|
||||
|
||||
namespace detail {
|
||||
// The default way of converting a PyObject* or PyTypeObject* to a T*
|
||||
template <class T>
|
||||
struct downcast_traits
|
||||
{
|
||||
template <class U>
|
||||
static T* cast(U* p) { return static_cast<T*>(p); }
|
||||
};
|
||||
|
||||
inline PyTypeObject* as_base_object(const PyTypeObject*, PyObject* p)
|
||||
{
|
||||
return reinterpret_cast<PyTypeObject*>(p);
|
||||
@@ -46,19 +54,19 @@ template <class T>
|
||||
struct downcast
|
||||
{
|
||||
downcast(PyObject* p)
|
||||
: m_p(static_cast<T*>(detail::as_base_object((T*)0, p)))
|
||||
: m_p(detail::downcast_traits<T>::cast(detail::as_base_object((T*)0, p)))
|
||||
{}
|
||||
|
||||
downcast(const PyObject* p)
|
||||
: m_p(static_cast<T*>(detail::as_base_object((const T*)0, p)))
|
||||
: m_p(detail::downcast_traits<T>::cast(detail::as_base_object((const T*)0, p)))
|
||||
{}
|
||||
|
||||
downcast(PyTypeObject* p)
|
||||
: m_p(static_cast<T*>(p))
|
||||
: m_p(detail::downcast_traits<T>::cast(p))
|
||||
{}
|
||||
|
||||
downcast(const PyTypeObject* p)
|
||||
: m_p(static_cast<T*>(p))
|
||||
: m_p(detail::downcast_traits<T>::cast(p))
|
||||
{}
|
||||
|
||||
operator T*() const { return m_p; }
|
||||
|
||||
@@ -46,7 +46,7 @@ class function : public python_object
|
||||
private:
|
||||
struct type_object;
|
||||
private:
|
||||
reference<function> m_overloads; // A linked list of the function overloads
|
||||
reference<function> m_overloads;
|
||||
};
|
||||
|
||||
// wrapped_function_pointer<> --
|
||||
@@ -66,12 +66,7 @@ struct wrapped_function_pointer : function
|
||||
|
||||
private:
|
||||
PyObject* do_call(PyObject* args, PyObject* keywords) const
|
||||
{
|
||||
// This is where the boundary between the uniform Python function
|
||||
// interface and the statically-checked C++ function interface is
|
||||
// crossed.
|
||||
return caller<R>::call(m_pf, args, keywords);
|
||||
}
|
||||
{ return caller<R>::call(m_pf, args, keywords); }
|
||||
|
||||
const char* description() const
|
||||
{ return typeid(F).name(); }
|
||||
|
||||
@@ -101,7 +101,7 @@ class list : public object
|
||||
explicit list(std::size_t sz = 0);
|
||||
static PyTypeObject* type_obj();
|
||||
static bool accepts(ref p);
|
||||
std::size_t size() const;
|
||||
std::size_t size();
|
||||
ref operator[](std::size_t pos) const;
|
||||
proxy operator[](std::size_t pos);
|
||||
ref get_item(std::size_t pos) const;
|
||||
@@ -283,7 +283,7 @@ struct list::slice_proxy
|
||||
const list& operator=(const list& rhs);
|
||||
operator ref() const;
|
||||
operator list() const;
|
||||
std::size_t size() const;
|
||||
std::size_t size();
|
||||
ref operator[](std::size_t pos) const;
|
||||
private:
|
||||
friend class list;
|
||||
|
||||
@@ -61,8 +61,6 @@ function::function()
|
||||
|
||||
PyObject* function::call(PyObject* args, PyObject* keywords) const
|
||||
{
|
||||
// Traverse the linked list of function overloads until we find one that
|
||||
// matches.
|
||||
for (const function* f = this; f != 0; f = f->m_overloads.get())
|
||||
{
|
||||
PyErr_Clear();
|
||||
@@ -77,14 +75,9 @@ PyObject* function::call(PyObject* args, PyObject* keywords) const
|
||||
}
|
||||
}
|
||||
|
||||
// If we get here, no overloads matched the arguments
|
||||
|
||||
// Allow the single-function error-reporting to take effect unless there was
|
||||
// an overload
|
||||
if (m_overloads.get() == 0)
|
||||
return 0;
|
||||
|
||||
// Synthesize a more-explicit error message
|
||||
PyErr_Clear();
|
||||
string message("No overloaded functions match (");
|
||||
tuple arguments(ref(args, ref::increment_count));
|
||||
|
||||
@@ -362,7 +362,7 @@ bool list::accepts(ref p)
|
||||
return PyList_Check(p.get());
|
||||
}
|
||||
|
||||
std::size_t list::size() const
|
||||
std::size_t list::size()
|
||||
{
|
||||
return PyList_Size(get());
|
||||
}
|
||||
@@ -467,7 +467,7 @@ list::slice_proxy::operator list() const
|
||||
return list(this->operator ref());
|
||||
}
|
||||
|
||||
std::size_t list::slice_proxy::size() const
|
||||
std::size_t list::slice_proxy::size()
|
||||
{
|
||||
return this->operator list().size();
|
||||
}
|
||||
|
||||
@@ -24,11 +24,6 @@ namespace {
|
||||
|
||||
using detail::type_object_base;
|
||||
|
||||
// Define a family of forwarding functions that can be calle from a
|
||||
// PyTypeObject's slots. These functions dispatch through a (virtual) member
|
||||
// function pointer in the type_object_base, and handle exceptions in a
|
||||
// uniform way, preventing us from having to rewrite the dispatching code over
|
||||
// and over.
|
||||
PyObject* call(PyObject* obj, PyObject* (type_object_base::*f)(PyObject*) const)
|
||||
{
|
||||
try
|
||||
@@ -159,10 +154,6 @@ namespace {
|
||||
|
||||
extern "C" {
|
||||
|
||||
//
|
||||
// These functions actually go into the type object's slots, and dispatch to the
|
||||
// "call" wrappers defined above.
|
||||
//
|
||||
static PyObject* do_instance_repr(PyObject* obj)
|
||||
{
|
||||
return call(obj, &type_object_base::instance_repr);
|
||||
|
||||
@@ -8,11 +8,14 @@ r'''
|
||||
// producing this work.
|
||||
|
||||
// Revision History:
|
||||
// 2001 Nov 01 Python 2.2 pickle problems fixed (rwgk)
|
||||
// 04 Mar 01 Changed name of extension module so it would work with DebugPython,
|
||||
// fixed exception message checking to work with Python 2.0
|
||||
// (Dave Abrahams)
|
||||
|
||||
Load up the extension module
|
||||
|
||||
>>> from boost_python_test import *
|
||||
|
||||
Automatic checking of the number and type of arguments. Foo's constructor takes
|
||||
a single long parameter.
|
||||
|
||||
@@ -271,12 +274,19 @@ Pickle safety measures:
|
||||
... except RuntimeError, err: print err[0]
|
||||
...
|
||||
Incomplete pickle support (__dict_defines_state__ not set)
|
||||
>>> class myrational(Rational):
|
||||
... __dict_defines_state__ = 1 # this is a lie but good enough for testing.
|
||||
...
|
||||
>>> r=myrational(3, 4)
|
||||
>>> r
|
||||
Rational(3, 4)
|
||||
>>> s=pickle.dumps(r)
|
||||
>>> u=pickle.loads(s)
|
||||
|
||||
>>> class myworld(world):
|
||||
... def __init__(self):
|
||||
... world.__init__(self, 'anywhere')
|
||||
... self.x = 1
|
||||
...
|
||||
>>> w = myworld()
|
||||
>>> w.greet()
|
||||
'Hello from anywhere!'
|
||||
@@ -287,6 +297,9 @@ Pickle safety measures:
|
||||
...
|
||||
Incomplete pickle support (__getstate_manages_dict__ not set)
|
||||
|
||||
>>> class myunsafeworld(myworld):
|
||||
... __getstate_manages_dict__ = 1 # this is a lie but good enough for testing.
|
||||
...
|
||||
>>> w = myunsafeworld()
|
||||
>>> w.greet()
|
||||
'Hello from anywhere!'
|
||||
@@ -1178,23 +1191,6 @@ test methodologies for wrapping functions that return a pointer
|
||||
'''
|
||||
#'
|
||||
|
||||
from boost_python_test import *
|
||||
|
||||
# pickle requires these derived classes to be
|
||||
# at the global scope of the module
|
||||
|
||||
class myrational(Rational):
|
||||
__dict_defines_state__ = 1 # this is a lie but good enough for testing.
|
||||
|
||||
class myworld(world):
|
||||
def __init__(self):
|
||||
world.__init__(self, 'anywhere')
|
||||
self.x = 1
|
||||
|
||||
class myunsafeworld(myworld):
|
||||
__getstate_manages_dict__ = 1 # this is a lie but good enough for testing.
|
||||
|
||||
|
||||
def assert_integer_expected(err):
|
||||
"""Handle a common error report which appears differently in Python 1.5.x and 2.0"""
|
||||
assert isinstance(err, TypeError)
|
||||
|
||||
Reference in New Issue
Block a user