-
Notifications
You must be signed in to change notification settings - Fork 605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow users to install a project's dependencies, without the project itself #4028
Comments
(Not decided, filed to revisit later.) |
Lots of prior chatter over in python-poetry/poetry#800 |
Maybe see also pypa/pip#11440 for potential use cases. |
(Interestingly, we actually kind of already support what's described in that issue because we allow |
That doesn't support the [extras] syntax (e.g. Personally, I'd love to see support for the syntax suggested here:
[EDIT] |
This works great
So it would also work with PS: uv is such an amazing tool - thanks for building it ❤️ |
I have a use case for that: my blog, which is actually Markdown content only, and is built by Pelican, a pure Python static website generator. In that case the In the mean time, I hacked the process and added a dummy package at the root of my repository:
And added the following directive in [tool.setuptools.packages.find]
include = ["blog"] |
My use case: ansible project with bundled For ansible project, the majority of code are written in yaml, by providing Besides, non-python-package programs like |
We use The first layer just installs the project dependencies; the second adds the projects itself. We hope to write something like: WORKDIR /app
ADD pyproject.toml uv.lock /app
RUN uv sync --no-dev --no-root
ADD src /app
RUN uv sync --no-dev |
In the above scenario of a layered Dockerfile to leverage caching of infrequently changing dependencies, it is important that there is a way to install from At first sight, IMHO this is a critical feature for adoption of |
I agree that something like this is necessary. |
I'll chime in that In particular the idea is that if you have a monorepo you can still copy in your top-level lockfile and not have to copy in anything (not even the |
Yeah 100% agree that you should be able to sync from just the lockfile. The lockfile itself is actually designed to support that (it doesn’t rely on pyproject.toml), but we need to expose the right options to users… |
I can see a few approaches here (all fairly easy to implement, mostly about getting the API right)...
|
In case you’re looking for opinions, I like “seed”. The others are rather generic and I’d have to guess what they exactly mean. |
(Gonna see if we can come up with an API and ship this ~today.) |
Opinions very welcome. |
I think |
Would |
|
Some thoughts.... I think extras would be covered by the normal I worry about I think we might want to use The difficulty is in choosing how to describe what we're selecting. There are a few things we want to be able exclude:
Unfortunately All of these are "local" dependencies, as in they're on the local file system, so It feels like we need a separate flag for excluding just the current project, like Do we need the ability to exclude all local dependencies except the current project? Or can it be done in two steps:
What's the use-case for that? |
I think the only use-case for the Docker caching situation is "exclude all locals". I think excluding the current project (but not other workspace members) is independently useful, like for "virtual projects." We could choose not to solve that here, but we should probably have a design that won't cause us problems in the future if we pursue it. |
Your example doesn't include cache busting by copying the uv.lock file into the build container which is kind the whole point? You want the layer to be rebuilt if the lock file changes. but keep it around otherwise. I suspect your example is incomplete on purpose to just sketch out the idea, but I think it would be good to complete it, because those I for one could live with explicitly naming the package I want to sync later (i.e. |
My use case here is very similar to the ones listed here, but with a twist. We do not copy the workspace into the build context, rather, we mount a wheel that was already built in a previous CI stage. This reduces duplication, both in terms of stages (build-backend only invoked once), as well as storage (if I Most importantly, by using a wheel and not a raw workspace, this also lets me have consistent builds between different targets (docker, pypi, rpm/deb/nix, etc etc) Being able to
For context, right now we do:
Which works exactly as intended -- but it's not a proper lockfile (and being able to slice it into layers is a very nice thing to be able to do) |
Yes, the lock file needs to be copied first, but only prior to the first partial sync and if it's not there, My point is mostly, without going too much into the implementation, that a partial sync would be an explicit, multi-stage approach precisely to safely make a multi-layer caching solution work. The benefit for the user is that it can be guided without the user having too many ways to unintentionally fuck it up or changes in uv breaking layer caching accidentally.
My reasoning with explicit skipping here is not so much that this is how it should be (eg: this is how you name what has not been synced) but that it's a very intentional process and you don't accidentally start interacting with a partial venv and then end up surprised about random failures later down the line. |
I think it would be pretty reasonable to use |
Does the lock file include dev dependencies? In that case it would be very tedious if we don't want these in the docker image. How about |
Yeah it does include dev dependencies. But you can omit those with |
Ah, right I now see the lock file knows the distinction between regular and dev dependencies 👍 |
Might be worth considering #4422 too when designing a |
What stands out to me is that uv sync is not a command designed for application install or deployment. It sets up the venv and workspace (for development/test?) and all the defaults point towards that use case (?) |
Today we discussed doing something like:
So most usages would just be We may even want to have a dedicated separate command for this with different defaults (per the above). |
#6538) See #4028 A smaller version of #6398 Co-authored-by: Charlie Marsh <[email protected]>
This will be available when we release (soon, I'm sure). Let me know if you encounter any problems! |
This is available now in 0.3.3 |
Is |
@justenstall we're waiting to see how necessary it is since we have |
Can |
No, it's not intended for long-term usage. You're probably looking for #6585 instead (which will release today). |
uv ha añadido soporte para gestionar proyectos. Se prueba en esta PR Relacionado: https://astral.sh/blog/uv-unified-python-packaging EDIT: - Ejemplo de FastAPI oficial: https://github.com/astral-sh/uv-fastapi-example - Hilos discutiendo mejoras para Docker: - astral-sh/uv#4028 - astral-sh/uv#6451 De esos últimos hilos, probablemente queremos añadir el `--frozen` y el `--no-locals` cuando lo implementen. Closes #43 Closes #48 Closes #49
Not sure if we want this -- it's like Poetry's
--no-root
. Let's wait and see if we can find motivating use-cases for it. Poetry also has this concept of "operating modes" which toggle this automatically.The text was updated successfully, but these errors were encountered: