Command Line Interface¶
feu provides a command-line interface (CLI) for package management tasks. To use the CLI, you need
to install the optional cli dependency:
pip install 'feu[cli]'
Exit Status¶
The standard output holds only the answer of a command, the logs and the error messages go to the
standard error (--verbose logs the executed commands), and the exit status carries the result:
0: success, or a valid version;1: a negative answer (no compatible version, orcheck-valid-versionprintedFalse);2: a usage error (unknown option, missing option, invalid version request).
feu --version prints the version. feu is a console script; python -m feu is equivalent.
Commands¶
The reference below is generated from the code (mkdocs-click), so it cannot drift. install
installs into the interpreter that runs feu for the current target, so it has no target option.
The platform (OS and CPU architecture) is always the current one: there is no --os or --arch
option.
feu¶
Implement the main entrypoint, which groups the commands.
Usage:
feu [OPTIONS] COMMAND [ARGS]...
Options:
--version Show the version and exit.
--verbose Log the executed commands on the standard error.
--help Show this message and exit.
check-valid-version¶
Print if a package version is valid for a target.
True is printed and the exit status is 0 if the version is
valid or if the package is not configured for the target. Otherwise
False is printed and the exit status is 1.
Args: pkg_name: The package name. pkg_version: The package version request to check. python_version: The python version. If not provided, the current python version is used. free_threaded: Whether the target is a free-threaded build. If not provided, the current interpreter's free-threaded status is used.
Example:
$ feu check-valid-version --pkg-name=numpy --pkg-version=2.0.2 --python-version=3.10
Usage:
feu check-valid-version [OPTIONS]
Options:
-n, --pkg-name TEXT Package name [required]
-v, --pkg-version TEXT Package version request: an exact version
e.g. '2.0.2', a wildcard e.g. '2.*' or an
empty string for the latest version.
[default: ""]
-p, --python-version TEXT Python version e.g. '3.12' or '3.14t'.
Default: the current Python version.
-f, --free-threaded / --no-free-threaded
Whether the target is a free-threaded build.
Default: the current interpreter.
--help Show this message and exit.
find-closest-version¶
Print the closest valid version of a package for a target.
The standard output holds only the version to install. For a
wildcard or an empty version request that lies in an open-ended
range, the request itself is printed. If no version is compatible
with the target, the message is printed on the standard error, the
standard output is empty and the exit status is 1.
Args: pkg_name: The package name. pkg_version: The package version request to check. python_version: The python version. If not provided, the current python version is used. free_threaded: Whether the target is a free-threaded build. If not provided, the current interpreter's free-threaded status is used.
Example:
$ feu find-closest-version --pkg-name=numpy --pkg-version=2.0.2 --python-version=3.10
Usage:
feu find-closest-version [OPTIONS]
Options:
-n, --pkg-name TEXT Package name [required]
-v, --pkg-version TEXT Package version request: an exact version
e.g. '2.0.2', a wildcard e.g. '2.*' or an
empty string for the latest version.
[default: ""]
-p, --python-version TEXT Python version e.g. '3.12' or '3.14t'.
Default: the current Python version.
-f, --free-threaded / --no-free-threaded
Whether the target is a free-threaded build.
Default: the current interpreter.
--help Show this message and exit.
install¶
Install a package and associated packages.
The package is installed in the interpreter that runs feu, for
the current target. The closest compatible version is installed if
pkg_version is not compatible. The exit status is 1 if no
version is compatible and 2 if an argument is invalid (e.g. a
malformed wildcard).
Args:
pkg_name: The package name e.g. 'pandas'.
pkg_version: The version request of the package to install:
an exact version, a wildcard (e.g. '2.*') or an empty
string for the latest version.
pkg_extras: Optional package extra dependencies, separated by
commas e.g. 'dev,doc'. An empty string means no extra.
installer_name: The package installer name to use to install
the packages.
installer_args: Optional arguments to pass to the package
installer, as a single string e.g. '--upgrade'. It is
split once with shlex.split. The valid arguments
depend on the package installer.
Example:
$ feu install --installer-name=pip --pkg-name=numpy --pkg-version=2.0.2
Usage:
feu install [OPTIONS]
Options:
-n, --pkg-name TEXT Package name [required]
-v, --pkg-version TEXT Package version request: an exact version e.g.
'2.0.2', a wildcard e.g. '2.*' or an empty string
for the latest version. [default: ""]
-e, --pkg-extras TEXT Package extra dependencies, separated by commas
e.g. 'dev,doc'. [default: ""]
-i, --installer-name TEXT The package installer. [default: pip]
-a, --installer-args TEXT Arguments to pass to the package installer, split
once like a shell would. [default: ""]
--help Show this message and exit.
package-versions¶
Write the versions to test of the dependencies of a project.
The dependencies are read from [project.dependencies] and
[project.optional-dependencies]. The output is a JSON object
that maps each package to the latest version of each minor (or
major) version at or above its lower bound.
Args:
pyproject: The pyproject.toml file.
output: The JSON file to write, or None for the standard
output.
major_only: The packages for which only the major versions
are kept.
Example:
$ feu package-versions --pyproject pyproject.toml --output dev/config/package_versions.json
Usage:
feu package-versions [OPTIONS]
Options:
--pyproject FILE The pyproject.toml file to read the dependencies from.
[default: pyproject.toml]
--output FILE The JSON file to write. Default: the standard output.
--major-only TEXT A package for which only the latest version of each major
version is kept. Repeat the option for several packages.
[default: packaging]
--help Show this message and exit.
Examples¶
Find the closest valid NumPy version for Python 3.10 and for an older NumPy on Python 3.11:
$ feu find-closest-version --pkg-name=numpy --pkg-version=2.0.2 --python-version=3.10
2.0.2
$ feu find-closest-version --pkg-name=numpy --pkg-version=1.0.0 --python-version=3.11
1.23.2
A wildcard or an empty version request is resolved like a version. The request itself is printed when the latest compatible release is in an open-ended range, so that the installer picks the real latest release:
$ feu find-closest-version --pkg-name=numpy --pkg-version='1.*' --python-version=3.9
1.26.4
$ feu find-closest-version --pkg-name=numpy --pkg-version='1.24.*' --python-version=3.14
No version of package numpy matches '1.24.*' for target Target(python_version='3.14', ...)
$ echo $?
1
Check if a version is valid. The exit status is 0 when the version is valid:
$ feu check-valid-version --pkg-name=numpy --pkg-version=2.0.2 --python-version=3.10
True
$ feu check-valid-version --pkg-name=numpy --pkg-version=1.0.0 --python-version=3.11
False
Install a package, with extras and installer arguments:
feu install --pkg-name=numpy --pkg-version=2.0.2
feu install --pkg-name=pandas --pkg-version='2.*' --pkg-extras=performance
feu install --installer-name=uv --installer-args='--upgrade' --pkg-name=numpy
Write the versions to test of the dependencies of a project, from the bounds of its
pyproject.toml:
feu package-versions --pyproject pyproject.toml --output dev/config/package_versions.json
Use in a shell script or a workflow¶
The standard output holds only the answer, so it can be captured. An unsupported request makes the
step fail instead of installing pkg==None:
VERSION=$(feu find-closest-version --pkg-name=numpy --pkg-version=2.0.2 --python-version=3.10) \
&& feu install --pkg-name=numpy --pkg-version="$VERSION"