Python: Reverted to Boost 1.55

This commit is contained in:
Philippe Tillet
2015-08-07 01:00:52 -07:00
parent 623c5f5e85
commit a986bc3a17
2823 changed files with 384926 additions and 12340 deletions

View File

@@ -70,6 +70,7 @@ execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c"
"from distutils import sysconfig as s;import sys;import struct;
print('.'.join(str(v) for v in sys.version_info));
print(s.PREFIX);
print(s.get_python_inc());
print(s.get_python_inc(plat_specific=True));
print(s.get_python_lib(plat_specific=True));
print(s.get_config_var('SO'));
@@ -96,10 +97,11 @@ string(REGEX REPLACE "\n" ";" _PYTHON_VALUES ${_PYTHON_VALUES})
list(GET _PYTHON_VALUES 0 _PYTHON_VERSION_LIST)
list(GET _PYTHON_VALUES 1 PYTHON_PREFIX)
list(GET _PYTHON_VALUES 2 PYTHON_INCLUDE_DIR)
list(GET _PYTHON_VALUES 3 PYTHON_SITE_PACKAGES)
list(GET _PYTHON_VALUES 4 PYTHON_MODULE_EXTENSION)
list(GET _PYTHON_VALUES 5 PYTHON_IS_DEBUG)
list(GET _PYTHON_VALUES 6 PYTHON_SIZEOF_VOID_P)
list(GET _PYTHON_VALUES 3 PYTHON_PLATFORM_INCLUDE_DIR)
list(GET _PYTHON_VALUES 4 PYTHON_SITE_PACKAGES)
list(GET _PYTHON_VALUES 5 PYTHON_MODULE_EXTENSION)
list(GET _PYTHON_VALUES 6 PYTHON_IS_DEBUG)
list(GET _PYTHON_VALUES 7 PYTHON_SIZEOF_VOID_P)
# Make sure the Python has the same pointer-size as the chosen compiler
if(NOT ${PYTHON_SIZEOF_VOID_P} MATCHES ${CMAKE_SIZEOF_VOID_P})
@@ -163,7 +165,7 @@ MARK_AS_ADVANCED(
# cache entries because they are meant to specify the location of a single
# library. We now set the variables listed by the documentation for this
# module.
SET(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
SET(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR};${PYTHON_PLATFORM_INCLUDE_DIR}")
SET(PYTHON_LIBRARIES "${PYTHON_LIBRARY}")
SET(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}")

View File

@@ -3,7 +3,7 @@ macro( addPythonExe _name _srccpp )
ADD_EXECUTABLE(${_name} ${_srccpp})
# make the pyd library link against boost_numpy python and boost
TARGET_LINK_LIBRARIES(${_name} boost_numpy)
TARGET_LINK_LIBRARIES(${_name} boost_numpy ${PYTHON_LIBRARIES} ${Boost_LIBRARIES})
# put the example target into a VS solution folder named example (should
# be a no-op for Linux)
@@ -14,7 +14,7 @@ macro( addPythonMod _name _srccpp )
PYTHON_ADD_MODULE(${_name} ${_srccpp})
# make the pyd library link against boost_numpy python and boost
TARGET_LINK_LIBRARIES(${_name} boost_numpy)
TARGET_LINK_LIBRARIES(${_name} boost_numpy ${PYTHON_LIBRARIES} ${Boost_LIBRARIES})
# put the example target into a VS solution folder named example (should
# be a no-op for Linux)

View File

@@ -111,11 +111,8 @@ BOOST_PYTHON_MODULE(example) {
int main(int argc, char **argv)
{
// This line makes our module available to the embedded Python intepreter.
# if PY_VERSION_HEX >= 0x03000000
PyImport_AppendInittab("example", &PyInit_example);
# else
PyImport_AppendInittab("example", &initexample);
# endif
PyImport_AppendInittab("example", &initexample);
// Initialize the Python runtime.
Py_Initialize();

View File

@@ -17,7 +17,8 @@ add_library(boost_numpy ${LIBRARY_TYPE}
ufunc.cpp
numpy.cpp
)
target_link_libraries(boost_numpy ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
TARGET_LINK_LIBRARIES(boost_numpy ${Boost_LIBRARIES})
install(TARGETS boost_numpy
ARCHIVE DESTINATION lib

View File

@@ -5,18 +5,8 @@
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
import sys
import os
Import(['env', 'EXT_SUFFIX', 'LIB_SUFFIX', 'OBJ_SUFFIX'])
Import("env")
LIB_BOOST_NUMPY = ('boost_numpy' + LIB_SUFFIX)
sourcefiles = Glob("*.cpp")
if os.name == 'nt':
lib = env.StaticLibrary(LIB_BOOST_NUMPY, source=sourcefiles)
else:
mods = [g.name.replace('.cpp', '') for g in sourcefiles]
for m in mods:
env.SharedObject (target=m+OBJ_SUFFIX, source=m+'.cpp')
lib = env.SharedLibrary(LIB_BOOST_NUMPY, source=[m+OBJ_SUFFIX for m in mods])
lib = env.SharedLibrary("boost_numpy", Glob("*.cpp"))
Return("lib")

View File

@@ -2,9 +2,7 @@
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifdef _MSC_VER
#include <boost/cstdint.hpp>
#endif
#define BOOST_NUMPY_INTERNAL
#include <boost/numpy/internal.hpp>
@@ -57,7 +55,6 @@ BUILTIN_INT_DTYPE(8);
BUILTIN_INT_DTYPE(16);
BUILTIN_INT_DTYPE(32);
BUILTIN_INT_DTYPE(64);
BUILTIN_FLOAT_DTYPE(16);
BUILTIN_FLOAT_DTYPE(32);
BUILTIN_FLOAT_DTYPE(64);
BUILTIN_COMPLEX_DTYPE(64);
@@ -90,32 +87,10 @@ python::detail::new_reference dtype::convert(python::object const & arg, bool al
int dtype::get_itemsize() const { return reinterpret_cast<PyArray_Descr*>(ptr())->elsize;}
bool equivalent(dtype const & a, dtype const & b) {
// On Windows x64, the behaviour described on
// http://docs.scipy.org/doc/numpy/reference/c-api.array.html for
// PyArray_EquivTypes unfortunately does not extend as expected:
// "For example, on 32-bit platforms, NPY_LONG and NPY_INT are equivalent".
// This should also hold for 64-bit platforms (and does on Linux), but not
// on Windows. Implement an alternative:
#ifdef _MSC_VER
if (sizeof(long) == sizeof(int) &&
// Manually take care of the type equivalence.
((a == dtype::get_builtin<long>() || a == dtype::get_builtin<int>()) &&
(b == dtype::get_builtin<long>() || b == dtype::get_builtin<int>()) ||
(a == dtype::get_builtin<unsigned int>() || a == dtype::get_builtin<unsigned long>()) &&
(b == dtype::get_builtin<unsigned int>() || b == dtype::get_builtin<unsigned long>()))) {
return true;
} else {
return PyArray_EquivTypes(
reinterpret_cast<PyArray_Descr*>(a.ptr()),
reinterpret_cast<PyArray_Descr*>(b.ptr())
);
}
#else
return PyArray_EquivTypes(
reinterpret_cast<PyArray_Descr*>(a.ptr()),
reinterpret_cast<PyArray_Descr*>(b.ptr())
);
#endif
}
namespace {
@@ -139,13 +114,9 @@ public:
static void * convertible(PyObject * obj) {
if (obj->ob_type == get_pytype()) {
return obj;
} else {
dtype dt(python::detail::borrowed_reference(obj->ob_type));
if (equivalent(dt, dtype::get_builtin<T>())) {
return obj;
}
} else {
return 0;
}
return 0;
}
static void convert(PyObject * obj, pyconv::rvalue_from_python_stage1_data* data) {
@@ -177,13 +148,6 @@ void dtype::register_scalar_converters() {
array_scalar_converter<npy_int16>::declare();
array_scalar_converter<npy_uint32>::declare();
array_scalar_converter<npy_int32>::declare();
#ifdef _MSC_VER
// Since the npy_(u)int32 types are defined as long types and treated
// as being different from the int32 types, these converters must be declared
// explicitely.
array_scalar_converter<boost::uint32_t>::declare();
array_scalar_converter<boost::int32_t>::declare();
#endif
array_scalar_converter<npy_uint64>::declare();
array_scalar_converter<npy_int64>::declare();
array_scalar_converter<float>::declare();

View File

@@ -12,19 +12,19 @@ namespace boost
namespace numpy
{
#if PY_MAJOR_VERSION == 2
static void wrap_import_array() {
import_array();
}
#if PY_MAJOR_VERSION >= 3
int
#else
static void * wrap_import_array() {
import_array();
}
void
#endif
do_import_array()
{
import_array();
}
void initialize(bool register_scalar_converters)
{
wrap_import_array();
do_import_array();
import_ufunc();
if (register_scalar_converters)
dtype::register_scalar_converters();