-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
[master] Fix the installation of pip modules with special characters in the module name #66989
Open
avelin
wants to merge
3
commits into
saltstack:master
Choose a base branch
from
avelin:avelin/pip-normalize
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
salt-project-bot-prod-environment
bot
changed the title
Fix the installation of pip modules with special characters in the module name
[master] Fix the installation of pip modules with special characters in the module name
Oct 23, 2024
twangboy
previously approved these changes
Oct 25, 2024
Normalize a Python package name according to https://packaging.python.org/en/latest/specifications/name-normalization/
Fix the handling of Python modules with non-standard characters in either the package name or the name of the installed module. Passing the module name through the normalize() function recommended by the Python packaging guidelines allows us to correctly match them, so that e.g. the consumers do not falsely report that a package was not installed correctly or needs to be installed. NB: this commit CHANGES the dictionary returned by `pip.list`; the package names will be normalized, so any consumers that look for specific names MUST also normalize the latter.
Similarly to `pip.list`, normalize package names before processing them. In this case most of the work is already done - most functions invoke `_check_package_version_format` and use the processed package name that it returns. Thus, to use the same normalization algorithm everywhere, make that function use `pip.normalize`, too. This, among other things, deals with some "There was no error installing package... although it does not show..." warnings when the package name contains underscores, since now we look for the correctly normalized name and we can find it. Fixes saltstack#66988
avelin
force-pushed
the
avelin/pip-normalize
branch
from
October 27, 2024 10:49
2f77c9a
to
8f9aaac
Compare
twangboy
approved these changes
Oct 28, 2024
TBH, I don't think the failing integration tests have much to do with this particular change; I think I saw them fail on the master branch, too. |
If you rebase against 3006.x you'll get this change in sooner... and tests should pass, assuming the bug exists in 3006. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
This pull request implements the changes described in #66988 to
make the
pip.installed
state handle correctly Python modules thatdiffer in their "user-friendly" PyPI name and the name that is
actually listed in the package metadata (and reported as installed by
the
pip
tool).There are three user-visible changes:
pip.normalize
function that implements the normalizationalgorithm descrined in
PEP 503
pip.list
function normalize the returned package names andalso normalize the supplied prefix before using it to filter the names
pip.installed
state normalize the user-supplied package namesbefore checking whether they are already installed and, later, checking
whether they have been successfully installed or upgraded
As noted in the issue, this will change the behavior of
pip.list
;however, I believe that packages with e.g. dashes in their names are
already handled incorrectly, so this will be an improvement.
There was another pull request (#66880) that attempted to fix
the warning reported by the
pip.installed
state when handlingpackage names with dashes; I have since come to believe that the solution
there was incomplete and it would be better to use the PEP 503
normalization algorithm in several places instead.
What issues does this PR fix or reference?
Fixes #66988
Previous Behavior
The pip.installed state is unable to verify the successful installation of some modules.
New Behavior
The pip.installed state finds the modules.
Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
Commits signed with GPG?
No