[bug] Environment created with PyEnv is not detected by CMake
Describe the bug
Environment details:
- Oracle 9
- Python 3.9
- Conan 2.31.2
- CMake 3.31
When a Python package is installed with PyEnv the generated environment .sh file sets PATH which should be enough in most cases. However, if Conan is already used from a virtual environment and CMake is involved in the build then CMake will not detect the PyEnv environment. It seems that CMake prioritizes Python installations in virtual environments by checking the VIRTUAL_ENV environment variable and because that points to the original virtual environment the PyEnv environment is invisible for CMake
How to reproduce it
The attached conanfile.py and CMakeLists.txt file helps reproduce the problem. The CMake project requires NumPy and if conan build is run outside of a virtual environment then it detects NumPy installed into the created PyEnv (a message() is added to CMakeLists.txt to print where Python and NumPy is according to CMake).
However, if there is an active virtual environment without NumPy installed then conan build will fail. If NumPy is installed into the virtual environment then conan buld succeeds but Python and NumPy will come from the original virtual environment and not from PyEnv
Source: conan-io/conan