So I would have to do it the hard way. Fortunately, SCons makes it very easy to develop custom Builders. So after a couple of hours I had a working Pyrex Builder.
It could have been done quicker, If the LIBPATH keyword in the SharedLibrary function worked the way I expected. One other Annoyance was the fact that SCons prepends 'lib' to the name of a shared library, not respecting your wishes. This turned out to be a real problem: I painfully found out that if the name of the .so is not the same as the original .pyx source, You get an importError. I fixed that by manually renaming the .so file. If anyone knows of a better solution to this problem, please post a comment.
I also did not test this for building multiple files and other variations. If anyone feels like trying, please let me know how it goes.
here is the SConstruct code:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCY_Mt6hQtCuHG6Lx2wR-vVhbPQUu8rrAPObLpPVSocaDSjUxlVqP0JU1upxQBOZu3SdZsNhSaRGPwJKEY-sPfX2KeXDvCJK-YRdrvcXPp_fa-tfnw6vlmLz8MxixIfgbOqnaaJKKY_NU/s400/SConstruct.png)
2 comments:
env.SharedLibrary('primespyx', ['primespyx.c'], LIBPREFIX = '')
removes the need to rename. I found this useful, thank you.
Thanks for the tip, Greg.
Post a Comment