pip
Install the pinned requirements of a Python project with pip.
Install the pinned requirements of a Python project with pip.
The task runs in a python container and installs into __pypackages__, so it is
skipped when the requirements file is unchanged. Tasks that need the packages set
PYTHONPATH=__pypackages__.
includes:
pip:
git: https://github.com/no0dles/hammerkit.git
ref: v1.19.0
path: catalog/pip
tasks:
test:
image: python:3.13-slim
deps: [pip:install]
src: [app, tests]
envs:
PYTHONPATH: __pypackages__
cmds:
- python -m unittestTasks
| Task | What it does | Reads | Produces |
|---|---|---|---|
install | Install the pinned requirements with pip. | the requirements file (requirements.txt) | __pypackages__ |
Inputs
| Input | Default | Meaning |
|---|---|---|
PYTHON_VERSION | 3.13 | Tag of the python image the install runs in. The image is python:<PYTHON_VERSION>-slim. Quote it in with ('3.10'), or YAML reads it as the number 3.1. |
REQUIREMENTS | requirements.txt | The file to install from, with exact versions (pip freeze, pip-compile). Use it for a different name or folder, for example requirements/prod.txt. |
The entry
# Installs the pinned requirements of a Python project with pip.
envs:
# tag of the python image the install runs in, quoted so 3.10 stays 3.10
PYTHON_VERSION: '3.13'
# the file to install from, with exact versions (pip freeze, pip-compile)
REQUIREMENTS: requirements.txt
tasks:
install:
description: install the pinned requirements with pip
image: python:${PYTHON_VERSION}-slim
src:
- '${REQUIREMENTS}'
generates: [__pypackages__]
cmds:
- pip install --no-cache-dir --disable-pip-version-check --target __pypackages__ -r ${REQUIREMENTS}