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

PyPy support #64

Closed
wants to merge 24 commits into from
Closed

PyPy support #64

wants to merge 24 commits into from

Conversation

jamadden
Copy link
Contributor

This PR brings support for PyPy 2.5.0 and above (tested with 2.5.0 and 2.6.0 on Linux and 2.5, 2.6, and 2.7 on OS X). All the tests pass on Travis.

The major change is in graphviz.i's unwrapping of FILE* objects. On PyPy, the PyFile_AsFile function is not supported, so we go with the codepath that Python 3 uses. This of course required the .c file to get rebuilt, and I used the most current version of SWIG available to do so---which complained about syntax in the copyright header lines ("Error: Unknown SWIG preprocessor directive: Copyright", etc). I wasn't sure what to do there; hopefully a comment is ok.

(There's also some automatic whitespace cleanup in the .i file; emacs does that automatically and I forgot to turn that off, but I can restore the whitespace if necessary to make the diff cleaner.)

The other notable change has to do with a build-time issue. I couldn't figure out how to get PyPy on Travis (or a local Linux) to properly link and load the graphviz libraries with the PyPy module, so I took the blunt approach with LD_PRELOAD. I then had to undo this hammer in agraph.py. I'd like to have a better way, but at least this gets things working.

I'm happy to make any adjustments needed. This is my first time contributing to this project.

The crashes in PyFile_AsFile are gone (that method is unimplemented) by using the same code path that python 3 does.

There is a floating point exception on OS X with PyPy 2.6.0, not sure what that is, trying to reproduce on Travis.

Swig module rebuilt with 3.0.6.
@hagberg
Copy link
Contributor

hagberg commented Aug 15, 2015

Thanks for looking into this. It seems pretty straightforward to add pypy support this way. It would be good to figure out how to do the build/link correctly.

@jamadden
Copy link
Contributor Author

I totally agree, but I'm just about out of ideas. It works perfectly on OS X, there's only a problem on Linux. The complier args look correct there, though. I'm guessing its something to do with "as needed" link removal, something that maybe differs between gcc and clang, but I haven't so far come up with what to do about it. Any ideas are welcome!

At any rate, this is a blocker for us and probably others using pypy in production, so at least this much works :)

@jamadden
Copy link
Contributor Author

It turned out that simply putting the libraries in their dependency order in setup.py fixed the issues under GCC/GNU ld. No more LD_PRELOAD!

The crashes in PyFile_AsFile are gone (that method is unimplemented) by using the same code path that python 3 does.

Swig module rebuilt with 3.0.7.
@jamadden
Copy link
Contributor Author

If there's anything I can do to facilitate this, please let me know.

@dmr dmr mentioned this pull request Aug 25, 2015
@jamadden jamadden mentioned this pull request Sep 16, 2015
@jamadden
Copy link
Contributor Author

Closing in favor of #75.

@jamadden jamadden closed this Sep 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants