-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
convert underscore to dash in pip package names #18126
Conversation
rosdep/python.yaml
Outdated
@@ -237,13 +237,13 @@ python: | |||
python-adafruit-bno055-pip: | |||
debian: | |||
pip: | |||
packages: [adafruit_bno055] | |||
packages: [adafruit-bno055] |
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.
According to pip freeze
it is Adafruit-BNO055
I find it rather confusing to use a different name in the rosdep database then what the actual package name on PyPI is (e.g. https://pypi.org/project/catkin_tools/). I think it would be "cleaner" if the rosdep value matches exactly the package name on PyPI. Any necessary transformation should be done by the tool imo. |
@dirk-thomas: the updated names are the PyPi packages names (as reported by pip). As an alternative approach, rosdep could use a canonical name to match against the |
|
But it shows as |
But the debian package name is Don't get me wrong, I see your point, this will confuse users at first. |
@tfoote, @mikaelarguedas, @dirk-thomas: How to proceed 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.
This looks good to me as it stands.
As I see it:
- The pip rules should use the canonical "pip" name, as reported by
pip freeze
. There's not a programmatic mapping from any project name to the pip key that I know of we can implement in code.
The main key for consistency sake should follow the predicted debian naming convention with the -pip
extension if pip only.
There is a "canonicalize_name" method in the packaging module: https://github.com/pypa/packaging/blob/master/docs/utils.rst
That implements PEP 503's normalize names, but pip freeze doesn't follow that entirely. Exceptions I found on my system include both .
and capitals.
pyOpenSSL==0.15.1
zope.interface==4.1.3
Also note that there's actually bugs related to using the different names within pip: pypa/pip#5021 they're not even equivalent. |
I don't agree with the above statement:
Why are the actual package names declared in the packages source code not "canonical"? |
That's a very good question (there are some open issues discussing this..).
(needs pip 9 or newer) |
Any chance this gets rebased and merged (as a temporary solution) until a final solution is agreed upon and implemented? |
a month later....any chance this gets rebased and merged? |
@dirk-thomas Since this is how pip works, will it work for you if we just follow what they're doing since we don't have control over it? If so we'd just need a rebase of this commit. |
My opinion hasn't changed. I think the canonical name is the name a package declares in its manifest and the rosdep database should use that exact name. When interacting with |
Unfortunately, the names are case-sensitive as well. |
The underscore / dash replacement was just an example. Whatever transformation |
This seems to vary with each pip version. |
If that is the case that is an even stronger reason why we shouldn't manipulate the entries in the rosdep database. If that mangling changes we have to way to get back to the canonical / "upstream" name of the packages. And a single database wouldn't work with different pip versions. |
@dirk-thomas, that's why I added:
These names work with all pip versions and are easy to verfiy/maintain. |
This conversation is not making much progress. I have stated a clear reason why I think the canonical names of the packages should be kept in the rosdep database without any mangling. What is the advantage of mangling the package names in place (over applying the name mangling at runtime by code in |
The canonical name (w.r.t pip) is the name reported by pip.
I don't think that it would be hard to write (after the actual logic was identified). But it would introduce effort for the rosdep maintainers to keep up with the rules implemented by each pip version: |
If each PIP version mangles differently which variation of the mangled package names would you propose to store in the rosdep database then? |
pip does not really mangle the name. There is one name that is used by pip internally (the one that is reported by I see two alternatives:
While the latter is consistent with |
A package named e.g.
Please use fixed terminology for the conversation. "Canonical" seems to be not agreed on - I defined it above as the name in the upstream source. In this context I think you mean the name reported by pip. If we can't get a consensus on the term we shouldn't use it at all to avoid confusion.
A straight forward solution to this case would be to apply the transformation in the @ipa-mdl Do you agree that if you can manually rewrite rosdep keys in the database [your option 1] that the very same effect can be achieved by keeping the rosdep database untouched and transforming the value in some code (wherever that logic would be) [your option 2]? |
TL;DR: This PR should at least get refactored to fix the case of the pip entries. It would be great to find any solution for the "dash problem" as well.
I don't agree. The manual process is case specific (-> for each package) and can be verified with
The rosdep database does not contain the Python/PyPi package name, but whatever is the internal name in the respective installer (e.g. pip). That's what rosdep was created for (?).
This would require every data user to know about the transformation which is buried in some code. |
I absolutely agree with you on this part. 👍 e.g.
All of the following URLs resolve to a single page (the first one which is the name of the :
Same for
So updating the existing rosdep entries to the actual package name seems to be fairly straight forward and scriptable. Also for instructions it is easy to recommend using the name which the PyPI page actually resolves to aka the "upstream" package name. |
At some level I understand the desire to use the declared name. But pip clearly prefers and basically changes strongly recommends to enforces that there's no underscores. Some commands work with either the underscored version or the dashed version. But some only work with the dashed version. And pip always outputs the dashed version in it's listings. Underscore cannot be used for
pip freeze only reports the dashed version.
I agree that it would be relatively easy to write the logic to mangle a rule for
|
For me, the So if they're even close in terms of correctness, my preference would be for
🤷♂️ |
I agree that's not good, but maybe the right answer is to give hints for people (maybe when using In the end, I feel that this is a problem that PyPI has invented (by choosing a convention that's contrary what the community is doing ergonomically), so I feel we're not to blame if someone confuses |
At the risk of wading into something that I don't fully understand... This has been open for 2 years, with no real movement in almost 2 years. The title doesn't really reflect what it does. There is a merge conflict. And there seems to be no agreement here. So I'm going to tentatively close this PR. If you feel that we should keep this open, please feel free to reopen. |
For what its worth, the dash version is called the "normalized name" as per this PEP:
Also, interesting to notes that now it seems https://pypi.org/project/catkin_pkg/ redirects to https://pypi.org/project/catkin-pkg/ It is indeed unfortunate that the normalized name is not usable in an actual python import statement. I fell down this rabbit hole while trying to decide what to name my own packages: repos, directories, package name, etc. |
related to #18116