Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failure on CentOS using cmake: return-statement with a value, in function returning 'void' #60

Closed
classfire opened this issue Jun 6, 2016 · 6 comments

Comments

@classfire
Copy link

Hello,
I'm trying to install boost.numpy on my CentOS 6.6 platform using cmake and python 3.5.0 and numpy 1.10.0:

cmake -DPYTHON_LIBRARY=/usr/local/lib/libpython3.5m.so -D Boost_NO_BOOST_CMAKE=ON ../

-- Configuring project "BoostNumpy"
:
:
ImportError: No module named 'sphinx'
-- - Sphinx not found, "make html" will do nothing at all.
-- Project "BoostNumpy" configured.
-- + Now, type-in "cd /root/BoostNumpy-master/build && make && make test && make html && make install"!
-- + "BoostNumpy" will be installed in /usr/local.
-- Configuring done
-- Generating done
-- Build files have been written to: /root/BoostNumpy-master/build

make

[ 8%] Building CXX object CMakeFiles/boost_numpy.dir/src/boost/numpy/numpy.cpp.o
/root/BoostNumpy-master/src/boost/numpy/numpy.cpp: In function ‘void boost::numpy::initialize()’:
/root/BoostNumpy-master/src/boost/numpy/numpy.cpp:50: error: return-statement with a value, in function returning 'void'
make[2]: *** [CMakeFiles/boost_numpy.dir/src/boost/numpy/numpy.cpp.o] Error 1
make[1]: *** [CMakeFiles/boost_numpy.dir/all] Error 2
make: *** [all] Error 2

Suggestions and advice appreciated!

Thank you

@TallJimbo
Copy link
Member

TallJimbo commented Jun 6, 2016

I think I know what's going on.

The return statement with a value is coming from the NumPy C API's import_array and/or import_ufunc macros (without those expanding, there is no line 50 in numpy.cc), and they're assuming they're being called directly within a Python 3 module initialization function. In Python 3, module initialization functions return PyObject* while Python 2's do not return anything. This is apparently contrary to the NumPy docs; this should probably be reported upstream.

Anyhow, you might be able to get it working if you just change the signature of boost::numpy::initialize to return PyObject*. That ought to imply some further changes in how you call it and check for errors, and it's not clear what the return value ought to be when there isn't a failure. But it might take me a while to get to a better fix for that, as I don't have Python 3 development environment setup at the moment, so I'm hoping this will tide you over.

@nbecker
Copy link
Contributor

nbecker commented Jun 6, 2016

In my code I have:

#if PY_MAJOR_VERSION == 2
static void wrap_import_array() {
import_array();
}
#else
static void * wrap_import_array() {
import_array();
}
#endif

On Mon, Jun 6, 2016 at 1:11 PM, Jim Bosch [email protected] wrote:

I think I know what's going on.

The return statement with a value is coming from the NumPy C API's
import_array and/or import_ufunc macros (without those expanding, there
is no line 50 in numpy.cc), and they're assuming they're being called
directly within a Python 3 module initialization function. In Python 3,
module initialization functions return PyObject* while Python 2's do not
return anything). This is apparently contrary to the NumPy docs
http://docs.scipy.org/doc/numpy-1.10.1/reference/c-api.array.html#c.import_array;
this should probably be reported upstream.

Anyhow, you might be able to get it working if you just change the
signature of boost::numpy::initialize to return PyObject*. That ought to
imply some further changes in how you call it and check for errors, and
it's not clear what the return value ought to be when there isn't a
failure. But it might take me a while to get to a better fix for that, as I
don't have Python 3 development environment setup at the moment, so I'm
hoping this will tide you over.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#60 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAHK0J9I9VvfdaP625RZJ_6Hx-B-X2Ynks5qJFSogaJpZM4IvF5z
.

Those who don't understand recursion are doomed to repeat it

@classfire
Copy link
Author

Hi,
I modified the return type of the initialize() function to PyObject_, in numpy.hpp and numpy.cpp. make and make install then proceeded satisfactorily. Running make test, however, has a similar error pattern to another open issue (#26):
`Running tests...
Test project /root/BoostNumpy-master/build
Start 1: dtype_test
1/4 Test #1: dtype_test ......................._**Failed Error regular expression found in output. Regex=[ERROR:] 1.05 sec
Start 2: ndarray_test
2/4 Test #2: ndarray_test ..................... Passed 0.16 sec
Start 3: indexing_test
3/4 Test #3: indexing_test .................... Passed 0.13 sec
Start 4: dstream_test
4/4 Test #4: dstream_test ..................... Passed 0.21 sec

75% tests passed, 1 tests failed out of 4

Total Test time (real) = 1.58 sec

The following tests FAILED:
1 - dtype_test (Failed)
Errors while running CTest
make: *** [test] Error 8
`
I see the "long()" function is used in dtype_test.py, something Python3 will not recognize?

Thank you.

@classfire
Copy link
Author

Yes, that fixed it: I commented out all the 'assertEquivalent()' calls that used long() in dtype_test.py and the test suite now passes.

@TallJimbo
Copy link
Member

Thanks for the testing, and I'm glad you've gotten it working. I'll try to work these into the master branch when I get a chance. If you have a patch (or a git fork) you'd be willing to contribute, that'd be even better.

TallJimbo added a commit that referenced this issue Jun 26, 2016
Improve support for Python 3.
@TallJimbo
Copy link
Member

Fixed merged to master at f1ffaac.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants