Skip to content

install: Update extra-index-url in session from requirements file #8522

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

Merged
merged 3 commits into from
Aug 25, 2020

Conversation

NoahGorny
Copy link
Contributor

Resolves #8103
@pfmoore you are welcome to take a look 😄

Not sure how to test this though, maybe just check that session.auth.index_urls is updated as expected in a test?

@uranusjr
Copy link
Member

Where were --extra-index-url from command line and the --index-url from requirements file populated into the session? It seems weird we need to update this separately.

@ivanst0
Copy link

ivanst0 commented Jul 30, 2020

URLs from both --index-url and --extra-index-url are treated equally and stored in session.auth.index_urls and finder.index_urls. They are not stored in session itself, just passed to auth (session.py:252). When the session is initialized (install.py:278) only options from command line are available. The options from the requirements file are populated into finder.index_urls only later by get_requirements() (install.py:300). At that point session.auth.index_urls can be updated to include URLs from the requirements file.

@uranusjr
Copy link
Member

Thanks for the explanation! The patch makes sense to me now. It seems like the whole requirements file parsing logic needs some serious revamping 🙁 But this will have to do for now.

@NoahGorny
Copy link
Contributor Author

@uranusjr @ivanst0 I am pinging this as this seems to be ready and can be merged (pip just released a version, so merging should be okay now)

@sbidoul
Copy link
Member

sbidoul commented Aug 5, 2020

Would it be better to update session.index_urls in req_file.handle_option_line()? It is the place where the finder search scope is updated with index urls found in requirement files, so it could make sense to put the update of the session at the same place so it will be easier to spot when refactoring the requirements parser.

@NoahGorny NoahGorny force-pushed the fix-requirements-file-options branch from 47f7299 to 80620ea Compare August 5, 2020 18:10
@NoahGorny
Copy link
Contributor Author

Would it be better to update session.index_urls in req_file.handle_option_line()? It is the place where the finder search scope is updated with index urls found in requirement files, so it could make sense to put the update of the session at the same place so it will be easier to spot when refactoring the requirements parser.

This is a very good idea, take a look now @sbidoul, moved to here and pushed a change

@NoahGorny NoahGorny force-pushed the fix-requirements-file-options branch from 80620ea to 2e9d1f0 Compare August 5, 2020 18:16
@sbidoul
Copy link
Member

sbidoul commented Aug 6, 2020

@NoahGorny thanks for the update. It would nice to add a test in test_req_file.py, for which you can find inspiration here, using the session fixture.

@NoahGorny NoahGorny force-pushed the fix-requirements-file-options branch from 2e9d1f0 to 3e70cbe Compare August 6, 2020 16:26
@NoahGorny
Copy link
Contributor Author

@NoahGorny thanks for the update. It would nice to add a test in test_req_file.py, for which you can find inspiration here, using the session fixture.

Updated the relevant tests, take a look and thanks a lot for your feedback! 😄

Copy link
Member

@sbidoul sbidoul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Co-authored-by: Pradyun Gedam <[email protected]>
@NoahGorny
Copy link
Contributor Author

@pradyunsg thanks for the additional review 😄
I think the PR is ready now 😃

@ivanst0
Copy link

ivanst0 commented Aug 25, 2020

This PR has two approvals and all tests are passing, is there anything else blocking the merge?

Could you please link it to #8640?

@NoahGorny
Copy link
Contributor Author

@pradyunsg @uranusjr could you give us a hand here?

@pradyunsg pradyunsg merged commit e17f845 into pypa:master Aug 25, 2020
@pradyunsg
Copy link
Member

pradyunsg commented Aug 25, 2020

Merged, not because I reviewed this but since there's 2 other approvals already. Thanks for the PR @NoahGorny and for the nudge here @ivanst0! :)

@NoahGorny NoahGorny deleted the fix-requirements-file-options branch August 25, 2020 15:46
@mitar
Copy link

mitar commented Dec 16, 2020

Thanks for fixing #8103! Could I suggest that documentation is updated as well? Currently it says:

pip install keyring
echo your-password | keyring set pypi.company.com your-username
pip install your-package --extra-index-url https://pypi.company.com/

But with this fix it should be:

pip install keyring
echo your-password | keyring set https://pypi.company.com/ your-username
pip install your-package --extra-index-url https://pypi.company.com/

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--extra-index-url in requirements.txt
6 participants