Thank you.<div><br></div><div>At the end, I realized that I could just call the standard Python installer from CMake. This led to a more reliable install process and also a vastly cleaner CMakeLists.txt file. My line for installing the Python code is simply:</div>
<div><br></div><div>install(CODE "execute_process(COMMAND python setup.py install -f --prefix=${CMAKE_INSTALL_PREFIX} WORKING_DIRECTORY ../source/libmoleculizer-1.1.2/python-src/language_parser)")</div><div><br>
</div><div>This works well on both of my Macs. With luck, it will work more broadly, too. We'll see...</div><div><br></div><div>Thanks again for all the help.</div><div><br></div><div>-Steve</div><div><br></div><div>
<br><br><div class="gmail_quote">On Wed, Mar 27, 2013 at 3:32 AM, Hendrik Sattler <span dir="ltr"><<a href="mailto:post@hendrik-sattler.de" target="_blank">post@hendrik-sattler.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Am 2013-03-27 05:46, schrieb Steve Andrews:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thats very helpful. Thank you.<div class="im"><br>
<br>
My other question was about how to get CMake to create directories at<br>
installation time. Do you, or someone else, have suggestions about<br>
that? Despite your advice, I think that I want the "make install"<br>
step to put Python files into<br>
/usr/local/lib/python2.5/site-<u></u>packages/moleculizer, at least as the<br></div>
default path. Depending on what the users system already has, I may<div class="im"><br>
need to create one or more levels of this hierarchy. Do you know if<br>
there is a way to create this directory structure, as needed, during<br>
the install step?<br>
<br>
Thanks,<br>
-Steve<br>
<br></div>
On Tue, Mar 26, 2013 at 4:28 PM, Andreas Pakulat <<a href="mailto:apaku@gmx.de" target="_blank">apaku@gmx.de</a> [1]><br>
wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
Hi,<br>
<br>
Am Dienstag, 26. März 2013 schrieb sandrews :<br>
<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
Hi,<br>
<br>
My project is primarily C and C++, but also includes some Python<br>
code. I<br>
can get everything to build fine, and my CMakeLists.txt files<br>
uses the<br>
INSTALL(TARGETS ...) to so that the user can install the compiled<br>
code to<br>
the proper place. However, part of the installation is to copy<br>
the Python<br></div>
files over to their proper places, too, and this isnt working.<div class="im"><br>
<br>
First of all, where should Python files go? On my Mac, I put<br>
them in<br>
/usr/local/lib/python2.5/site-<u></u>packages. Of course though, this<br>
directory<br>
would be different if I had a different version of Python.<br>
Also, I expect<br></div>
its different on different platforms. Does CMake automatically<div class="im"><br>
know where<br>
the Python files should go and, if so, how do I access that?<br>
(For example,<br>
the INSTALL(TARGETS...) command does know where targets are<br>
supposed to go<br>
for different platforms.)<br>
</div></blockquote><div class="im">
<br>
<br>
No, cmake does not know about this as python apps are usually<br>
installed with python tools like distutils, setuptools etc. That<br>
beingsaid cmake does ship modules to find a python interpreter and<br>
that one can be queried about its search path. Along with the<br>
install command (using the FILES variant) you can have cmake copy<br>
your python code where you want it.<br>
<br>
However you should think twice before writing cmake code that<br>
installs stuff outside thecmake prefix. This is usually unexpected<br>
by cmake users, can turn out to be impossible (the user might not be<br>
able to writeto thepython install directory) or trip up packaging<br>
tools (such as cpack).<br>
<br>
On the other hand, having python files in something like $HOME/myapp<br>
does require an extra environment variable to be set in order for<br>
python to find the code there. Thats something that python users are<br>
possibly used to though.<br>
</div></blockquote></blockquote>
<br>
I had the same problem when trying to find a proper location for installing<br>
a SWIG Python module. CMake helps building it but lacks on the installation<br>
part :-/<br>
<br>
I did it like this:<br>
find_package ( PythonLibs REQUIRED )<br>
find_package ( PythonInterp REQUIRED )<br>
<br>
if ( PYTHON_VERSION_STRING AND PYTHONLIBS_VERSION_STRING )<br>
if ( NOT PYTHON_VERSION_STRING VERSION_EQUAL PYTHONLIBS_VERSION_STRING )<br>
message ( FATAL_ERROR<br>
"Version mismatch between python interpreter and libraries" )<br>
endif ( NOT PYTHON_VERSION_STRING VERSION_EQUAL PYTHONLIBS_VERSION_STRING )<br>
endif ( PYTHON_VERSION_STRING AND PYTHONLIBS_VERSION_STRING )<br>
<br>
include_directories ( ${PYTHON_INCLUDE_DIRS} )<br>
<br>
....target..setup....<br>
<br>
execute_process (<br>
COMMAND ${PYTHON_EXECUTABLE} -c<br>
"import site, sys; sys.stdout.write(site.<u></u>PREFIXES[-1])"<br>
OUTPUT_VARIABLE PYTHON_PREFIX<br>
)<br>
file ( TO_CMAKE_PATH "${PYTHON_PREFIX}" PYTHON_PREFIX )<br>
execute_process (<br>
COMMAND ${PYTHON_EXECUTABLE} -c<br>
"import site, sys; sys.stdout.write(site.<u></u>getsitepackages()[-1])"<br>
OUTPUT_VARIABLE PYTHON_SITE_DIR<br>
)<br>
file ( TO_CMAKE_PATH "${PYTHON_SITE_DIR}" PYTHON_SITE_DIR )<br>
string ( REGEX REPLACE "^${PYTHON_PREFIX}/" ""<br>
PYTHON_SITE_DIR "${PYTHON_SITE_DIR}"<br>
)<br>
<br>
install ( TARGETS ${SWIG_MODULE_obexftp-python_<u></u>REAL_NAME}<br>
LIBRARY<br>
DESTINATION ${PYTHON_SITE_DIR}<br>
COMPONENT library<br>
)<br>
<br>
install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/<u></u>obexftp.py<br>
DESTINATION ${PYTHON_SITE_DIR}<br>
COMPONENT library<br>
)<br>
<br>
<br>
My setup is similar for Perl and Ruby SWIG modules as the problem is the same<br>
there.<span class="HOEnZb"><font color="#888888"><br>
<br>
HS</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/<u></u>opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/<u></u>CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/<u></u>listinfo/cmake</a></div></div></blockquote></div><br></div>