uv
uv copied to clipboard
Consider feature to vendor-in distributions in workspace
Summary
We have an interesting discussions in Airlfow about sharing some code between different distributions in the same workspace and we have a particular need that might be useful to consider as uv workspace feature - vendored-in distributions.
Basically what we want to achieve is to eat-cake and have it too when it comes to shared code. I.e.
- we would like to have a shared code that is not duplicated in the monorepo and can be used by different distributions
- but we want this code to be distriibuted "embedded" in the distribution that uses it, but in the way that you can install two distributions - each of them with a different version of that shared code embedded (basicallly the version that was present in the repo at the moment the using distribution was released
This resembles a bit npm/javascript ecosystem where different packages can use different versions of shared libraries - but we would like to do it without having such "generic" capability in Python - and only focus on shared code from our monorepo, rather than external distributions.
We want it to be available for coding and changing it and using it in our distributions when you just check-out "main" from the repo - it should not require any manual synchronisation - it should just work that when you modify the code in one place, then change should be automatically picked by the other distribution.
It boils down to having the same code available in different packages in different distributions. Say.
- Package airflow-core uses "airflow.shared.logging".
- Package airflow-task-sdk uses the exact same code (maybe with modified imports) but it is in `airflow.sdk.shared.logging"
We have several options we can follow now:
- symlinking the code from one distribution to the other in a - this has a number of limitations - only relative imports can be used for such a shared code
- we have a POC where we use https://pypi.org/project/vendoring/ to automatically vendor in the code between distributions (which needs a bit of tweaking to work in uv)
- we can have regular "common" library, but that introduces a whole host compatiblity, versioning, fixing API etc.
Maybe that would be possible / good idea to have a feature in uv workspace to mark a workspace as "shared" - and while localy you could refer to it as a dependency (say in "shared" dependency group), it would end up as actual code embedded in a designated package inside the distribution.
Have you ever considered such feature? Would that be feasible to implement/ useful for others as well ?
Example
No response