-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Constraint flag for uv add
#6518
Comments
That's fine, in fact that's probably the best behavior, that the constraint applies to all dependencies. But in line with my Airflow use case, it'd be great if we can specify a URL for |
cc @potiuk |
Can you not specify a URL in |
Sorry I don't think |
Sorry — |
How? I tried running [tool.uv]
constraint-dependencies = ["https://raw.githubusercontent.com/apache/airflow/constraints-2.10.0/constraints-3.8.txt"] but got
|
Ah sorry I misunderstood — yes this requires the constraints to be unpacked into a list. I'm not sure it makes sense to use a remote file here? We'd need to download it on every uv operation. Could we just unpack it into this setting on |
I get the overhead hit, but is it any different from
Yes, that could be a good fallback, if you decide not to support saving the URL itself in |
Yes, it's different because you |
I see, that makes sense. So can we at least add the flag
I guess there are some outstanding questions about what the expected behavior should be in these scenarios:
|
Yeah that sounds nice. We should probably support it for local files first. I'm a little hesitant on automatically tracking the URL but maybe it'd be okay. I think they'd be combined as we would normally combine constraint files when they overlap (which I think means we'd raise an error if it results in unsolvable dependencies). |
…6596) Add missing portions of documents reported in #6518 and #5248(Comment). ## Summary <img width="600" alt="override" src="https://github.com/user-attachments/assets/062f0036-8672-4c68-b21c-aebdeb79b58b"> <img width="600" alt="constraint" src="https://github.com/user-attachments/assets/f5ef1aa2-0662-4352-a1a0-3af1127fb7fb">
FWIW I have exactly the same use case as @yehoshuadimarsky and I'd be very pleased to see his suggestion implemented. I'd add that running Currently, I am specifing a minimal list of dependencies in The specific commands I'm using currently.
> uv pip compile pyproject.toml --constraint https://raw.githubusercontent.com/apache/airflow/constraints-2.9.2/constraints-3.11.txt --no-strip-extras --emit-index-url --all-extras --output-file requirements.txt -q
> uv pip sync requirements.txt
> uv pip install --requirement requirements.txt A separate, but related, feature request, would be an option to write the constraint file used to the top of the requirements.txt file. As described in point 3 of these MWAA docs. |
This is a workaround, but at my company , in our airflow project we use Taskfile ( makefile alternative ) to manage the constrained airflow dependencies, and do not rely on
-c https://raw.githubusercontent.com/apache/airflow/constraints-2.10.4/constraints-3.10.txt
boto3 >1.34, <1.36
botocore >1.34, <1.36
s3transfer == 0.10.4
apache-airflow==2.10.4
apache-airflow-providers-amazon==9.1.0 and # https://taskfile.dev
version: '3'
vars:
REQIN: requirements.in
REQOUT: requirements.txt.out
tasks:
default:
cmds:
- task -l
silent: true
install:
desc: Compile and install requirements
deps: [compile]
aliases: [i]
cmds:
- uv pip install -r {{ .REQOUT }}
compile:
desc: Compile python requirements
aliases: [c]
cmds:
- uv pip compile {{ .REQIN }} > {{ .REQOUT }}
sync:
desc: Sync installed packages with requirements file
aliases: [s]
cmds:
- uv pip sync {{ .REQOUT }} Then instead of
|
Hi, can we instead add a new flag
-c / --constraint
touv add
, so that you can pass in constraint files directly? I think currently you can do this by adding a constraint to arequirements.txt
file, then runninguv add --requirements requirements.txt
, but this would embed it directly in the command.My specific use case is using Apache Airflow which only supports
pip
(not Poetry etc) because it basically requires constraint files, see https://github.com/apache/airflow/blob/main/README.md#installing-from-pypiThat way, I can do (copying from their example):
Thanks.
The text was updated successfully, but these errors were encountered: