Skip to content
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

Keyring multi choice #11698

Merged
merged 7 commits into from
Mar 15, 2023
Merged

Keyring multi choice #11698

merged 7 commits into from
Mar 15, 2023

Conversation

Darsstar
Copy link
Contributor

@Darsstar Darsstar commented Jan 5, 2023

Fixes #8719.
Fixes #11020

See #8719 (comment) for the reasoning why this implementation, or a minor variant, is desired over a simpler on/off switch as implemented in #11215.

It is currently based on #11029, which is, as of writing this, a part of the 23.0 milestone since it would touch the same unit tests. Making a rebase inevitable either way.
Let me know if I should make it more standalone.

@Darsstar Darsstar force-pushed the keyring-multi-choice branch 3 times, most recently from 12c5206 to 527e43e Compare January 5, 2023 13:22
@Darsstar Darsstar force-pushed the keyring-multi-choice branch 3 times, most recently from 412a5d9 to 230b588 Compare January 12, 2023 15:32
@Darsstar
Copy link
Contributor Author

I resolved all your comments in the refactoring I did.

Copy link
Member

@uranusjr uranusjr left a comment

Choose a reason for hiding this comment

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

I added a couple of commits on doc and minor code cleanups

src/pip/_internal/network/auth.py Outdated Show resolved Hide resolved
src/pip/_internal/network/auth.py Outdated Show resolved Hide resolved
src/pip/_internal/network/auth.py Outdated Show resolved Hide resolved
Copy link
Contributor Author

@Darsstar Darsstar left a comment

Choose a reason for hiding this comment

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

I noticed a small typo I made when I was reading your documentation improvements, so I fixed that as well.

src/pip/_internal/network/auth.py Outdated Show resolved Hide resolved
src/pip/_internal/network/auth.py Outdated Show resolved Hide resolved
src/pip/_internal/network/auth.py Outdated Show resolved Hide resolved
Dos Moonen and others added 5 commits January 30, 2023 09:00
…import` or `subprocess`

Refactored `_get_index_url()` to get integration tests for the subprocess backend working.

Keyring support via the 'subprocess' provider can only retrieve a password, not a username-password combo. The username therefor MUST come from the URL.
If the URL obtained from the index does not contain a username then the username from a matching index is used. `_get_index_url()` does that matching.

The problem this refactoring solves is that the URL where a wheel or sdist can be downloaded from does not always start with the index url. Azure DevOps Artifacts Feeds are an example since it replaces the friendly name of the Feed with the GUID of the Feed. Causing `url.startswith(prefix)` to evaluate as `False`.

The new behaviour is to return the index which matches the netloc and has the longest common prefix of the `path` property of the value returned by `urllib.parse.urlsplit()`. The behaviour for resolving ties is unspecified.
@Darsstar Darsstar force-pushed the keyring-multi-choice branch from ef02ef2 to 16bd6b7 Compare January 30, 2023 08:02
@pypa-bot pypa-bot removed the needs rebase or merge PR has conflicts with current master label Jan 30, 2023
Copy link
Member

@uranusjr uranusjr left a comment

Choose a reason for hiding this comment

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

I am OK with this personally, but other maintainers may have different concerns.

@pfmoore
Copy link
Member

pfmoore commented Jan 30, 2023

I'm neutral. This seems like a reasonable solution, but I still have fundamental reservations about how keyring is integrated with pip, and this feels like it's a band aid over that fundamental problem.

The original approach was to use keyring (via import) if it was installed. That has issues with the question of how you install keyring. At some point we added the option to use keyring via command line. Now we're making keyring opt-in, adding yet more options, and generally making the whole thing ever more complex. I frankly don't think this is the right way to evolve things here. Keyring support is a relatively niche requirement, aimed mostly at large organisations who have private, password-protected indexes. And yet we're spending increasing amounts of volunteer time and adding complexity to pip's code base for it.

The same is true of a lot of pip's network stack. Realistically, we do little more than fetch URLs, and having all of the various options to control that process (including keyring, but going way beyond that with proxy settings, trusted URLs, timeouts and retries, etc) is overhead on top of our core job. What I'd love is for us to outsource the whole "get a URL" job onto a library dedicated to making that just happen - ideally, integrating with the standard platform settings. So we don't have to. But that's a much bigger topic, and as far as I know no such library exists, so I'll raise a separate issue for that one 🙂

TBH, I doubt we're going to get a better answer than this PR in the short term. And I don't want to block this just because we might be able to do better "someday". But I do think we need to keep aware of the long term implications.

@pradyunsg
Copy link
Member

FWIW, as the RM for 23.0, I'm gonna say that this isn't going to be in this release. We can include it in the next one.

@github-actions github-actions bot added the needs rebase or merge PR has conflicts with current master label Feb 3, 2023
@pypa-bot pypa-bot removed the needs rebase or merge PR has conflicts with current master label Feb 21, 2023
# Conflicts:
#	src/pip/_internal/network/auth.py
@Darsstar Darsstar force-pushed the keyring-multi-choice branch from 9a0d319 to 6affad8 Compare February 21, 2023 13:03
@uranusjr
Copy link
Member

I’m going to merge this for 23.1 and see what happens.

@uranusjr uranusjr merged commit 5c3d1fe into pypa:main Mar 15, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 4, 2023
@Darsstar Darsstar deleted the keyring-multi-choice branch April 11, 2023 14:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
5 participants