How to build a project wheel with pinned dependencies? #312
-
Hi! 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? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
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 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 |
Beta Was this translation helpful? Give feedback.
-
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! |
Beta Was this translation helpful? Give feedback.
-
(I will move this to Discussions and the |
Beta Was this translation helpful? Give feedback.
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:
When installing the wheel (example from a Dockerfile):