[CMake] Installing Python files

Andreas Pakulat apaku at gmx.de
Tue Mar 26 19:28:13 EDT 2013


Hi,

Am Dienstag, 26. März 2013 schrieb sandrews :

> Hi,
>
> My project is primarily C and C++, but also includes some Python code.  I
> can get everything to build fine, and my CMakeLists.txt files uses the
> INSTALL(TARGETS ...) to so that the user can install the compiled code to
> the proper place.  However, part of the installation is to copy the Python
> files over to their proper places, too, and this isn't working.
>
> First of all, where should Python files go?  On my Mac, I put them in
> /usr/local/lib/python2.5/site-packages.  Of course though, this directory
> would be different if I had a different version of Python.  Also, I expect
> it's different on different platforms.  Does CMake automatically know where
> the Python files should go and, if so, how do I access that?  (For example,
> the INSTALL(TARGETS...) command does know where targets are supposed to go
> for different platforms.)


No, cmake does not know about this as python apps are usually installed
with python tools like distutils, setuptools etc. That beingsaid cmake does
ship modules to find a python interpreter and that one can be queried about
its search path. Along with the install command (using the FILES variant)
you can have cmake copy your python code where you want it.

However you should think twice before writing cmake code that installs
stuff outside thecmake prefix. This is usually unexpected by cmake users,
can turn out to be impossible (the user might not be able to writeto
thepython install directory) or trip up packaging tools (such as cpack).

On the other hand, having python files in something like $HOME/myapp does
require an extra environment variable to be set in order for python to find
the code there. Thats something that python users are possibly used to
though.

Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130327/77648f6b/attachment.htm>


More information about the CMake mailing list