libpoly
libpoly copied to clipboard
make check on MacOS X
'make check' can be made to work on a Mac but it's hard.
Several issues get in the way:
-
pip doesn't work with the default system python because of openssl issues (don't know when that stopped working).
-
it's common to have several versions of python but they have to be installed outside of /usr/bin and /usr/lib where the system python lives.
-
the CMAKE find_package(PythonLibs) is not reliable. It may find /usr/lib/libpython2.7.dylib (i.e., the system version) instead of the version one actually wants.
The only way I got it to work is by finding the right library and forcing cmake to use it:
cmake -DPYTHON_LIBRARY=/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib
-DPYTHON_INCLUDE_DIR=/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
Yes, python seems to be a mess on Mac.
But in general on a Mac you do not want to be using the system python, especially since you need to install some extra packages. I currently can't do a make check
on my python2 machine.
No problems on my python3 machine. I will update once I solve this.
After a
brew install python@2
and a
pip2 install sympy
I did
cmake -DPYTHON_LIBRARY=/usr/local/Cellar/python@2/2.7.16_1/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib -DPYTHON_INCLUDE_DIR=/usr/local/Cellar/python@2/2.7.16_1/Frameworks/Python.framework/Versions/2.7/include/python2.7 ..
and make check
succeeded without any failures.
On my other laptop, where I only have a brew version of python3
the make check
worked out of the box, once I ported the libpoly/python
and libpoly/tests
to python3.
I have a couple of loose ends to tie up today, but I should be able to make a pull request with the port shortly.
Make sure it works for people who don't use brew.
And for contrast, without specifying the PYTHON_LIBRARY
and PYTHON_INCLUDE_DIR
, it
finds a python and dynamic library that don't match and the make check
crashes with
Fatal Python error: PyThreadState_Get: no current thread
I will look into the what happens to people who try and use the system python (contrary to Apple's advice), once the port is over.
I tried some cmake hack. Can you guys check if this works.
OK will try out now ...
Nope:
-- Found PythonInterp: /usr/local/opt/python@2/bin/python (found version "2.7.16")
-- Found PythonLibs: /usr/lib/libpython2.7.dylib (found version "2.7.16")
But does it crash? (Fatal Python error: PyThreadState_Get: no current thread
)
Amazing! No it doesn't crash. What sort of magic is this?
OK after my beach walk I will pull this into my python3 branch and see if it works there too.
facebook magic :-(
Ok, so I changed cmake to do the following:
- find python interpreter
- ~~use the interpreter to get the headers location~~ This doesn't work, reverted.
- link polypy to load python libraries at runtime as opposed to the one it was compiled with
So it works on my python3 port. Why do we need the PythonLibs stuff still?