uv icon indicating copy to clipboard operation
uv copied to clipboard

environment variable references in requirements files are not resolved

Open detlefla opened this issue 6 months ago • 4 comments

If a requirements file contains a line -r ${OTHERPKG}/requirements/dev.in, pip-compile tries to replace ${OTHERPKG} with the contents of an environment variable OTHERPKG. uv, however, uses the string literally and fails to find the location of the file to be included.

Maybe this is a feature uv has not implemented yet; I apologize if it's a documented restriction and I just didn't find it!

detlefla avatar Feb 16 '24 10:02 detlefla

Ah, we actually do support this, but not for paths to requirements files, only for dependency specifiers (like -e ${OTHER_PKG}/..).

charliermarsh avatar Feb 16 '24 14:02 charliermarsh

@charliermarsh I am not sure this issue from @detlefla is the same I have, but I believe uv doesn't support environment variables inside of requirements.txt file as described here: https://pip.pypa.io/en/stable/reference/requirements-file-format/#using-environment-variables

My txt file has the following:

mod-wsgi==${MOD_WSGI_WINDOWS_VERSION} ; sys_platform=='win32' and platform_machine=='AMD64'

But uv fails with

error: Couldn't parse requirement in `.\requirements\pip-deploy.txt` at position 276
  Caused by: expected version to start with a number, but no leading ASCII digits were found
mod-wsgi==${MOD_WSGI_WINDOWS_VERSION} ; sys_platform=='win32' and platform_machine=='AMD64'
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

inoa-jboliveira avatar Feb 17 '24 19:02 inoa-jboliveira

@inoa-jboliveira - It's similar! We support environment variables in URLs, but not in arbitrary locations like in a version specifier, so that's something we'd have to implement.

charliermarsh avatar Feb 17 '24 19:02 charliermarsh

Added support for both cases in the PR above

inoa-jboliveira avatar Feb 17 '24 23:02 inoa-jboliveira

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.

charliermarsh avatar Mar 03 '24 23:03 charliermarsh