astral-sh / uv

An extremely fast Python package installer and resolver, written in Rust.
https://astral.sh/
Apache License 2.0
14.64k stars 415 forks source link

Support Environment Variable Expansion in Version Specifiers #4592

Open akan72 opened 1 week ago

akan72 commented 1 week ago

Specifying the versions of related packages via envvar would be really useful for us!

Here's an example of what we used to be able to do via pip-tools:

dagster==${DAGSTER_VERSION}
dagster-cloud==${DAGSTER_VERSION}
dagster-cloud-cli==${DAGSTER_VERSION}

The originating issue here (supporting environment variables in -r and -c paths, within requirements files) is now fixed by https://github.com/astral-sh/uv/pull/2143. If folks want environment variable expansion for other parts of the file (like version specifiers), we need to handle those on a case-by-case basis, so feel free to open a new issue to track it.

Originally posted by @charliermarsh in https://github.com/astral-sh/uv/issues/1473#issuecomment-1975402403

charliermarsh commented 1 week ago

We could probably support this, but I don't think we would preserve the environment variables in the output file (unlike for URLs, where we go to great lengths to support it).