Skip to content

make check on MacOS X #15

Open
Open

Description

@BrunoDutertre

'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

Activity

  1. dddejan commented on Apr 19, 2018

    @dddejan
    Collaborator

    Yes, python seems to be a mess on Mac.

  2. self-assigned this
    on Apr 19, 2018
  3. ianamason commented on Sep 25, 2019

    @ianamason
    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.

  4. ianamason commented on Sep 26, 2019

    @ianamason
    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.

  5. BrunoDutertre commented on Sep 26, 2019

    @BrunoDutertre
    CollaboratorAuthor

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

  6. ianamason commented on Sep 26, 2019

    @ianamason
    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.

  7. dddejan commented on Sep 26, 2019

    @dddejan
    Collaborator

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

  8. ianamason commented on Sep 26, 2019

    @ianamason
    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")
    
  9. dddejan commented on Sep 27, 2019

    @dddejan
    Collaborator

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

  10. ianamason commented on Sep 27, 2019

    @ianamason
    Member

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

  11. ianamason commented on Sep 27, 2019

    @ianamason
    Member

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

  12. ianamason commented on Sep 27, 2019

    @ianamason
    Member

    facebook magic :-(

  13. dddejan commented on Sep 27, 2019

    @dddejan
    Collaborator

    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
  14. ianamason commented on Sep 27, 2019

    @ianamason
    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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions