-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to uv for Python management #635
Conversation
b43bcdd
to
4333014
Compare
cache-dependency-glob: | | ||
${{ inputs.dbt_project_dir }}/pyproject.toml | ||
${{ inputs.dbt_project_dir }}/uv.lock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unlike before, we have to explicitly specify the cache keys for pip dependencies. This is actually probably a good thing insofar as it lets us isolate each of the subproject dependencies in their own cache.
env: | ||
UV_SYSTEM_PYTHON: 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This env var is required if we want to install the pip dependencies into the system library rather than a uv
virtual env. We could use the uv
virtual env but we'd need to switch all the run commands from python $SCRIPT
to uv run $SCRIPT
and I thought this was easier.
- name: Install Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version-file: ${{ inputs.dbt_project_dir }}/.python-version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having this file lets us keep our Python version synchronized with uv
. If you want to use the Python version associated with the project locally, you just uv python install
with the virtualenv active.
8fc1df2
to
e841932
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice! I tested this out locally and it works great. No concerns from my end.
This PR switches to using
uv
for environment and dependency management in our data architecture repo and Actions.Locally, this (optionally) allows users to:
uv
for virtual env management (viauv venv && source .venv/bin/activate
) with a per-subdirectory virtualenv (i.e. dbt has its owndbt/.venv
directory)uv python install
uv pip install .
For Actions:
uv
now handles caching and installing pip dependenciesuv
to install directly to the system library (just as we did before with plainpip
)Why make this switch?
uv
is significantly faster when installing Python dependencies in Actions (10-100x faster)dbt/
,socrata/
, etc.) viauv.lock
files.python-version
filesThe downsides are:
venv
and users can still use plainpip
andvenv
if they want touv