uv icon indicating copy to clipboard operation
uv copied to clipboard

Add `constraints.txt` export to `uv export`

Open charliermarsh opened this issue 1 year ago • 1 comments

Constraints files are a little different... Specifically, every requirement has to be named, so we can't write relative paths. (You also can't include extras, but we already don't do that.)

charliermarsh avatar Aug 30 '24 00:08 charliermarsh

Hm. An export of the pyproject.toml constraints?

zanieb avatar Aug 30 '24 01:08 zanieb

No, it’s an export of the lockfile in constraints.txt format. requirements.txt files support things that constraints files do not. You can’t export in requirements.txt format and pass it as constraints.

charliermarsh avatar Aug 30 '24 02:08 charliermarsh

I've had this line in every rye-based Dockerfile for the last few years to work around this.

RUN sed -i '/^-e ./d' requirements.txt

carderne avatar Aug 31 '24 11:08 carderne

@carderne -- If you structure your project as a non-package (i.e., omit a [build-system] or set package = false under [tool.uv]), that line should be omitted from the export.

charliermarsh avatar Aug 31 '24 16:08 charliermarsh

Sorry maybe I crossed a wire. To be super explicit, this works:

uv init --package foo
cd foo
uv sync
uv run python -c 'import foo'

But if I set tool.uv.package = false then I obviously can't import foo.

I want foo to be installed in the venv, but I don't want it in the constraints file, as pip rejects that.

(Happy to have a thumbs up and go on my way, I might be derailing the point of this thread.)

carderne avatar Aug 31 '24 17:08 carderne