[CMake] Installing Python files

Steve Andrews steven.s.andrews at gmail.com
Wed Mar 27 00:46:46 EDT 2013


That's very helpful.  Thank you.

My other question was about how to get CMake to create directories at
installation time.  Do you, or someone else, have suggestions about that?
 Despite your advice, I think that I want the "make install" step to put
Python files into /usr/local/lib/python2.5/site-packages/moleculizer, at
least as the default path.  Depending on what the user's system already
has, I may need to create one or more levels of this hierarchy.  Do you
know if there is a way to create this directory structure, as needed,
during the install step?

Thanks,
-Steve


On Tue, Mar 26, 2013 at 4:28 PM, Andreas Pakulat <apaku at gmx.de> wrote:

> 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/20130326/fa8af52f/attachment.htm>


More information about the CMake mailing list