diff --git a/admin-guide/configuration/packages.md b/admin-guide/configuration/packages.md index 236cb27d..bf28064b 100644 --- a/admin-guide/configuration/packages.md +++ b/admin-guide/configuration/packages.md @@ -68,19 +68,24 @@ Note that this tag can be combined with the `latest` and `absent` tag. RHEL 8 introduced the concept of [module streams](https://docs.pagure.org/modularity/). A specific stream can be selected with the `stream` tag: -``` + +```yaml base::pkg_group::nodejs: - 'nodejs:stream=12' ``` ## Install Python Modules with `pip` -The `pip` tag can be used to install Python module using `pip`, e.g. `pygame-utility`: -``` +The `pip` tag can be used to install a PYPI Python package using `pip`, e.g. `pygame-utility`: + +```yaml base::pkg_group::my_pip_modules: - 'pygame-utility:pip' ``` -Note that packages installed with `pip` are not updated automatically. + +To install a packages for specific python versions use the tag `:pip` (example: `- 'numpy:pip3.12'`). + +Note that packages installed with `pip` are not updated automatically! ## Remove Packages diff --git a/admin-guide/configuration/python.md b/admin-guide/configuration/python.md index 6ae0a2fa..9ca03190 100644 --- a/admin-guide/configuration/python.md +++ b/admin-guide/configuration/python.md @@ -1,48 +1,81 @@ # Python -There are several versions of Python available from RedHat. This guide shows how you can select a specific version to be used on your system. - -The use of environment like [`venv`](https://docs.python.org/3/library/venv.html) or [Conda](https://docs.conda.io) is recommended if a single user needs one or multiple specific Python environments. But this is not part of this guide. - -This guide is only for RHEL8 and newer. - -## Python 3 - - -In Hiera you can select the wished version of Python - +## Overview +```{note} +This guide only covers RHEL8/9 and newer. Also we will __not__ cover how to use Python 2 any more. ``` -base::python::version: '3.11' -``` -The `python` as well as the `python3` command will then link to the interpreter of given version. The same is for `pip` and `pip3`. -### RHEL8 -On RHEL8 the default Python version is **3.6**. Available are also -- 3.8 -- 3.9 -- 3.11 -- 3.12 +There are several versions of Python(3) available from RedHat. This guide shows how one can install specific/multiple versions and how to configure the default Python of a system. -### RHEL9 -On RHEL9 the default Python version is **3.9**. Available are also -- 3.11 -- 3.12 - -### Libraries -The packages prefixed with `python3-` are for the default Python version. For newer versions they have a versioned prefix like `python38-` or `python3.11-`. There might not be for all libraries packages for all availabe Python versions. Then you might need to install your library with `pip`. - -For package installation (including with `pip`) with Hiera please check out [this guide](packages). - -Note that packages installed with `pip` are not updated automatically. - -## Python 2 -Don't use. +The use of Python environments like [`venv`](https://docs.python.org/3/library/venv.html) or [Conda](https://docs.conda.io) is recommended if a single user needs one or multiple specific Python environments. But this is not part of this guide. -## Platform Python -For system tools, which are shared over many systems where maybe different Python versions are used by default, you may select to use "Platform Python" instead, which is always the default Python version, independed of what has been selected as default Python. +## Platform Python vs Default Python -For this you need to set the shebang of your script to -``` +As many system tools are written in Python each RHEL8/9 system comes with a so called Platform Python. This is a _fixed_ Python version than cannot be modified and usually is also not available via the commandline. + +Beside that, on each system you can install multiple Python versions. One of this Python version can then be set as the Default Python. This means that this Python version is called if you call `python` and/or `python3` on the commandline/script. + +To explicitly call a specific Python version always specify the full version as follows: `python`, e.g. `python3.12`. The same applies to the `pip` command! + +### Using the Platform Python +For system tools, that should run consistently on all systems you may decide to use the "Platform Python" instead of the Default Python. For doing so you need to set the shebang of your script to + +```bash #!/usr/libexec/platform-python ``` + +## Python Versions + +On __RHEL8__ the Platform (and usual Default) Python version is __3.6__. As the time of writing following Python versions are additinally available: _3.8_, _3.9_, _3.11_, _3.12_ . + +On __RHEL9__ the Platform (and usual Default) Python version is __3.9__. As the time of writing following Python versions are additinally available: _3.11_, _3.12_ + + +## Configuration + +Following hiera keys can be used to configure Python on a system. + +### Installing and Setting a Default Python + +To install a default Python you can use: +```yaml +python::default_version: '3.11' +``` + +This will make sure that that this Python version is installed on the system and that this Python version is available via the `python` and `python3` command. The same applies for `pip` and `pip3`. + + +### Installing Additional Python Versions + +To install additional Python versions on the system you can use: + +```yaml +python::install_versions: ['3.6', '3.12'] +``` + +This will take care that the necessary packages are installed on the system. These versions are then available by calling the version specific Python command `python