Skip to content

Use uv for installing dependencies on all Linux-only CI jobs#11515

Merged
AlexWaygood merged 1 commit into
python:mainfrom
AlexWaygood:uv-switch
Mar 1, 2024
Merged

Use uv for installing dependencies on all Linux-only CI jobs#11515
AlexWaygood merged 1 commit into
python:mainfrom
AlexWaygood:uv-switch

Conversation

@AlexWaygood

Copy link
Copy Markdown
Member

Using uv rather than pip means our requirements are installed almost instantly in CI, compared to around 10s to install our requirements.txt file currently on each job.

I've only changed the jobs that are Linux-only in this PR. uv works fine on Windows, but it's slightly fiddly to install uv in a workflow that runs on both Windows and Linux without using pip (which is slow, defeating the point of the exercise). It's possible to install uv in a cross-platform workflow without using pip, but I wasn't sure it was worth the added complexity for us here.

@JelleZijlstra JelleZijlstra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK with doing this, thanks! A few questions.

- uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: pip

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does losing this cache have a significant cost?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With pip + the cache it took 10s. With uv without the cache it takes 1s. So I think we just don't need to worry about caching installs anymore with uv?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It only cached the download, not the install anyway. It probably helped avoid connection issues with PyPI more than anything

run: echo "$PWD/.venv/bin" >> $GITHUB_PATH
- name: List 3rd-party stub dependencies installed
run: pip freeze --all
run: uv pip freeze

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does uv not do the thing where setuptools etc. are only listed if you pass --all?

@AlexWaygood AlexWaygood Mar 1, 2024

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uv doesn't install setuptools/pip/wheel into environments the way the stdlib venv module does, unless you explicitly ask for them with --seed (because, the theory goes, you don't need any of them if you have uv). Newly created environments come completely empty. So even if uv had a --all flag for uv pip freeze (it doesn't currently), we wouldn't need to use it

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I assume that it does, by default, list setuptools/pip etc if they are installed into an environment. Though I haven't checked.

@hauntsaninja hauntsaninja left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hooray! It'll be great when we use uv in mypy_primer too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants