libpoly icon indicating copy to clipboard operation
libpoly copied to clipboard

make check on MacOS X

Open BrunoDutertre opened this issue 6 years ago • 13 comments

'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

BrunoDutertre avatar Apr 19 '18 12:04 BrunoDutertre

Yes, python seems to be a mess on Mac.

dddejan avatar Apr 19 '18 14:04 dddejan

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.

ianamason avatar Sep 25 '19 23:09 ianamason

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.

ianamason avatar Sep 26 '19 15:09 ianamason

Make sure it works for people who don't use brew.

BrunoDutertre avatar Sep 26 '19 15:09 BrunoDutertre

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.

ianamason avatar Sep 26 '19 15:09 ianamason

I tried some cmake hack. Can you guys check if this works.

dddejan avatar Sep 26 '19 23:09 dddejan

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")

ianamason avatar Sep 26 '19 23:09 ianamason

But does it crash? (Fatal Python error: PyThreadState_Get: no current thread)

dddejan avatar Sep 27 '19 00:09 dddejan

Amazing! No it doesn't crash. What sort of magic is this?

ianamason avatar Sep 27 '19 00:09 ianamason

OK after my beach walk I will pull this into my python3 branch and see if it works there too.

ianamason avatar Sep 27 '19 00:09 ianamason

facebook magic :-(

ianamason avatar Sep 27 '19 00:09 ianamason

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

dddejan avatar Sep 27 '19 00:09 dddejan

So it works on my python3 port. Why do we need the PythonLibs stuff still?

ianamason avatar Sep 27 '19 01:09 ianamason