uv icon indicating copy to clipboard operation
uv copied to clipboard

Add `uv init --from-project <path>` to import from other tools

Open zanieb opened this issue 1 year ago • 8 comments

As previously discussed for uv add -r pyproject.toml but without any of the controversy about what to do with extras. We can copy all of the dependencies as reported by the build backend.

zanieb avatar Aug 20 '24 21:08 zanieb

I'll look into this tonight unless someone beats me to it.

charliermarsh avatar Aug 20 '24 21:08 charliermarsh

I have no idea why I closed this.

charliermarsh avatar Aug 20 '24 21:08 charliermarsh

Related: https://github.com/astral-sh/uv/issues/6164

charliermarsh avatar Aug 20 '24 23:08 charliermarsh

Is this up for grabs?

blueraft avatar Aug 21 '24 14:08 blueraft

Yes!

charliermarsh avatar Aug 21 '24 15:08 charliermarsh

You can use SourceTreeResolver to get the metadata. But one challenge is... we probably need to preserve extras rather than resolving them. For example, if the user's pyproject.toml has:

[project.optional-dependencies]
foo = "bar"

Then in the project we create, we'd also want to create a foo extra with bar in it.

charliermarsh avatar Aug 21 '24 15:08 charliermarsh

I'll take a look soon.

we'd also want to create a foo extra with bar in it.

This makes sense, a similar PR would then resolve #6164 right?

blueraft avatar Aug 21 '24 15:08 blueraft

Yeah, it's possible that we want to skip #6164 for now since it brings up some confusing questions, like what does --extra mean in uv add --extra baz -r pyproject.toml. So let's start with support here in uv init.

charliermarsh avatar Aug 21 '24 15:08 charliermarsh

What is needed to get this merged/released? It will help converting a lot of users from Poetry to UV, at least for companies which have large number of repo's.

mrijken avatar Sep 02 '24 06:09 mrijken

Shameless plug (in case someone stumbles over this issue here and --from-project is still WIP): I wrote a script to migrate our Poetry monorepo project to uv (keeping versions pinned). I doubt it will work immediately on other projects, but could be a good start.

https://gist.github.com/mrcljx/8e99a7f9fb924a573416f4365ee15873

mrcljx avatar Sep 19 '24 15:09 mrcljx

Any update on this?

Defiect avatar Aug 22 '25 03:08 Defiect