From ee09f6617f3871e2036f57d491edd1e6f49151af Mon Sep 17 00:00:00 2001 From: babic_a Date: Wed, 25 Nov 2026 14:45:00 +0100 Subject: [PATCH] Python pages: a tool declares all its requirements so that installing it is enough Co-Authored-By: Claude Fable 5.2 --- docs/2._Services_Portfolio/Services/03_devops.md | 4 ++-- docs/3._Knowledge_Center/01_Tutorials/02_python.md | 2 +- docs/3._Knowledge_Center/03_how_to/08_python_venv.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/2._Services_Portfolio/Services/03_devops.md b/docs/2._Services_Portfolio/Services/03_devops.md index e5cf652d..4fb94490 100644 --- a/docs/2._Services_Portfolio/Services/03_devops.md +++ b/docs/2._Services_Portfolio/Services/03_devops.md @@ -198,7 +198,7 @@ Controls delivers Python tools that work with the control system, for example th | Outside the RPM, the main way to install a Python tool is `pip` in a virtual environment (venv). | It stays in your home directory, does not change the host, and works on any machine that has Python. | | **pixi** is an optional alternative for a project that wants its Python and packages declared in a manifest and a lock file that pins every version. | The environment rebuilds identically on every machine and after a re-create. AIT supports pixi for the beamlines, so Controls uses the same tool instead of a parallel one. | | Installing into your user's Python (`pip install --user`) is possible for one user without root and without a venv. | It also stays in your home directory and does not change the host. | -| Every Controls Python tool states its requirements for each way of installing it. | The requirements differ: system packages for the RPM, PyPI for pip, package channels for pixi. | +| Every Controls Python tool states all of its requirements properly, for each way of installing it. | Installing the tool must be enough to make it work: the package declares every dependency and the install pulls them in, so nobody has to install something extra by hand afterwards. The requirements differ per route: system packages for the RPM, PyPI for pip, package channels for pixi. | | No `sudo pip install` into the system Python, no hand-installed packages on a standard host, no conda. | A host changed by hand has left its standard. It is no longer supported, and the remedy is a re-create to standard. | The one exception to "no conda": `ioc install` still builds the environment of a Python IOC with conda. This is legacy and still works, see [Python IOCs](#python-iocs). @@ -302,7 +302,7 @@ What your project needs: - Source in a Git repository, documented in a `README.md`. Nothing that matters may live only on a machine: source and build results belong in Git and in the repositories, so a machine can be re-created at any time. - Standard packaging metadata in `pyproject.toml` or `setup.py`: name, version, dependencies, and the commands as console-script entry points. `cas-iocutils/setup.py` is a working example. -- The requirements for each install method, stated in the README: supported Python versions (`requires-python`), dependencies, and where they come from. +- All requirements stated properly: every dependency declared in the package metadata, so that installing the tool pulls them in and nothing has to be installed by hand afterwards; and in the README, for each install method, the supported Python versions (`requires-python`), the dependencies and where they come from. - `pip install .` must work in a fresh venv as a normal user. Do not install files to absolute system paths (for example via `data_files` to `/etc`). - For pixi: a `pixi.toml` and a `pixi.lock` in the repository. - For RPM delivery: a `.spec` file, written by the application developer. Every dependency must exist as a RHEL9 `python3-*` RPM, because the RPM declares them with `Requires:` and does not bundle them. Pure-Python tools are built as `noarch`. Build the RPM on a RHEL9 machine with `rpm-build` (`rpmbuild -bb .spec`); give each release a new version number in both the packaging metadata and the spec, in the same commit, and tag that commit. diff --git a/docs/3._Knowledge_Center/01_Tutorials/02_python.md b/docs/3._Knowledge_Center/01_Tutorials/02_python.md index 60b1fbd6..9b42b4f9 100644 --- a/docs/3._Knowledge_Center/01_Tutorials/02_python.md +++ b/docs/3._Knowledge_Center/01_Tutorials/02_python.md @@ -144,7 +144,7 @@ Line by line: - `name`, `version`, `description`: the package name, its version, one line about it. - `readme`: the file that describes the project. - `requires-python`: the Python versions the tool supports; 3.9 is the system Python on RHEL9. -- `dependencies`: a list of the packages the tool needs. It must be a list: pip rejects `[project.dependencies]` written as a table with `` `project.dependencies` must be array ``. +- `dependencies`: a list of all the packages the tool needs. List every one of them: installing the tool must be enough to make it work, without anyone installing something extra by hand afterwards. It must be a list: pip rejects `[project.dependencies]` written as a table with `` `project.dependencies` must be array ``. - `[project.scripts]`: the command `pvshow` calls the function `main` in the module `pvshow.cli`. Create a short `README.md` (you complete it in stage 3), add `*.egg-info/` to `.gitignore` (pip writes the package metadata there), and install the project in editable mode, so the venv uses your source files directly: diff --git a/docs/3._Knowledge_Center/03_how_to/08_python_venv.md b/docs/3._Knowledge_Center/03_how_to/08_python_venv.md index bd96aa76..52ee26e4 100644 --- a/docs/3._Knowledge_Center/03_how_to/08_python_venv.md +++ b/docs/3._Knowledge_Center/03_how_to/08_python_venv.md @@ -75,7 +75,7 @@ Check that it worked: `which ioc` prints `$VENVS/iocutils/bin/ioc`, and `ioc --h The commands of the tool are on the [IOC Utils](../../2._Services_Portfolio/Tools/01_ioc_utils.md) page. -Every Controls Python tool states its requirements per install route in its README. +A tool must state all of its requirements properly, so that installing it is enough to make it work: every dependency is declared in the package itself (`dependencies` in `pyproject.toml`, `install_requires` in `setup.py`, `Requires:` in an RPM), and the install pulls them in. Nobody should have to install something extra by hand afterwards. Requirements that a package cannot pull in, such as the Python version or a system library, are stated in the README for each install route. ## Install your own project for development