Skip to content

Use update-alternatives to manage additional Python versions #1172

@osechet

Description

@osechet

Hello,
When using the additionalVersions parameter of the python feature, would it be possible to register all the installed versions with update-alternatives?
It would make it easier to switch from one version to another one.
Alternative creation:

update-alternatives --install /usr/local/bin/python3 python3 /usr/local/python/3.12.7/bin/python3 1000 \
            --slave /usr/local/bin/pip3 pip3 /usr/local/python/3.12.7/bin/pip3

Alternative selection:

update-alternatives --set python3 /usr/local/python/3.12.7/bin/python3

Ideally, it would be even better if the installation path was limited to 3.x or if a symlink 3.x was pointing to the corresponding version:

3.10 -> 3.10.15
3.10.15
3.11 -> 3.11.10
3.11.10
3.12 -> 3.12.7
3.12.7
current -> 3.12.7

This way, the user doesn't have to know which specific version has been installed, only needs to know which main version they wants:

update-alternatives --set python3 /usr/local/python/3.12/bin/python3

or if alternatives are not installed:

rm /usr/local/python/current
ln -s 3.12 /usr/local/python/current

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions