Add hatch autocomplete for oh-my-zsh
- Run this command
mkdir -p ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/hatch-zsh-completion && _HATCH_COMPLETE=zsh_source hatch > ${ZSH_CUSTOM}/plugins/hatch-zsh-completion/hatch-zsh-completion.plugin.zsh
- Add
hatch-zsh-completion
to your.zshrc
file atplugins=
like so
plugins=(git hatch-zsh-completion)
Run a script from a non-default environment
hatch run <env-name>:<script-alias>
Deactivate an environment
exit
Enter an environment
hatch -e <env-name> shell
Adding environment variables
[tool.hatch.envs.<env-name>.env-vars]
NAME = "value"
Run with uv
as the virtual env backend.
Link to discussion
When configuring Hatch to use environment variables in pyproject.toml
, note that TOML doesn’t directly support variable substitution within strings. To work around this, we can leverage shell commands to access environment variables.
Here's an example setup to pull data from Kaggle, unzip it, and launch a notebook using custom paths:
[tool.hatch.envs.default.scripts]
pull-data = [
"sh -c 'kaggle datasets download -d $KAGGLE_PATH -p src/demo_supply_chain/data/raw'",
"unzip src/demo_supply_chain/data/raw/supply-chain-analysis.zip -d src/demo_supply_chain/data/raw",
]
notebook = ["marimo edit src/demo_supply_chain/notebooks/demo.py"]
[tool.hatch.envs.default.env-vars]
DATA_PATH = "src/demo_supply_chain/data/raw/supply_chain_data.csv"
KAGGLE_PATH = "fayez1/inventory-management"