Skip to content

Latest commit

 

History

History
82 lines (62 loc) · 2.97 KB

hunter_venv.rst

File metadata and controls

82 lines (62 loc) · 2.97 KB

venv

single: python ; hunter_venv

hunter_venv

This package is used to create an isolated Python environment inside Hunter and is a workaround for missing Python package. It is designed to be used with FindPython module. CMake 3.13 is a minimum required (see details below).

/../examples/hunter_venv/CMakeLists.txt

Python version that will be used to create environment can be set by HUNTER_VENV_PYTHON_VERSION variable:

# local config.cmake

hunter_config(
    hunter_venv
    VERSION ${HUNTER_hunter_venv_VERSION}
    CMAKE_ARGS HUNTER_VENV_PYTHON_VERSION=3.6.7
)

Requested Python version and virtualenv should be installed in a system.

Default values for HUNTER_VENV_PYTHON_VERSION will match testing CI environment of Travis/AppVeyor machines:

/../cmake/projects/hunter_venv/hunter.cmake

At this moment the procedure of making a relocatable Python environment is not robust (see virtualenv issue #1169). Because of that activate and deactivate scripts removed from the created environment and for other scripts shebangs set to general #!/usr/bin/env python value. It means that before running a Python script, you will have to set the PATH environment variable accordingly. As a more convenient and less error-prone approach, you can use the Python_EXECUTABLE variable:

/../examples/hunter_venv/CMakeLists.txt

/../examples/hunter_venv/CMakeLists.txt

/../examples/hunter_venv/CMakeLists.txt

While calling find_package(hunter_venv CONFIG REQUIRED) variables Python*_FIND_REGISTRY and CMAKE_FIND_FRAMEWORK will be set to NEVER. Otherwise, find_package(Python REQUIRED) will return Python executable from the system instead of Python from created virtual environment: