Skip to content

add PyEnv and CMake FindPython caveats to pyenv reference - #4559

Merged
czoido merged 2 commits into
conan-io:release/2.33from
davidsanfal:docker_runner_vars
Oct 16, 2026
Merged

czoido merged 2 commits into
conan-io:release/2.33from
davidsanfal:docker_runner_vars

Conversation

@davidsanfal

Copy link
Copy Markdown
Contributor

No description provided.

@memsharded memsharded added this to the 2.34 milestone Oct 7, 2026
Comment thread reference/tools/system/pyenv.rst Outdated
Comment on lines +107 to +108
- **CMake FindPython search order**: by default, `FindPython <https://cmake.org/cmake/help/latest/module/FindPython.html>`_ does not
just look for ``python`` or ``python3`` in the ``PATH``. It also looks for *versioned* executables (like ``python3.13``),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rephrase it and just mention that a python in PATH is not always prioritised, and leave details aside, and follow that FindPython may prefer a different python installation.

Comment thread reference/tools/system/pyenv.rst Outdated
Comment on lines +114 to +115
Conan does not set the ``VIRTUAL_ENV`` environment variable when generating the ``PyEnv`` environment, because it is read by Python
itself and it could interfere with other Python executions.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as my earlier comment, I'd leave "details" out
The relevant info:

  • FindPython does not prioritise python/python3 in PATH (which is what the PyEnv generator exposes)
  • we need to set Python_ROOT_DIR and possibly Python_FIND_VIRTUALENV

Comment thread reference/tools/system/pyenv.rst Outdated
Comment on lines +145 to +146
tc.cache_variables["Python_FIND_VIRTUALENV"] = "STANDARD"
tc.cache_variables["Python_ROOT_DIR"] = pyenv.env_dir

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quick one here, have we double check that Python_FIND_VIRTUALENV is required in the presence of the env var being defined? I'd have thought that Python_ROOT_DIR gave that one the highest priority?
or if Python_EXECUTABLE skips the search, I would just document that one and not mention this

Comment thread reference/tools/system/pyenv.rst Outdated
Comment on lines +155 to +157
tc.cache_variables["Python_FIND_UNVERSIONED_NAMES"] = "FIRST"
tc.cache_variables["Python_FIND_STRATEGY"] = "LOCATION"
tc.cache_variables["Python_FIND_REGISTRY"] = "NEVER"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the above are sufficient, I would leave these out too - the goal is to provide the quickest way to guarantee that FindPython finds the one we want, these seem redundant

@davidsanfal
davidsanfal requested a review from jcar87 October 13, 2026 12:16

@jcar87 jcar87 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@czoido
czoido merged commit 44f0222 into conan-io:release/2.33 Oct 16, 2026
4 checks passed
@czoido czoido removed this from the 2.34 milestone Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants