Skip to content

Support for environment variables in requirement specifiers #6244

Closed
@gioele

Description

@gioele

Pip should accept bash-like enviroment variables in requirement specifiers and substitute them on the fly when pip is run.

What's the problem this feature will solve?

One possible use of this feature is installing packages from private GitHub repositories via OAuth. Right now this is not possible without storing the OAuth token in plain text in requirements.txt like, for example, git+https://1234abcdef56789:x-oauth-basic@github.com/myorg/private-package.git@v2.1.

Describe the solution you'd like

It would be nice if bash-like enviroment variables where accepted and substituted on the fly when pip is run. For example:

git+https://${GIT_TOKEN}:x-oauth-basic@github.com/myorg/private-package.git@v2.1

Alternative Solutions

A workaround is to use pip install -r <(envsubst < requirements.txt) instead of pip install -r requirements.txt, but this would not work when pip is invoked by other tools like pipenv.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: requirement fileUsing `requirements.txt`auto-lockedOutdated issues that have been locked by automation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions