Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
feat: Add support for envsubst in extra_pip_args #1673
feat: Add support for envsubst in extra_pip_args #1673
Changes from 2 commits
3ca64f6
ff89fd7
57064ab
67f338d
3d76cc2
1eaf6ac
182cde8
4bd91b5
a6a2dc3
c6d9b4a
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vonschultz, could you elaborate a little on what is the usecase here? Is it only for the requirements files that your project owns? What should we do for the
PIP_INDEX_URL
in a non-root module? On one hand I think that the root module should be able to override the index url + extra index urls for everyone, but if that is what we want to achieve with this PR, then maybe having support for this in:might be maybe cleaner?
We could append the
index_url
and prepend theextra_index_urls
to the extra pip args and those would take precedence (I think).Are there other env var names that you want to expand here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The task I need it for is converting a project from
WORKSPACE.bazel
toMODULE.bazel
in a case where theWORKSPACE.bazel
uses environment variables (by writing them to a file using a repo rule and loading that file). Since loading isn't supported inMODULE.bazel
I need the support for environment variables here instead. I have only been thinking in terms of the root module, so I'm not entirely sure what the desired behavior would be in a non-root module.In principle, there are as many potential use cases as there are flags to
pip
, but to focus on the ones explicitly mentioned in the patch:PIP_RETRIES
, and alsoPIP_TIMEOUT
for that matter, are useful when the user has an unstable Internet connection. Rather like Bazel's own --http_timeout_scaling, which a user might put in their~/.bazelrc
, it is a property of the environment we run in, rather than the repo itself.PIP_INDEX_URL
is given to us by our CI system, and is pointing to an AWS CodeArtifact URL. ThePIP_INDEX_URL
contains a short-lived token for authentication, so we need to read it from the environment rather than hardcoding it in theMODULE.bazel
file.I haven't been thinking of
pip.override
. Isn't that specific for a given Python package (distribution)?https://rules-python.readthedocs.io/en/latest/api/extensions/pip.html#pip-override
It doesn't sound like it's something you'd use to override the index url.
I'm not convinced overriding the index url for everyone (including non-root modules) is the desired behavior. If someone uses the default https://pypi.org/simple certainly, we'd like to be able to redirect that, but if a non-root module very explicitly and purposefully uses a different index url containing a small set of packages not found on the public PyPI, then it's not a given that we should override that.
(Incidentally, I think
extra_index_urls
is a huge security issue, and should never be used. That's how we got hit by https://pytorch.org/blog/compromised-nightly-dependency/, and I'm sure there are many other cases like it.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from the environment variables I mentioned, I can also imagine
PIP_PROXY
being useful.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for elaborating on the extra index url usage.
I am wondering if the right thing here would be to have an
attr
for each thingpip
supports - the downside would be that we would need to have stuff in sync with thepip
version we support/use, but the upside would be that it would be more structured and we could more easily ensure that sensitive info does not leak into the lock file.What do you think? How many extra attributes would you need? @rickeylev, do you have any thoughts on this?