-
Notifications
You must be signed in to change notification settings - Fork 60
Description
To be honest, I solved the issue I had even before posting it, but I thought I want to post it somewhere anyway.
So if we install our project dependencies (and then the project itself) with uv sync --frozen ... --no-dev, we can only cache production dependencies (which should've been obvious, yes), but any uv command, such as uv run will check uv.lock again and install all of them (including dev dependencies), which in my case took about additional 7 seconds.
I was building a Django project and was frustrated to no end, and I thought that these 7 seconds came from the Django setup code. But then I checked uv issue guide, and tweaked the RUST_LOG variable to see what's going on, maybe it is uv, after all, why would I see Installed N packages in my logs?
2024-12-17 20:33:32 DEBUG Identified uncached distribution: django-debug-toolbar==4.4.6
2024-12-17 20:33:32 DEBUG Identified uncached distribution: django-stubs==5.1.1
2024-12-17 20:33:32 DEBUG Identified uncached distribution: mypy==1.13.0
2024-12-17 20:33:32 DEBUG Identified uncached distribution: ruff==0.8.0
2024-12-17 20:33:32 DEBUG Requirement already installed: django==5.1.3
...
2024-12-17 20:33:32 DEBUG Requirement already installed: asgiref==3.8.1
2024-12-17 20:33:32 DEBUG Identified uncached distribution: django-stubs-ext==5.1.1
2024-12-17 20:33:32 DEBUG Identified uncached distribution: types-pyyaml==6.0.12.20240917
2024-12-17 20:33:32 DEBUG Requirement already installed: typing-extensions==4.12.2
2024-12-17 20:33:32 DEBUG Identified uncached distribution: mypy-extensions==1.0.0
2024-12-17 20:33:32 DEBUG Requirement already installed: packaging==24.2
2024-12-17 20:33:32 DEBUG Requirement already installed: psycopg-binary==3.2.3
2024-12-17 20:33:32 DEBUG Requirement already installed: brotli==1.1.0
...
2024-12-17 20:33:32 DEBUG No cache entry for: https://files.pythonhosted.org/packages/2f/33/2036a472eedfbe49240dffea965242b3f444de4ea4fbeceb82ccea33a2ce/django_debug_toolbar-4.4.6-py3-none-any.whl
2024-12-17 20:33:32 DEBUG No cache entry for: https://files.pythonhosted.org/packages/9e/2c/c1d81d680997d24b0542aa336f0a65bd7835e5224b7670f33a7d617da379/types_PyYAML-6.0.12.20240917-py3-none-any.whl
2024-12-17 20:33:32 DEBUG No cache entry for: https://files.pythonhosted.org/packages/6a/ed/f79ae5ad993bdf900d61892d2a9fc0145441a507a7579890fb8e21e4a7bc/django_stubs_ext-5.1.1-py3-none-any.whl
2024-12-17 20:33:32 DEBUG No cache entry for: https://files.pythonhosted.org/packages/2a/e2/5d3f6ada4297caebe1a2add3b126fe800c96f56dbe5d1988a2cbe0b267aa/mypy_extensions-1.0.0-py3-none-any.whl
...
2024-12-17 20:33:39 Installed 7 packages in 49ms
(And as if gods laugh at me, I have 7 INSTALLED_APPS in Django config, so that was the root of my confusion)
So yeah, this problem isn't reproducible if you "give up" on uv and sort of activate the environment with ENV PATH="/app/.venv/bin:$PATH" and then keep calling python manage.py ... or fastapi dev as in the example, or if you run uv run --no-dev, but it's still a silent landmine that can bite you.
And tbh, I can't think of a proper "solution" to this "problem" if it even counts as a problem, and if it is, whether it's something that can be improved here with documentation or if people just need to read existing docs more thoroughly, because it is probably explained somewhere 😅