Building C Extensions on MacOS

Issue #2577 new
Omer Ben-Amram
created an issue

When building c extensions on macos sierra - pypy3 doesn't seem to add the libpypy3-c shared object (dylib) to the link command.

settings LDFLAGS to -L<path_to_pypy> -lpypy3-c solves the issue.

Comments (7)

  1. Amber Brown

    I'm noticing this too. To repeat:

    brew install pypy3
    pypy3 -m virtualenv venv
    venv/bin/python pypy3 -m pip install numpy

    Adding env LDFLAGS="-L/usr/local/Cellar/pypy3/5.8.0/lib/ -lpypy3-c" works fine.

  2. Armin Rigo

    Sorry, as I have no easy access to an OS X box, I cannot do anything about that. It's probably a matter of tweaking a file in lib-python/3/distutils/. A patch would be welcome.

  3. Min RK

    Since pypy3-c is linked in the pypy3 binary, this should be fixed by adding -undefined dynamic_lookup which is in the default ldflags on pypy2 (and all versions of cpython), but not pypy3. PR 564 fixes this by copying the same snippet that sets these flags on 2.7 to the 3 branch, I believe.

    Also note that the LDFLAGS would differ depending on how pypy is installed. Homebrew patches pypy installs to put libpypy-c in /lib/, but pypy dists install the lib in /bin/ (a bug, I think: #2630).

  4. Min RK

    I just finished building pypy from the py3.5 branch with that PR merged, and it is able to build and load my Extension now without any extra LDFLAGS, where 5.8 could not.

  5. Log in to comment