2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-20 04:42:28 +00:00

Compare commits

..

5 Commits

Author SHA1 Message Date
nobody
a1e76757b5 This commit was manufactured by cvs2svn to create tag
'Version_1_25_1_BGL'.

[SVN r11635]
2001-11-08 17:13:50 +00:00
Ralf W. Grosse-Kunstleve
b4a1a6c688 PYEXE=PYTHONPATH=. /usr/local/Python-1.5.2/bin/python
[SVN r11523]
2001-11-02 01:24:59 +00:00
Ralf W. Grosse-Kunstleve
6cb4b790b9 Python 2.2 pickle problems fixed.
[SVN r11521]
2001-11-01 23:28:54 +00:00
Dave Abrahams
a245bdbc2a Modified Files:
boost/python/detail:
    base_object.hpp - Changed template parameter to MixedCase
    cast.hpp -        Killed off unused downcast_traits<>
    functions.hpp -   Added commentary

  libs/python/src
    functions.cpp, types.cpp -   Added comments

  tools/build
    TODO.txt - updated
    allyourbase.jam -           fixed a nasty typo which caused all kinds of bugs
    boost-base.jam -            changes to support the use of command files
    intel-win32-tools.jam -
         A feeble attempt at allowing intel to work without prior tool setup. More work needed
    msvc-tools.jam -            A first cut at command file support

  tools/build/jam_src
    jam.h -                     Fixed MAXLINE for NT


[SVN r11489]
2001-10-31 19:14:07 +00:00
Dave Abrahams
e63451a9e7 regex, threads, and python will all build from the top level. If you build the 'test' target from the top level, it will run all regressions.
Jamfile:
  subincludes for thread, python libs, and status for regression tests

Jamrules:
  Use the new path-global rule to establish BOOST_ROOT correctly for all subprojects

libs/regex/build/Jamfile
  Take advantage of correct BOOST_ROOT setting

libs/python/build/Jamfile
  Search for python executable; don't try to build anything if it can't be found.
  don't build tests by default
  improved comments, organization, and naming.

status/Jamfile
  Fixed references to config test files
  Failed tests now leave their stdout results in <testname>.error instead of removing it
  No test targets are dependencies of 'all' anymore
  Added comments
  Reorganized

tools/build/Jambase
  Meant to check this in long ago.

tools/build/allyourbase.jam
  Fixed SHELL_EXPORT setting, added SHELL_SET
  removed 'test' from the dependencies of 'all'; tests no longer run by default.
  Fixed the direction of slashes for Windows when ALL_LOCATE_TARGET is used.
  Added path-global rule for declaring path variables which may be relative
  rule in-invocation-subdir returns true if the current subproject is the one
     from which Jam was invoked
  rule protect-subdir is now used to protect subproject variables
  rule tokens-to-simple-path converts path tokens to a simplified path.

tools/build/boost-base.jam
  Fixed bugs

tools/build/jam_src/makedebugjam.bat
  Fixed a bug which prevented a final debug build

tools/build/jam_src/search.c
  Fixed a bug of mine which caused LOCATE to be ignored (!).


[SVN r11348]
2001-10-06 18:19:15 +00:00
10 changed files with 147 additions and 90 deletions

View File

