Warning
This may faile with some packages. We recommend to just use uv and create the requirements.txt with uv export
Airflow provides a constraints file with the exact versions used. Here is how we can make the installation (almost) reproducible by relying on the hashes.
requirements.in holds the dependencies with constraints.
# airflow and constraints
apache-airflow[celery]==2.9.0
-c https://raw.githubusercontent.com/apache/airflow/constraints-2.9.0/constraints-3.8.txtwith pip (and pip-tools)
# create requirements.txt with hashes and exact versions by provided constraint.
# The requirements.txt is commited to Git.
pip-compile --generate-hashes --allow-unsafe
# Install and verify hashes, will exit if hashes have a missmatch.
# This step is usually run during docker build.
pip install --require-hashes -r requirements.txtwith uv
# create requirements.txt with hashes and exact versions by provided constraint.
# The requirements.txt is commited to Git.
uv pip compile requirements.in -o requirements.txt --generate-hashes
# Install and verify hashes, will exit if hashes have a missmatch.
# This step is usually run during docker build.
uv pip install --require-hashes -r requirements.txt