[Bug 252277] cmake find_package(python3...) fails to get default python version

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Sun Apr 10 14:10:54 BST 2022


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=252277

Adriaan de Groot <adridg at freebsd.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|New                         |In Progress

--- Comment #10 from Adriaan de Groot <adridg at freebsd.org> ---
Where is this DEFAULT_VERSIONS set? How are you testing it?

The (old-style) PythonInterp runs `python3` and/or `python` to find whatever
version that points to, and pretends that that is the preferred version.
There's no specific reference to FreeBSD's default versions. If you have a
program named `python3` in your $PATH, then that will be the version of Python3
that is found-by-default.

As an illustration:

```
[adridg at beastie /tmp/pr-252277]$ ln -s `which python3.7` ~/bin/python3
[adridg at beastie /tmp/pr-252277]$ which python3
/home/adridg/bin/python3
```

Here, the example CMakeLists.txt will find Python 3.7. Re-jig the link to point
to Python 3.9 and then that is what is found. This works for **me** because
~/bin is in my $PATH. In many installations, the *python3* metaport installs a
link to some default Python version, and that gets picked up.

If there is **no** `python3` in $PATH, then you'll find the highest-versioned
Python3 that is installed.

[[ it **is** quite true, though, that finding PythonInterp and finding Python3
behave very differently, because the latter doesn't run `python3` for
versioning. ]]

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the kde-freebsd mailing list