@@ -5,13 +5,16 @@
#
# 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 "all" target
# depends on it so that it it is built by default. <name>.run runs
# <name>.test runs the test when it is out-of-date, and the "test"
# pseudotarget depends on it. <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:
@@ -38,6 +41,12 @@
#
# 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.
@@ -49,12 +58,21 @@
# 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/python2.1 ;
PYTHON_LIBS ?= c:/cygnus/lib/python2.1/config/libpython2.1.dll.a ;
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_LIB_PATH = $(PYTHON_ROOT)/libs ;
# common properties required for compiling any Python module.
@@ -64,17 +82,20 @@ if $(NT)
<runtime-link>dynamic
;
SHELL_SET ?= "set " ;
SHELL_EXPORT ?= ; # shell variables are exported by default
}
else if $(UNIX)
{
PYTHON_INCLUDES ?= <include>/usr/include/python1.5 ;
PYTHON_LIBS ?= /usr/lib/python1.5/config/libpython1.5.a ;
SHELL_SET ?= "" ;
SHELL_EXPORT ?= "export " ;
PYTHON_VERSION ?= 1.5 ;
PYTHON_INCLUDES ?= <include>/usr/include/python$(PYTHON_VERSION) ;
PYTHON_LIBS ?= /usr/lib/python$(PYTHON_VERSION)/config/libpython$(PYTHON_VERSION).a ;
}
# how do we invoke python?
local PYTHON = $(PYTHON) ;
PYTHON ?= python ;
PYTHON = [ FAppendSuffix $(PYTHON:G=<executable-grist>) : $(SUFEXE) ] ;
SEARCH on $(PYTHON) = $(PATH) ;
#######################
#
@@ -82,10 +103,10 @@ else if $(UNIX)
#
# standard include requirements for anything using Boost.Python
BOOST_PYTHON_INCLUDES = <include>$(BOOST_ROOT) $(PYTHON_INCLUDES) ;
local BOOST_PYTHON_INCLUDES = <include>$(BOOST_ROOT) $(PYTHON_INCLUDES) ;
# Base names of the source files for libboost_python
CPP_SOURCES =
local CPP_SOURCES =
classes conversions extension_class functions
init_function module_builder objects types cross_module ;
@@ -117,13 +138,25 @@ 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-test target : python-script sources : requirements : local-build : args
# boost-python-runtest 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-test
rule boost-python-runtest
{
# tell Jam that the python script is relative to this directory
SEARCH on $(>[1]) = $(SEARCH_SOURCE) ;
@@ -131,28 +164,25 @@ rule boost-python-test
# 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-test.
# PYTHON_RUNTEST runs the test unconditionally. These are used by boost-python-runtest.
SUFPYTHON_TEST = .test ;
gGENERATOR_FUNCTION(PYTHON_TEST) = python-test-target ;
rule python-test-target # test-target : sources :
{
python-test-aux $(<) : $(>) ;
python-runtest-aux $(<) : $(>) ;
Clean clean : $(<) ; # remove the test-target as part of any clean operation
type-DEPENDS test : $(<) ;
MakeLocate $(<) : $(LOCATE_TARGET) ;
}
actions python-test-target
actions python-test-target bind PYTHON
{
$(SHELL_SET)PYTHONPATH=$(PYTHONPATH)
$(SHELL_EXPORT)PYTHONPATH
@@ -163,18 +193,18 @@ SUFPYTHON_RUNTEST = .run ;
gGENERATOR_FUNCTION(PYTHON_RUNTEST) = python-runtest-target ;
rule python-runtest-target # test-target : sources :
{
python-test-aux $(<) : $(>) ;
python-runtest-aux $(<) : $(>) ;
NOTFILE $(<) ;
ALWAYS $(<) ;
}
actions python-runtest-target
actions python-runtest-target bind PYTHON
{
$(SHELL_SET)PYTHONPATH=$(PYTHONPATH)
$(SHELL_EXPORT)PYTHONPATH
$(PYTHON) "$(>)" $(ARGS)
}
rule python-test-aux # target : sources
rule python-runtest-aux # target : sources
{
DEPENDS $(<) : $(>) ;
@@ -196,50 +226,60 @@ rule python-test-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 boost_python_test : ../test/comprehensive.cpp ;
boost-python-test comprehensive : [ join-path $(DOTDOT) test comprehensive.py ] <lib>boost_python_test ;
boost-python-test boost_python_test : ../test/comprehensive.cpp ;
boost-python-runtest comprehensive
: [ join-path $(DOTDOT) test comprehensive.py ]
<lib>boost_python_test ;
############# simple tests from ../example ############
rule boost-python-example-test
rule boost-python-example-runtest
{
boost-python $(<) : ../example/$(<).cpp ;
boost-python-test $(<) : [ join-path $(DOTDOT) example test_$(<).py ] <lib>$(<) ;
boost-python-test $(<) : ../example/$(<).cpp ;
boost-python-runtest $(<) : [ join-path $(DOTDOT) example test_$(<).py ] <lib>$(<) ;
}
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-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 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 ;
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 ;
############## 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-test # test-name : python-file libs
rule boost-python-multi-example-runtest # test-name : python-file libs
{
boost-python-test $(<) : ../example/tst_$(<).py <lib>$(>) : : : $(PYTHON_VECT_ITERATIONS) ;
boost-python-runtest $(<)
: ../example/tst_$(<).py <lib>$(>)
: : : $(PYTHON_VECT_ITERATIONS) ;
}
PYTHON_VECT_ITERATIONS ?= 10 ;
boost-python-multi-example-test dvect1 : ivect dvect ;
boost-python-multi-example-test dvect2 : ivect dvect ;
boost-python-multi-example-runtest dvect1 : ivect dvect ;
boost-python-multi-example-runtest dvect2 : ivect dvect ;
boost-python-multi-example-test ivect1 : ivect dvect ;
boost-python-multi-example-test ivect2 : ivect dvect ;
boost-python-multi-example-runtest ivect1 : ivect dvect ;
boost-python-multi-example-runtest ivect2 : ivect dvect ;
boost-python-multi-example-test noncopyable : noncopyable_import noncopyable_export ;
boost-python-multi-example-runtest
noncopyable : noncopyable_import noncopyable_export ;

View File

@@ -17,9 +17,9 @@
ROOT=$(HOME)
BOOST=$(ROOT)/boost
PYEXE=/usr/local/Python-1.5.2/bin/python
PYEXE=PYTHONPATH=. /usr/local/Python-1.5.2/bin/python
PYINC=-I/usr/local/Python-1.5.2/include/python1.5
#PYEXE=/usr/local/Python-2.1/bin/python
#PYEXE=PYTHONPATH=. /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

View File

@@ -19,9 +19,9 @@ BOOST=$(ROOT)/boost
PYEXE=PYTHONPATH=. /usr/bin/python
PYINC=-I/usr/include/python1.5
#PYEXE=/usr/local/Python-1.5.2/bin/python
#PYEXE=PYTHONPATH=. /usr/local/Python-1.5.2/bin/python
#PYINC=-I/usr/local/Python-1.5.2/include/python1.5
#PYEXE=/usr/local/Python-2.1/bin/python
#PYEXE=PYTHONPATH=. /usr/local/Python-2.1/bin/python
#PYINC=-I/usr/local/Python-2.1/include/python2.1
STDOPTS=-fPIC -ftemplate-depth-21

View File

@@ -17,9 +17,9 @@
ROOT=$(HOME)
BOOST=$(ROOT)/boost
PYEXE=/usr/local/Python-1.5.2/bin/python
PYEXE=PYTHONPATH=. /usr/local/Python-1.5.2/bin/python
PYINC=-I/usr/local/Python-1.5.2/include/python1.5
#PYEXE=/usr/local/Python-2.1/bin/python
#PYEXE=PYTHONPATH=. /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

View File

@@ -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 python_type>
struct base_object : python_type
template <class PythonType>
struct base_object : PythonType
{
typedef python_type base_python_type;
typedef PythonType 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 python_type>
base_object<python_type>::base_object(PyTypeObject* type_obj)
template <class PythonType>
base_object<PythonType>::base_object(PyTypeObject* type_obj)
{
base_python_type* bp = this;
#if !defined(_MSC_VER) || defined(__STLPORT)
@@ -53,8 +53,8 @@ base_object<python_type>::base_object(PyTypeObject* type_obj)
PyObject_INIT(bp, type_obj);
}
template <class python_type>
inline base_object<python_type>::~base_object()
template <class PythonType>
inline base_object<PythonType>::~base_object()
{
Py_DECREF(ob_type);
}

View File

@@ -15,14 +15,6 @@
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);
@@ -54,19 +46,19 @@ template <class T>
struct downcast
{
downcast(PyObject* p)
: m_p(detail::downcast_traits<T>::cast(detail::as_base_object((T*)0, p)))
: m_p(static_cast<T*>(detail::as_base_object((T*)0, p)))
{}
downcast(const PyObject* p)
: m_p(detail::downcast_traits<T>::cast(detail::as_base_object((const T*)0, p)))
: m_p(static_cast<T*>(detail::as_base_object((const T*)0, p)))
{}
downcast(PyTypeObject* p)
: m_p(detail::downcast_traits<T>::cast(p))
: m_p(static_cast<T*>(p))
{}
downcast(const PyTypeObject* p)
: m_p(detail::downcast_traits<T>::cast(p))
: m_p(static_cast<T*>(p))
{}
operator T*() const { return m_p; }

View File

@@ -46,7 +46,7 @@ class function : public python_object
private:
struct type_object;
private:
reference<function> m_overloads;
reference<function> m_overloads; // A linked list of the function overloads
};
// wrapped_function_pointer<> --
@@ -66,7 +66,12 @@ struct wrapped_function_pointer : function
private:
PyObject* do_call(PyObject* args, PyObject* keywords) const
{ return caller<R>::call(m_pf, args, keywords); }
{
// 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);
}
const char* description() const
{ return typeid(F).name(); }

View File

@@ -61,6 +61,8 @@ 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();
@@ -75,9 +77,14 @@ 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));

View File

@@ -24,6 +24,11 @@ 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
@@ -154,6 +159,10 @@ 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);

View File

@@ -8,14 +8,11 @@ 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.
@@ -274,19 +271,12 @@ 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!'
@@ -297,9 +287,6 @@ 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!'
@@ -1191,6 +1178,23 @@ 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)