Support uv add -r requirements.txt (#6005)

## Summary

Resolves https://github.com/astral-sh/uv/issues/4537

- First commit avoids overwriting dependencies with different markers.
- Second commit supports adding from requirements files.

## Test Plan

`cargo test`
This commit is contained in:
Ahmed Ilyas 2024-08-16 23:57:45 +02:00 committed by GitHub
parent 6cfb27c5e1
commit 268c6de7fd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 173 additions and 21 deletions

View file

@ -466,12 +466,12 @@ uv will search for a project in the current directory or any parent directory. I
<h3 class="cli-reference">Usage</h3>
```
uv add [OPTIONS] <REQUIREMENTS>...
uv add [OPTIONS] <PACKAGES|--requirements <REQUIREMENTS>>
```
<h3 class="cli-reference">Arguments</h3>
<dl class="cli-reference"><dt><code>REQUIREMENTS</code></dt><dd><p>The packages to add, as PEP 508 requirements (e.g., <code>ruff==0.5.0</code>)</p>
<dl class="cli-reference"><dt><code>PACKAGES</code></dt><dd><p>The packages to add, as PEP 508 requirements (e.g., <code>ruff==0.5.0</code>)</p>
</dd></dl>
@ -696,6 +696,10 @@ uv add [OPTIONS] <REQUIREMENTS>...
</dd><dt><code>--reinstall-package</code> <i>reinstall-package</i></dt><dd><p>Reinstall a specific package, regardless of whether it&#8217;s already installed. Implies <code>--refresh-package</code></p>
</dd><dt><code>--requirements</code>, <code>-r</code> <i>requirements</i></dt><dd><p>Add all packages listed in the given <code>requirements.txt</code> files.</p>
<p>Implies <code>--raw-sources</code>.</p>
</dd><dt><code>--resolution</code> <i>resolution</i></dt><dd><p>The strategy to use when selecting between the different compatible versions for a given package requirement.</p>
<p>By default, uv will use the latest compatible version of each package (<code>highest</code>).</p>