You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to build a project wheel with pinned dependencies? #310
I'm using polylith in a system together with uv and hatchling. One thing I'm struggling with is that, while in development I end up with a uv lock file for development (at the root), I haven't figured out a way to have a lock file for each project so that I can get wheel distributions with pinned dependencies. The reason why this is a problem for me is that I end up with a non-deterministic build process, and yesterday I had issues with this because my local environment was working fine but not my staging environment because of diverging dependency versions.
So how can I lock each project with its own lock file, to ensure deterministic builds, while not having to forcefully pin each dependency in pyproject.toml?
Hi @diogobaeder! I think that one way to accomplish this is to opt-out of the uv workspaces feature (if you use that) and have separate uv.lock files that are updated individually.
Another option is to export the project-specific deps before building the wheel. I think that you can do something like this:
# running from the folder of a project.# export the dependecies
uv export --no-emit-project --output-file requirements.txt
#build the distribution (wheel/sdist)
uv build --out-dir ./dist
When installing the wheel (example from a Dockerfile):
# Install with no deps. Removed other useful standard pip install flags in this example
RUN pip install --no-deps the-built-wheel-from-before.whl
# install the third-party deps separately
RUN pip install -r requirements.txt
I am not yet using uv myself that much, so I might have missed out on something. Please let me know if you find anything missing, and if this suggestion works 😄
Awesome, thanks man! I'll give those a try. I'm using Tilt locally, to develop multiple services together, so what you explained above is very helpful. Cheers!
Activity
DavidVujic commentedon Dec 8, 2024
Hi @diogobaeder! I think that one way to accomplish this is to opt-out of the uv workspaces feature (if you use that) and have separate
uv.lockfiles that are updated individually.Another option is to export the project-specific deps before building the wheel. I think that you can do something like this:
When installing the wheel (example from a Dockerfile):
I am not yet using
uvmyself that much, so I might have missed out on something. Please let me know if you find anything missing, and if this suggestion works 😄diogobaeder commentedon Dec 9, 2024
Awesome, thanks man! I'll give those a try. I'm using Tilt locally, to develop multiple services together, so what you explained above is very helpful. Cheers!
DavidVujic commentedon Dec 9, 2024
(I will move this to Discussions and the
Q&Asection, to have it available for other users)