Migrate to uv as package manager for the generated project#5434
Migrate to uv as package manager for the generated project#5434foarsitter merged 5 commits intocookiecutter:mainfrom
uv as package manager for the generated project#5434Conversation
bd785eb to
6bae8e7
Compare
|
Ready for testing 🎉 cookiecutter https://github.com/foarsitter/cookiecutter-django --checkout uv-generated-project |
8f3ca43 to
d12c2e7
Compare
browniebroke
left a comment
There was a problem hiding this comment.
Did a first pass and noted a few things. Haven't reviewed the Dockerfiles yet
|
Hi, there. I played around with using your fork to update some existing projects and eventually got them working but ended up reverting them to their production (pip) versions so that I could revisit when I had more time. When working on an adapting an existing project, I got an error during the build, which was reproduced when I built a project from scratch using
I believe that it's caused by having the blank |
|
@steveputman thanks looking into this! During a build you cannot write to the host system. Your interpreter is inside the container together with uv so you can run uv: Struggled a lot with this and it is not ideal. So hopefully someone has a better solution. |
|
@foarsitter Your solution is better than mine (I had uv installed on my host system so just ran Thanks for the help! Will let you know if anything else comes up. |
{{cookiecutter.project_slug}}/compose/production/django/Dockerfile
Outdated
Show resolved
Hide resolved
|
I think you need to run Of course we're also not sharing a virtualenv here, by my read/attempt to use this. It might be possible to just share a mount across all the services, but I'm having trouble getting that to work. |
|
Great work! This project really need to have a better tool than the plain pip |
|
The dependabot would need updating too. I dont know if it supports pyproject declarations |
I believe it does, I've found some discussions on the project, here's the link to the issue. |
This has been added now: dependabot/dependabot-core#10478 (comment) |
|
a git pull away from a merge 😿 |
|
Tried it. I wonder if the requirements currently in [project.optional-dependencies]
production = [
"gunicorn==23.0.0",
# ...
]Currently they appear in the main project dependencies, so they will be installed in the development virtualenv. They can then be installed by running uv docs about optional dependencies. (And thanks for doing the work - I look forward to it being merged :) ) |
|
@foobacca I see development as a superset of production. Everything from production needs to be replicated in development but production doesn't need a test framework for example. When the sentry_sdk is added as an extra dependency I cannot use capture_exception for example because the package is missing. Another example is testing the gunicorn command. I cannot do such thing when developing when I do not have the package. |
|
@foarsitter I see your point (though you can of course install the production dependencies if you want with I don't have a strong preference, but it does seem like a change from the master branch, where there is a separate I'll leave it to the maintainers. If they're happy with the change I have no objection. (And I'm quite capable of changing my project after running cookiecutter anyway 🙂 ) |
|
One other idea. I would expect the I can obviously edit it myself after running cookiecutter, so not a big deal if others prefer it at the bottom, but thought I'd mention it. |
The production deps are installed locally on the master branch too, so not so much of change - see #4838 for more context |
I agree. Dependencies should be at the top of the file |
|
We use https://github.com/tox-dev/pyproject-fmt for dictating the order of appearance, so you don't need to worry about it :) |
0de26a5 to
0f678fb
Compare
|
Just realised that there is the question of PythonAnywhere too: https://cookiecutter-django.readthedocs.io/en/latest/3-deployment/deployment-on-pythonanywhere.html Not sure what do about that: I haven't got much experience with this platform, do they support uv? EDIT: Looks like they do
|
e5d6fb0 to
f8c35b6
Compare
df472bc to
c922946
Compare
…way we can inspect the results if needed.
9c85003 to
4397073
Compare
|
Ok, I think we are ready to merge. |
browniebroke
left a comment
There was a problem hiding this comment.
Would be nice if we could address the latest comments but looking at them again, I don't think they're blockers.
474fcce to
4397073
Compare
|
Tests are failing now and I don't know why. Feel free to take over, need to fix something else first xD |
EDIT: I've just seen that you reverted that and it's still failing 😭 |
|
Failing tests seems related to docker container name conflict, like if test containers were not removed/clean. |
|
I've changed this approach a bit by defining a minimal Docker image to run |
Sounds like a good fundamental solution to me, thanks! I tried it this way using the uv image directly but I couldn't get it to work. Looking to the Dockerfile I'm wondering why it works this way but I'm fine with it. From my perspective we are ready to merge this as is! |
Let's do it! 🎉🎉🎉 |
The project itself now uses
uvand this is an attempt to bringuvto the generated project too.uv runfor local development. In Docker the .venv python interpreter is added to the $PATH so packages can be used system wide.uv syncis executed.pre-committhat compiles a requirements.txttraptotest_docker.shto cleanup after testing so the next time will no fail due to an existing postgres volume.Before we can merge this we need one last round to update all the versions to the latest ones in the requirement.txt files.