Skip to content
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

Replace pip with uv for the project files #5356

Merged
merged 3 commits into from
Oct 5, 2024

Conversation

foarsitter
Copy link
Collaborator

Description

uv is maturing out and I played around a bit by replacing pip with uv for the project files. The generated project template stay's untouched.

Rationale

Dependencies

The dependencies located in requirements.txt are now included in pyproject.toml in the project.dependencies section. pyproject-fmt sorts them alphabetical so I had to remove the comments. There is also a lock file (uv.lock) but dependabot doesn't have support for this at the moment.

Actions

Each action uses astral-sh/setup-uv@v2 for installing and caching the dependencies. From what I saw the actions are a few seconds faster but not much.

Scripts

The scripts located in /scripts/ have now a dependencies section for standalone execution: https://docs.astral.sh/uv/guides/scripts/ and are run by invoking uv run scripts/create_django_issue.py

Looking forward to implement uv in the project template to!

@browniebroke
Copy link
Member

Sounds cool!

There is also a lock file (uv.lock) but dependabot doesn't have support for this at the moment.

Found the issue tracking that dependabot/dependabot-core#10478

.github/workflows/ci.yml Show resolved Hide resolved
pyproject.toml Show resolved Hide resolved
scripts/create_django_issue.py Outdated Show resolved Hide resolved
@browniebroke
Copy link
Member

Alternatively, renovate already has uv support it seems: renovatebot/renovate#30756

@foarsitter
Copy link
Collaborator Author

Time to merge this before it is getting out of sync with requirements.txt again.

@foarsitter foarsitter merged commit 0cac725 into cookiecutter:master Oct 5, 2024
13 checks passed
@browniebroke
Copy link
Member

Nice work!

@luzfcb
Copy link
Collaborator

luzfcb commented Oct 5, 2024

Just some additional context reaffirming that:

This change is not intended to replace pip with uv in the generated project, that is, in the project you get after running cookiecutter https://github.com/cookiecutter/cookiecutter-django.

As far as I know, it is not yet possible to replace pip with uv in the generated project because Heroku does not support it yet on the Heroku's Classic Python Buildpack and because the Heroku's Classic Python Buildpack requires the requirements.txt file on the project root.

In parallel with Heroku's Classic Python Buildpack, Heroku is developing a new buildpack standard and a new buildpack for Python, the Heroku's Cloud Native Buildpack for Python applications, which may eventually support pyproject.toml, uv.lock, etc. However, the Heroku's Cloud Native Buildpack for Python applications is still under development and is not production-ready yet.

Issues directly and indirectly related to Heroku support in general, now and in the future:

Heroku's Classic Python Buildpack:

heroku/heroku-buildpack-python#834
heroku/heroku-buildpack-python#796

Heroku's Cloud Native Buildpack for Python applications:

heroku/buildpacks-python#261
heroku/buildpacks-python#275
heroku/buildpacks-python#271
heroku/buildpacks-python#248

@foarsitter
Copy link
Collaborator Author

The generated project is indeed untouched. But not for long if it is up to me.

In one of my projects running on Heroku I'm using the pre-commit hook to generate a requirements.txt as described over here: https://docs.astral.sh/uv/guides/integration/pre-commit/ works like a charm because uv is blazing fast.

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.

3 participants