[CMake] Re: Boost.Python Install
Malte Clasen
news at copro.org
Sat Feb 17 16:18:42 EST 2007
Aaron Spike wrote:
> What are the best practices in using CMake to build and install
> python extensions written with Boost.Python? I've succeeded in building
> a python wrapper in this way, but I'm not sure everything is being done
> correctly yet. Installation seems to be a bigger hurdle for me now. I
> would very much appreciate any advice and any pointers to projects that
> are successfully combining Boost.Python and CMake.
We install the .pyd to the same location as all other shared libraries.
The tricky part is getting python to find them there. We use the
__init__.py scripts to import the .pyd modules after extending the
search path. It works roughly as follows:
"/src/pyApp" contains the python applicaton, "/src/pyLib" the library.
The compiled modules are located in "/bin". When pyApp tries to import
pyLib, python calls /src/pyLib/__init__.py. This script adds /bin to
sys.path, imports the compiled module using "from XY import *" and
restores the original sys.path.
This approach can be extended to support different releases, either by
path (add /bin/debug to sys.path) or by postfix (import XY_d). We've
been using this way for about 8 months now and it works just fine.
Best regards,
Malte
More information about the CMake
mailing list