mirror of
https://github.com/boostorg/python.git
synced 2026-01-19 04:22:16 +00:00
Merge branch 'develop'
This commit is contained in:
@@ -39,6 +39,7 @@ arch = ARGUMENTS.get('arch', platform.machine())
|
||||
env_vars = {}
|
||||
if 'CXX' in os.environ: env_vars['CXX'] = os.environ['CXX']
|
||||
if 'CXXFLAGS' in os.environ: env_vars['CXXFLAGS'] = os.environ['CXXFLAGS'].split()
|
||||
env_vars['ENV'] = os.environ #{'PATH': os.environ['PATH'], 'TMP' : os.environ['TMP']}
|
||||
env = Environment(toolpath=['config/tools'],
|
||||
tools=['default', 'libs', 'tests', 'doc', 'sphinx4scons'],
|
||||
variables=vars,
|
||||
|
||||
@@ -69,13 +69,15 @@ install:
|
||||
# pip will build them from source using the MSVC compiler matching the
|
||||
# target Python version and architecture
|
||||
- easy_install scons
|
||||
- easy_install sphinx
|
||||
- pip install numpy
|
||||
#- "%CMD_IN_ENV% pip install -r dev-requirements.txt"
|
||||
|
||||
build_script:
|
||||
# Build the compiled extension
|
||||
#- "%CMD_IN_ENV% python setup.py build"
|
||||
- scons config arch=%ARCH% --boost-include=%BOOST_PREFIX%
|
||||
- scons arch=%ARCH%
|
||||
- scons arch=%ARCH% --verbose
|
||||
|
||||
test_script:
|
||||
# Run the project tests
|
||||
|
||||
@@ -38,7 +38,7 @@ The `indexing_suite` class is the base class for the management of C++ container
|
||||
[[__iter__(self)]
|
||||
[This method is called when an iterator is required for a container. This method should return a new iterator object that can iterate over all the objects in the container. For mappings, it should iterate over the keys of the container, and should also be made available as the method iterkeys().
|
||||
|
||||
Iterator objects also need to implement this method; they are required to return themselves. For more information on iterator objects, see [@http://www.python.org/doc/current/lib/typeiter.html Iterator Types] in the [@http://www.python.org/doc/current/lib/lib.html Python Library Reference].]]
|
||||
Iterator objects also need to implement this method; they are required to return themselves. For more information on iterator objects, see [@https://docs.python.org/3/library/stdtypes.html#iterator-types Iterator Types] in the [@https://docs.python.org/3/library/index.html Python Library Reference].]]
|
||||
|
||||
[[__contains__(self, item)]
|
||||
[Called to implement membership test operators. Should return true if item is in self, false otherwise. For mapping objects, this should consider the keys of the mapping rather than the values or the key-item pairs.]]
|
||||
|
||||
@@ -4,7 +4,7 @@ Pickle is a Python module for object serialization, also known as persistence, m
|
||||
|
||||
It is often necessary to save and restore the contents of an object to a file. One approach to this problem is to write a pair of functions that read and write data from a file in a special format. A powerful alternative approach is to use Python's pickle module. Exploiting Python's ability for introspection, the pickle module recursively converts nearly arbitrary Python objects into a stream of bytes that can be written to a file.
|
||||
|
||||
The Boost Python Library supports the pickle module through the interface as described in detail in the [@http://www.python.org/doc/current/lib/module-pickle.html Python Library Reference for pickle]. This interface involves the special methods `__getinitargs__`, `__getstate__` and `__setstate__` as described in the following. Note that `Boost.Python` is also fully compatible with Python's cPickle module.
|
||||
The Boost Python Library supports the pickle module through the interface as described in detail in the [@https://docs.python.org/2/library/pickle.html Python Library Reference for pickle]. This interface involves the special methods `__getinitargs__`, `__getstate__` and `__setstate__` as described in the following. Note that `Boost.Python` is also fully compatible with Python's cPickle module.
|
||||
[endsect]
|
||||
[section The Pickle Interface]
|
||||
At the user level, the Boost.Python pickle interface involves three special methods:
|
||||
|
||||
@@ -9,8 +9,11 @@
|
||||
|
||||
namespace boost { namespace python { namespace converter {
|
||||
|
||||
BOOST_PYTHON_DECL PyObject* checked_downcast_impl(PyObject*, PyTypeObject*);
|
||||
|
||||
BOOST_PYTHON_DECL inline
|
||||
PyObject* checked_downcast_impl(PyObject *obj, PyTypeObject *type)
|
||||
{
|
||||
return (PyType_IsSubtype(Py_TYPE(obj), type) ? obj : NULL);
|
||||
}
|
||||
// Used as a base class for specializations which need to provide
|
||||
// Python type checking capability.
|
||||
template <class Object, PyTypeObject* pytype>
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
* This is more permissive than equality tests. For instance, if long and int are the same
|
||||
* size, the dtypes corresponding to each will be equivalent, but not equal.
|
||||
*/
|
||||
friend bool equivalent(dtype const & a, dtype const & b);
|
||||
friend BOOST_NUMPY_DECL bool equivalent(dtype const & a, dtype const & b);
|
||||
|
||||
/**
|
||||
* @brief Register from-Python converters for NumPy's built-in array scalar types.
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
|
||||
};
|
||||
|
||||
bool equivalent(dtype const & a, dtype const & b);
|
||||
BOOST_NUMPY_DECL bool equivalent(dtype const & a, dtype const & b);
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace boost { namespace python { namespace numpy {
|
||||
namespace detail
|
||||
{
|
||||
|
||||
struct add_pointer_meta
|
||||
struct BOOST_NUMPY_DECL add_pointer_meta
|
||||
{
|
||||
template <typename T>
|
||||
struct apply
|
||||
@@ -29,8 +29,8 @@ struct add_pointer_meta
|
||||
|
||||
};
|
||||
|
||||
struct dtype_template_match_found {};
|
||||
struct nd_template_match_found {};
|
||||
struct BOOST_NUMPY_DECL dtype_template_match_found {};
|
||||
struct BOOST_NUMPY_DECL nd_template_match_found {};
|
||||
|
||||
template <typename Function>
|
||||
struct dtype_template_invoker
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
* return a numpy.matrix instead.
|
||||
*/
|
||||
template <typename Base = default_call_policies>
|
||||
struct BOOST_NUMPY_DECL as_matrix : Base
|
||||
struct as_matrix : Base
|
||||
{
|
||||
static PyObject * postcall(PyObject *, PyObject * result)
|
||||
{
|
||||
|
||||
@@ -142,32 +142,32 @@ public:
|
||||
/**
|
||||
* @brief Construct a new array with the given shape and data type, with data initialized to zero.
|
||||
*/
|
||||
ndarray zeros(python::tuple const & shape, dtype const & dt);
|
||||
ndarray zeros(int nd, Py_intptr_t const * shape, dtype const & dt);
|
||||
BOOST_NUMPY_DECL ndarray zeros(python::tuple const & shape, dtype const & dt);
|
||||
BOOST_NUMPY_DECL ndarray zeros(int nd, Py_intptr_t const * shape, dtype const & dt);
|
||||
|
||||
/**
|
||||
* @brief Construct a new array with the given shape and data type, with data left uninitialized.
|
||||
*/
|
||||
ndarray empty(python::tuple const & shape, dtype const & dt);
|
||||
ndarray empty(int nd, Py_intptr_t const * shape, dtype const & dt);
|
||||
BOOST_NUMPY_DECL ndarray empty(python::tuple const & shape, dtype const & dt);
|
||||
BOOST_NUMPY_DECL ndarray empty(int nd, Py_intptr_t const * shape, dtype const & dt);
|
||||
|
||||
/**
|
||||
* @brief Construct a new array from an arbitrary Python sequence.
|
||||
*
|
||||
* @todo This does't seem to handle ndarray subtypes the same way that "numpy.array" does in Python.
|
||||
*/
|
||||
ndarray array(object const & obj);
|
||||
ndarray array(object const & obj, dtype const & dt);
|
||||
BOOST_NUMPY_DECL ndarray array(object const & obj);
|
||||
BOOST_NUMPY_DECL ndarray array(object const & obj, dtype const & dt);
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
ndarray from_data_impl(void * data,
|
||||
dtype const & dt,
|
||||
std::vector<Py_intptr_t> const & shape,
|
||||
std::vector<Py_intptr_t> const & strides,
|
||||
object const & owner,
|
||||
bool writeable);
|
||||
BOOST_NUMPY_DECL ndarray from_data_impl(void * data,
|
||||
dtype const & dt,
|
||||
std::vector<Py_intptr_t> const & shape,
|
||||
std::vector<Py_intptr_t> const & strides,
|
||||
object const & owner,
|
||||
bool writeable);
|
||||
|
||||
template <typename Container>
|
||||
ndarray from_data_impl(void * data,
|
||||
@@ -183,12 +183,12 @@ ndarray from_data_impl(void * data,
|
||||
return from_data_impl(data, dt, shape_, strides_, owner, writeable);
|
||||
}
|
||||
|
||||
ndarray from_data_impl(void * data,
|
||||
dtype const & dt,
|
||||
object const & shape,
|
||||
object const & strides,
|
||||
object const & owner,
|
||||
bool writeable);
|
||||
BOOST_NUMPY_DECL ndarray from_data_impl(void * data,
|
||||
dtype const & dt,
|
||||
object const & shape,
|
||||
object const & strides,
|
||||
object const & owner,
|
||||
bool writeable);
|
||||
|
||||
} // namespace boost::python::numpy::detail
|
||||
|
||||
@@ -250,39 +250,53 @@ inline ndarray from_data(void const * data,
|
||||
* @param[in] nd_max Maximum number of dimensions.
|
||||
* @param[in] flags Bitwise OR of flags specifying additional requirements.
|
||||
*/
|
||||
ndarray from_object(object const & obj, dtype const & dt,
|
||||
int nd_min, int nd_max, ndarray::bitflag flags=ndarray::NONE);
|
||||
BOOST_NUMPY_DECL ndarray from_object(object const & obj,
|
||||
dtype const & dt,
|
||||
int nd_min,
|
||||
int nd_max,
|
||||
ndarray::bitflag flags=ndarray::NONE);
|
||||
|
||||
inline ndarray from_object(object const & obj, dtype const & dt,
|
||||
int nd, ndarray::bitflag flags=ndarray::NONE)
|
||||
BOOST_NUMPY_DECL inline ndarray from_object(object const & obj,
|
||||
dtype const & dt,
|
||||
int nd,
|
||||
ndarray::bitflag flags=ndarray::NONE)
|
||||
{
|
||||
return from_object(obj, dt, nd, nd, flags);
|
||||
}
|
||||
|
||||
inline ndarray from_object(object const & obj, dtype const & dt, ndarray::bitflag flags=ndarray::NONE)
|
||||
BOOST_NUMPY_DECL inline ndarray from_object(object const & obj,
|
||||
dtype const & dt,
|
||||
ndarray::bitflag flags=ndarray::NONE)
|
||||
{
|
||||
return from_object(obj, dt, 0, 0, flags);
|
||||
}
|
||||
|
||||
ndarray from_object(object const & obj, int nd_min, int nd_max,
|
||||
ndarray::bitflag flags=ndarray::NONE);
|
||||
BOOST_NUMPY_DECL ndarray from_object(object const & obj,
|
||||
int nd_min,
|
||||
int nd_max,
|
||||
ndarray::bitflag flags=ndarray::NONE);
|
||||
|
||||
inline ndarray from_object(object const & obj, int nd, ndarray::bitflag flags=ndarray::NONE)
|
||||
BOOST_NUMPY_DECL inline ndarray from_object(object const & obj,
|
||||
int nd,
|
||||
ndarray::bitflag flags=ndarray::NONE)
|
||||
{
|
||||
return from_object(obj, nd, nd, flags);
|
||||
}
|
||||
|
||||
inline ndarray from_object(object const & obj, ndarray::bitflag flags=ndarray::NONE)
|
||||
BOOST_NUMPY_DECL inline ndarray from_object(object const & obj,
|
||||
ndarray::bitflag flags=ndarray::NONE)
|
||||
{
|
||||
return from_object(obj, 0, 0, flags);
|
||||
}
|
||||
|
||||
inline ndarray::bitflag operator|(ndarray::bitflag a, ndarray::bitflag b)
|
||||
BOOST_NUMPY_DECL inline ndarray::bitflag operator|(ndarray::bitflag a,
|
||||
ndarray::bitflag b)
|
||||
{
|
||||
return ndarray::bitflag(int(a) | int(b));
|
||||
}
|
||||
|
||||
inline ndarray::bitflag operator&(ndarray::bitflag a, ndarray::bitflag b)
|
||||
BOOST_NUMPY_DECL inline ndarray::bitflag operator&(ndarray::bitflag a,
|
||||
ndarray::bitflag b)
|
||||
{
|
||||
return ndarray::bitflag(int(a) & int(b));
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#ifndef boost_python_numpy_numpy_object_mgr_traits_hpp_
|
||||
#define boost_python_numpy_numpy_object_mgr_traits_hpp_
|
||||
|
||||
#include <boost/python/numpy/config.hpp>
|
||||
|
||||
/**
|
||||
* @brief Macro that specializes object_manager_traits by requiring a
|
||||
* source-file implementation of get_pytype().
|
||||
@@ -14,7 +16,7 @@
|
||||
|
||||
#define NUMPY_OBJECT_MANAGER_TRAITS(manager) \
|
||||
template <> \
|
||||
struct object_manager_traits<manager> \
|
||||
struct BOOST_NUMPY_DECL object_manager_traits<manager> \
|
||||
{ \
|
||||
BOOST_STATIC_CONSTANT(bool, is_specialized = true); \
|
||||
static inline python::detail::new_reference adopt(PyObject* x) \
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace boost { namespace python { namespace numpy {
|
||||
*
|
||||
* @todo This could have a lot more functionality.
|
||||
*/
|
||||
class void_ : public object
|
||||
class BOOST_NUMPY_DECL void_ : public object
|
||||
{
|
||||
static python::detail::new_reference convert(object_cref arg, bool align);
|
||||
public:
|
||||
|
||||
@@ -62,13 +62,13 @@ public:
|
||||
};
|
||||
|
||||
/// @brief Construct a multi_iter over a single sequence or scalar object.
|
||||
multi_iter make_multi_iter(object const & a1);
|
||||
BOOST_NUMPY_DECL multi_iter make_multi_iter(object const & a1);
|
||||
|
||||
/// @brief Construct a multi_iter by broadcasting two objects.
|
||||
multi_iter make_multi_iter(object const & a1, object const & a2);
|
||||
BOOST_NUMPY_DECL multi_iter make_multi_iter(object const & a1, object const & a2);
|
||||
|
||||
/// @brief Construct a multi_iter by broadcasting three objects.
|
||||
multi_iter make_multi_iter(object const & a1, object const & a2, object const & a3);
|
||||
BOOST_NUMPY_DECL multi_iter make_multi_iter(object const & a1, object const & a2, object const & a3);
|
||||
|
||||
/**
|
||||
* @brief Helps wrap a C++ functor taking a single scalar argument as a broadcasting ufunc-like
|
||||
|
||||
@@ -10,9 +10,11 @@
|
||||
Import('env')
|
||||
|
||||
env.AppendUnique(CPPDEFINES = ["${LINK_DYNAMIC and 'BOOST_PYTHON_DYN_LINK=1' or ''}"])
|
||||
env.AppendUnique(CPPDEFINES = ['BOOST_PYTHON_SOURCE'])
|
||||
|
||||
env.BoostLibrary(
|
||||
env1 = env.Clone()
|
||||
env1.AppendUnique(CPPDEFINES = ['BOOST_PYTHON_SOURCE'])
|
||||
|
||||
env1.BoostLibrary(
|
||||
'python',
|
||||
['numeric.cpp',
|
||||
'list.cpp',
|
||||
@@ -44,7 +46,13 @@ env.BoostLibrary(
|
||||
'object/function_doc_signature.cpp'])
|
||||
|
||||
if env['NUMPY']:
|
||||
env.BoostLibrary(
|
||||
env2 = env.Clone()
|
||||
env2.Append(CPPPATH=env['NUMPY_CPPPATH'])
|
||||
build_dir = env.Dir('$BOOST_CURRENT_VARIANT_DIR/src')
|
||||
env2.AppendUnique(CPPDEFINES = ['BOOST_NUMPY_SOURCE'],
|
||||
LIBPATH = [build_dir],
|
||||
LIBS='boost_python' + env["BOOST_SUFFIX"])
|
||||
env2.BoostLibrary(
|
||||
'numpy',
|
||||
['numpy/dtype.cpp',
|
||||
'numpy/matrix.cpp',
|
||||
|
||||
@@ -8,9 +8,18 @@
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
import platform
|
||||
import sys
|
||||
|
||||
Import('env')
|
||||
|
||||
if sys.platform == 'win32':
|
||||
# HACK: This works around a bug in SCons.
|
||||
# subprocess.check_output will complain unless all environment
|
||||
# variables are strings.
|
||||
system_root = env['ENV']['SystemRoot']
|
||||
env['ENV']['SystemRoot'] = str(system_root)
|
||||
|
||||
|
||||
# libs needed for embedding
|
||||
ELIBS=env['LIBS'] + env['PYTHONLIBS']
|
||||
|
||||
|
||||
Reference in New Issue
Block a user