-
Notifications
You must be signed in to change notification settings - Fork 22
Python virtual environment
Mayeul d'Avezac edited this page Apr 11, 2014
·
1 revision
include(PythonVirtualEnv)
It creates a python virtual environment inside the build tree. The environment can be accessed in CMake scripts via ${LOCAL_PYTHON_EXECUTABLE}
, and within the shell via the localpython.sh
scripts. All arguments to this script are passed on to python.
The script is setup to read from a pypaths
(ldpaths
) file and add each line to the PYTHONPATH
(LD_LIBRARY_PATH
and DYLD_LIBRARY_PATH
) environment variable. Thus is is possible to setup the script to know about python modules (shared libraries) located within the build tree.
add_to_python_path("path/to/module/directory/in/build/tree")
add_to_ld_path("path/to/shared/library/directory/in/build/tree")
The two functions above make it easier to add paths to the relevant files directly from CMake.
Finally, a function is provided to install packages within the virtual environment:
add_package_to_virtualenv(pytest)
It will use pip to do the actual work.