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

Overeager pip normalization #206

Merged
merged 3 commits into from
Jan 2, 2024

Conversation

blast-hardcheese
Copy link
Collaborator

Unfortunately, even normalization rules are not the end of the story when it comes to pip freeze!

pip install discord-py will still result in pip freeze | grep discord == discord.py, since that's the name tracked in the metadata.

Exciting!

@blast-hardcheese blast-hardcheese added the bug Something isn't working label Jan 2, 2024
@blast-hardcheese blast-hardcheese requested a review from a team as a code owner January 2, 2024 21:12
@blast-hardcheese blast-hardcheese requested review from masad-frost and removed request for a team January 2, 2024 21:12
@@ -368,6 +368,12 @@ func makePythonPipBackend(python string) api.LanguageBackend {
span, ctx := tracer.StartSpanFromContext(ctx, "pip install")
defer span.Finish()

normalizedPkgs := make(map[api.PkgName]api.PkgName)
for name := range pkgs {
// Deleting this denormalizes the output of upm list, fixing Workspace bug, but breaks upm add --lang pip
Copy link
Collaborator

Choose a reason for hiding this comment

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

fixing Workspace bug

Can we reference or describe the bug so this isn't scary to change later?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think that was a WIP comment, it doesn't read well. I'll fix it up, thanks

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fleshed that out a bit. The underlying issue was Workspace was attempting to install discord.py, which we were normalizing and returning as discord-py, which would then (rightfully) confuse the workspace.

Hopefully the comment makes more sense.

@masad-frost
Copy link
Member

python wtf moment

pip freeze output is actually pip's internal canonicalized form, which
can be different from the normalized package name format.

Example: `discord.py` gets normalized into `discord-py`,
but `pip show discord-py` still outputs `Name: discord.py`.
Names in requirements.txt are the package as tracked in package metadata, not necessarily the normalized name of the package.

Example: pip install discord-py will add `discord.py` to the output of `pip freeze`.
@blast-hardcheese blast-hardcheese force-pushed the dstewart/overeager-pip-normalization branch from 4ed1ffd to 8e129bc Compare January 2, 2024 21:29
@blast-hardcheese blast-hardcheese enabled auto-merge (squash) January 2, 2024 22:28
@blast-hardcheese blast-hardcheese merged commit c35c3ca into main Jan 2, 2024
3 checks passed
@blast-hardcheese blast-hardcheese deleted the dstewart/overeager-pip-normalization branch January 2, 2024 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants