View previous topic :: View next topic |
Author |
Message |
paulj Guru


Joined: 30 Sep 2004 Posts: 526 Location: Wales, UK
|
Posted: Thu Jan 27, 2022 9:51 am Post subject: default python version |
|
|
I have not configured any specific setting for python on my system, and at the moment I have several versions installed:
Code: |
[I] dev-lang/python
Available versions:
(2.7) 2.7.18_p13{tbz2}
(3.6) 3.6.15(3.6/3.6m)^t
(3.7) 3.7.12_p1(3.7/3.7m)^t
(3.8) 3.8.12_p1-r1^t
(3.9) 3.9.9-r1^t{tbz2} ~3.9.10^t
(3.10) 3.10.0_p1-r1^t{tbz2} ~3.10.1-r2^t ~3.10.1-r3^t ~3.10.2^t
(3.11) ~3.11.0_alpha3^t ~3.11.0_alpha4^t
{berkdb bluetooth build examples gdbm hardened libedit lto +ncurses pgo +readline +sqlite +ssl test tk verify-sig wininst +xml}
Installed versions: 2.7.18_p13(2.7){tbz2}(15:36:20 08/01/22)(bluetooth gdbm ncurses readline sqlite ssl xml -berkdb -build -examples -hardened -tk -verify-sig -wininst) 3.9.9-r1(3.9)^t{tbz2}(12:13:47 19/01/22)(bluetooth gdbm ncurses readline sqlite ssl xml -build -examples -hardened -lto -pgo -test -tk -verify-sig -wininst) 3.10.0_p1-r1(3.10)^t{tbz2}(12:19:54 19/01/22)(bluetooth gdbm ncurses readline sqlite ssl xml -build -examples -hardened -lto -pgo -test -tk -verify-sig -wininst)
Homepage: https://www.python.org/
Description: An interpreted, interactive, object-oriented programming language
|
When I run python, the version loaded is 3.9.9 - not version 3.10. From my understanding of the wiki pages, I can install python-exec to select a version for the local user account. However, I don't need a specific version - I am just surprised that the system isn't selecting the latest automatically. Do I need to set something to make this happen?
Thanks! |
|
Back to top |
|
 |
fedeliallalinea Administrator


Joined: 08 Mar 2003 Posts: 31587 Location: here
|
Posted: Thu Jan 27, 2022 10:18 am Post subject: |
|
|
This happens because dev-lang/python-3.10 is marked stable but not the PYTHON_TARGETS python3_10 so the packages with PYTHON_TARGETS compile yet with python3_9. _________________ Questions are guaranteed in life; Answers aren't. |
|
Back to top |
|
 |
Ionen Developer


Joined: 06 Dec 2018 Posts: 2915
|
Posted: Thu Jan 27, 2022 10:27 am Post subject: |
|
|
Python has a tendency to deprecate things and break old scripts with about every new versions, so Gentoo goes for the safer approach of testing packages before marking them as "python 3.10 compatible" rather than always "use latest".
Then PYTHON_TARGETS and PYTHON_SINGLE_TARGET will decide which python version an installed package will use, e.g. if a package is installed only for python3.8, it will use python3.8 even if your default `python --version` is reporting 3.9.
As noted above, currently profiles are setting those to use python 3.9 given 3.10 support is still work-in-progress (you can use it if you know what you're doing, but generally it's simpler to just use profile versions). Portage does have a tendency to install the latest version of python even if it's not really used (yet) though...
`python --version` is really the version that /you/ want to use (e.g. if you had a random python script in /home/user/bin). By default it'll use the same value as PYTHON_TARGETS given it's what your python libraries are installed for and it makes it a more useful version. This can be configured manually but it's typically handled by dev-lang/python-exec-conf package (replaces the old eselect-python to allow auto-updating based on targets while going through dispatch-conf/etc-update only if you modified it).
...so it is automatic but just doesn't pick latest.
That aside, you could probably get rid of a few version by `emerge --depclean` though, 3.6 through 3.8 shouldn't be needed anymore. python2.7 is still needed to build qtwebengine right now and few other obscure things. |
|
Back to top |
|
 |
paulj Guru


Joined: 30 Sep 2004 Posts: 526 Location: Wales, UK
|
Posted: Thu Jan 27, 2022 12:00 pm Post subject: |
|
|
The approach to ensure the correct python version is run for a package is elegant - I was just surprised that running python from the shell doesn't select the latest version. Running "python3.10" works as expected.
my make.conf doesn't define PYTHON_TARGETS and PYTHON_SINGLE_TARGET any more - I removed this last year.
Anyway, for what I am doing, 3.9 is fine, I was just intrigued! Thanks to you both for the explanations! |
|
Back to top |
|
 |
fedeliallalinea Administrator


Joined: 08 Mar 2003 Posts: 31587 Location: here
|
Posted: Thu Jan 27, 2022 12:14 pm Post subject: |
|
|
paulj wrote: | The approach to ensure the correct python version is run for a package is elegant - I was just surprised that running python from the shell doesn't select the latest version. Running "python3.10" works as expected. |
This happens because if you don't have python-exec installed the system use dev-lang/python-exec-conf to select the python command line version and this package follow the PYTHON_TARGETS. _________________ Questions are guaranteed in life; Answers aren't. |
|
Back to top |
|
 |
|