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

make check on MacOS X #15

Open
BrunoDutertre opened this issue Apr 19, 2018 · 13 comments
Open

make check on MacOS X #15

BrunoDutertre opened this issue Apr 19, 2018 · 13 comments
Assignees

Comments

@BrunoDutertre
Copy link
Member

'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
@dddejan
Copy link
Member

dddejan commented Apr 19, 2018

Yes, python seems to be a mess on Mac.

@dddejan dddejan self-assigned this Apr 19, 2018
@ianamason
Copy link
Member

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
Copy link
Member

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.

@BrunoDutertre
Copy link
Member Author

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

@ianamason
Copy link
Member

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.

@dddejan dddejan reopened this Sep 26, 2019
@dddejan
Copy link
Member

dddejan commented Sep 26, 2019

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

@ianamason
Copy link
Member

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

@dddejan
Copy link
Member

dddejan commented Sep 27, 2019

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

@ianamason
Copy link
Member

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

@ianamason
Copy link
Member

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

@ianamason
Copy link
Member

facebook magic :-(

@dddejan
Copy link
Member

dddejan commented Sep 27, 2019

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

@ianamason
Copy link
Member

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

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