[CMake] Running Python unit tests importing modules built in CMake
Bradley Lowekamp
blowekamp at mail.nih.gov
Thu May 3 09:12:04 EDT 2012
Hello,
For testing python another alternative is to create a python virtual environment and install you python package into that. Here is an example of how I have done that:
https://github.com/SimpleITK/SimpleITK/blob/master/Wrapping/CMakeLists.txt#L97
Brad
On May 2, 2012, at 9:26 PM, David Cole wrote:
> Are you using "add_test" to add the tests in the CMakeLists file?
>
> If so, you can set the test ENVIRONMENT property to set PYTHONPATH
> when ctest executes the test. See property doc here:
>
> http://cmake.org/cmake/help/v2.8.8/cmake.html#prop_test:ENVIRONMENT
>
>
> On Wed, May 2, 2012 at 5:17 PM, Lori A. Pritchett-Sheats
> <lpritch at lanl.gov> wrote:
>> I'm building Python modules using SWIG and CMake, and have run into a
>> problem running Python unit tests for these built modules. I can not find a
>> slick way to set the Python module search path when running the test. The
>> usual trick of setting sys.path in the scripts will not work here because I
>> don't know the location of the build directory. I've tried updating
>> PYTHONPATH in my CMakeList.txt file but that change isn't picked up when the
>> test is executed. I could create the unit test modules at build time using
>> CONFIGURE_FILE replacing @CMAKE_CURRENT_BINARY_DIR@ in a sys.path line, but
>> that seems heavy-handed. Has anyone else run into this problem and found
>> better a solution?
>>
>> --
>> Lori A. Pritchett-Sheats, PhD.
>> CCS-2, Computational Physics and Methods
>> Office: 505-665-6675
>> Fax: 505-665-4972
>>
>> Los Alamos National Laboratory
>> P.O. Box 1663
>> MS D413
>> Los Alamos, NM 87544
>>
>> --
>>
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.cmake.org/mailman/listinfo/cmake
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
========================================================
Bradley Lowekamp
Medical Science and Computing for
Office of High Performance Computing and Communications
National Library of Medicine
blowekamp at mail.nih.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120503/69b2920d/attachment-0001.htm>
More information about the CMake
mailing list