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

Distribution lookup is case-sensitive #20

Closed
jaraco opened this issue Oct 22, 2020 · 18 comments
Closed

Distribution lookup is case-sensitive #20

jaraco opened this issue Oct 22, 2020 · 18 comments
Labels
bug Something isn't working
Milestone

Comments

@jaraco
Copy link
Member

jaraco commented Oct 22, 2020

In GitLab by @jaraco on Nov 1, 2018, 20:12

~ $ rwt -q importlib_metadata==0.6 -- -c "import importlib_metadata; print(importlib_metadata.version('PyJWT'))"
1.6.4
~ $ rwt -q importlib_metadata==0.6 -- -c "import importlib_metadata; print(importlib_metadata.version('pyjwt'))"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/rwt-_mwk2v6o/importlib_metadata/api.py", line 105, in version
    return distribution(package).version
  File "/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/rwt-_mwk2v6o/importlib_metadata/api.py", line 86, in distribution
    return Distribution.from_name(package)
  File "/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/rwt-_mwk2v6o/importlib_metadata/api.py", line 52, in from_name
    raise PackageNotFoundError(name)
importlib_metadata.api.PackageNotFoundError: pyjwt

Probably the search should be case-insensitive.

@jaraco jaraco added the bug Something isn't working label Oct 22, 2020
@jaraco jaraco added this to the 0.7 milestone Oct 22, 2020
@jaraco
Copy link
Member Author

jaraco commented Oct 22, 2020

In GitLab by @warsaw on Nov 2, 2018, 24:32

Do you know if it's possible to upload different packages to PyPI which differ only in their case? I sure hope the answer is "no".

@jaraco
Copy link
Member Author

jaraco commented Oct 22, 2020

In GitLab by @jaraco on Nov 2, 2018, 24:51

Definitely no. The names are normalized by the packaging tools.

@jaraco
Copy link
Member Author

jaraco commented Oct 22, 2020

In GitLab by @jaraco on Nov 2, 2018, 01:00

I was about to write a test to capture this issue when I realized the tests aren't running with pytest, so I don't get fixtures... so creating a test against which to validate is not fun when the tools I would use to do that are not present.

As time permits, I'll learn what facilities unittest provides.

I also wonder - should importlib_resources support all package name normalization (e.g. _ -> -) or just case insensitivity?

@jaraco
Copy link
Member Author

jaraco commented Oct 22, 2020

In GitLab by @jaraco on Nov 2, 2018, 01:02

should importlib_resources support all package name normalization (e.g. _ -> -) or just case insensitivity?

On further consideration, probably not... because the names being used are not normalized at all... so the user can be expected to provide the canonical name, and we'll add case insensitivity for convenience.

@jaraco
Copy link
Member Author

jaraco commented Oct 22, 2020

In GitLab by @warsaw on Nov 2, 2018, 01:10

I concur that we should keep package name normalization to a minimum. IME, it can cause many problems, especially when competing systems are normalizing or not with subtly different rules.

I think case insensitivity makes sense, but I'd like to see the implementation. Given that the name on the file system could differ by case, you'll have to be somewhat careful in how you match the file system names. Maybe it won't be too difficult though. We'll need a really good set of tests to cover the conditions.

As for unittest vs. pytest - the main reason for using unittest and keeping external dependencies to a minimum are because this package will have to get ported to Python 3.8. If we use pytest here, that will be more difficult. (The same holds true for importlib_resources of course.)

@jaraco
Copy link
Member Author

jaraco commented Oct 22, 2020

In GitLab by @jaraco on Nov 10, 2018, 16:22

mentioned in commit d4da27e

@jaraco
Copy link
Member Author

jaraco commented Oct 22, 2020

In GitLab by @jaraco on Nov 10, 2018, 16:22

mentioned in commit 0e945cf

@jaraco
Copy link
Member Author

jaraco commented Oct 22, 2020

In GitLab by @jaraco on Nov 10, 2018, 16:22

mentioned in commit 8bf0770

@jaraco
Copy link
Member Author

jaraco commented Oct 22, 2020

In GitLab by @jaraco on Nov 10, 2018, 16:22

mentioned in commit a017b2d8d2f8f8499cbe5b78847767fb12039a26

@jaraco
Copy link
Member Author

jaraco commented Oct 22, 2020

In GitLab by @jaraco on Nov 10, 2018, 16:26

mentioned in merge request !27

@jaraco
Copy link
Member Author

jaraco commented Oct 22, 2020

In GitLab by @jaraco on Nov 10, 2018, 16:28

mentioned in commit cf550b3cd6f4c79854d2ff7e5a0329e896d4cccf

@jaraco
Copy link
Member Author

jaraco commented Oct 22, 2020

In GitLab by @jaraco on Nov 10, 2018, 19:33

mentioned in commit 4f67ef8c7c6a7e768df4c95f142e0972721f405d

@jaraco
Copy link
Member Author

jaraco commented Oct 22, 2020

In GitLab by @jaraco on Nov 10, 2018, 19:33

mentioned in commit ef0dc89d00d0be4e598a8d9dad6b6c7f459a7d2d

@jaraco
Copy link
Member Author

jaraco commented Oct 22, 2020

In GitLab by @jaraco on Nov 10, 2018, 23:52

mentioned in commit e2f057605be3b45cfc150e55da660bc25d478b07

@jaraco
Copy link
Member Author

jaraco commented Oct 22, 2020

In GitLab by @jaraco on Nov 10, 2018, 23:52

mentioned in commit 0470c56033e51d59397dc27e123c70f55a5bfcdc

@jaraco
Copy link
Member Author

jaraco commented Oct 22, 2020

In GitLab by @jaraco on Nov 11, 2018, 24:03

mentioned in commit bdf3dcc

@jaraco
Copy link
Member Author

jaraco commented Oct 22, 2020

In GitLab by @jaraco on Nov 11, 2018, 24:03

mentioned in commit a0b07d9

@jaraco
Copy link
Member Author

jaraco commented Oct 22, 2020

In GitLab by @jaraco on Nov 27, 2018, 17:18

closed via commit d4da27e

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

No branches or pull requests

1 participant