hatch-run - Man Page

hatch run – Run commands within project environments

Synopsis

hatch run [OPTIONS] [ENV:]ARGS...

Description

This is a convenience wrapper around the hatch-env-run(1) command.

If the first argument contains a colon, then the preceding component will be interpreted as the name of the environment to target, overriding the -e/--env root option and the HATCH_ENV environment variable.

If the environment provides matrices, then you may also provide leading arguments starting with a + or - to select or exclude certain variables, optionally followed by specific comma-separated values.

Notes

Inclusions are treated as an intersection while exclusions are treated as a union i.e. an environment must match all of the included variables to be selected while matching any of the excluded variables will prevent selection.

Examples

For example, if you have the following configuration:

pyproject.toml
[[tool.hatch.envs.test.matrix]]
python = ["3.9", "3.10"]
version = ["42", "3.14", "9000"]
hatch.toml
[[envs.test.matrix]]
python = ["3.9", "3.10"]
version = ["42", "3.14", "9000"]

then running:

hatch run +py=3.10 -version=9000 test:pytest

would execute pytest in the environments test.py3.10-42 and test.py3.10-3.14. Note that py may be used as an alias for python.

See Also

hatch-build(1), hatch-clean(1), hatch-config(1), hatch-dep(1), hatch-env(1), hatch-fmt(1), hatch-new(1), hatch-project(1), hatch-publish(1), hatch-python(1), hatch-self(1), hatch-shell(1), hatch-status(1), hatch-test(1), hatch-version(1)

hatch(1)

hatch-env-run(1)

Referenced By

hatch(1), hatch-build(1), hatch-clean(1), hatch-config(1), hatch-dep(1), hatch-env(1), hatch-env-run(1), hatch-fmt(1), hatch-new(1), hatch-project(1), hatch-publish(1), hatch-python(1), hatch-shell(1), hatch-status(1), hatch-version(1).

August 2024