Open Kobzol opened 2 months ago
@Kobzol this is roughly supported with uv add -r requirements.in
or uv add -r requirements.txt
.
I don't think we'll try to infer which packages are actual direct dependencies in the near future — it seems hard to get right and I'm not sure what the interface would look like. It does sound cool and helpful though — if someone were to prototype it, I'd take a look.
Hi, thank you for an awesome package management tool! :) I have a suggestion for a feature that I would appreciate very much when porting existing projects to
uv
.Dependencies of some existing Python projects are not managed very well, and they only exist in the form of a
requirements.txt
lockfile, or even just a set of installed packages in some virtual environment (from which you can generate the lockfile withpip freeze
). Migrating such a project touv
is currently a bit annoying. The naive approach is to take all the dependency specifications in the lockfile and put them inside thedependencies
array inpyproject.toml
, but that's usually not what you want, because it also contains transitive dependencies.What would help automate this process is if there was a
uv
command that would read an existing (pip
) lockfile, transform the packages into a graph, calculate a topological sort, and then separate the packages that are not depended upon by any other package in the lockfile (these form the "root" package dependencies with a high probability). It could then import these into thedependencies
array, and potentially interactively ask the user what to do about the rest of the packages (but even just separating the root packages would be quite useful).Why do I need to do this? Well, if I have an existing project with a set of packages, I want to make sure that after I migrate to
uv
, I will essentially have the same lockfile, to avoid any surprises. If I just took the known root level packages and migrated them todependencies
, the versions of the transitive dependencies would most likely be updated byuv
(especially since there's currently no support for changing versions of transitive dependencies in a lockfile, AFAIK).Let me know if it makes sense :)