Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better Python detection #27

Open
ryanmrichard opened this issue Aug 15, 2022 · 0 comments
Open

Better Python detection #27

ryanmrichard opened this issue Aug 15, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@ryanmrichard
Copy link
Member

ryanmrichard commented Aug 15, 2022

Despite running my build in a Python virtual environment, created by /usr/bin/python3, CMake somehow manages to find /usr/bin/python3.11 (FWIW /usr/bin/ptyon3 is a sym link of 3.8). IMHO it should first find the virtual environment version (arguably that's the whole point of the virtual environment), but it would also be understandable if it found /usr/bin/python3 (albeit less desirable). The fact that it found python3.11 is unexpected (at least to me).

Here is where Python is detected. Off the top of my head I'm not sure what needs to change to make the detection more reasonable.

Edit: it looks like a workaround is for the user to add set(Python3_FIND_VIRTUALENV ONLY) to their toolchain. Maybe we can resolve this issue by setting Python3_FIND_VIRTUALENV to FIRST (if it's not set) before calling find_package(Python3)?

Edit 2: CMake seems to still be finding /usr/bin/python3.11 for me, even after setting Python3_FIND_VIRTUALENV to ONLY. Hmm...

Edit 3: Tried adding set(Python3_ROOT_DIR /path/to/venv) to my toolchain.cmake and still am getting /usr/bin/python3.11...

Edit 4: Finally got it to work by adding set(Python3_EXECUTABLE /path/to/venv/bin/python3) in my toolchain file.

@ryanmrichard ryanmrichard added the enhancement New feature or request label Aug 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant