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

Should one use this library or the one from Python's standard library? #130

Closed
jaraco opened this issue Oct 22, 2020 · 4 comments
Closed
Labels
question Further information is requested

Comments

@jaraco
Copy link
Member

jaraco commented Oct 22, 2020

In GitLab by @sinoroc on Sep 30, 2020, 10:00

This is not an issue report, it is a question. Hopefully it is acceptable to ask it here, otherwise please redirect me to the appropriate venue...

In order to avoid the try-import-except-import dance, I am considering simply using this library for all Python versions that my project supports (Python 3.5 to 3.8, potentially 3.9), instead of importlib.metadata from the standard library where available. Is that an acceptable thing to do, any drawback one should be aware of?

On one side, one can read:

Users of Python 3.8 and beyond are encouraged to use the standard library module. When imported on Python 3.8 and later, importlib_metadata replaces the DistributionFinder behavior from the stdlib, but leaves the API in tact.

-- https://importlib-metadata.readthedocs.io/en/latest/

On the other:

This functionality is provisional and may deviate from the usual version semantics of the standard library.

-- https://docs.python.org/3/library/importlib.metadata.html

This is a bit confusing. What does that mean? What are more concretely the pros and cons of using one or the other?

Is there a way to know which version of importlib-metadata is in which version of Python (if that makes sense)?

@gkedge
Copy link

gkedge commented Nov 19, 2020

I want to be shmart using Python3.8 also. Do I install importlib-metadata or not?

@FFY00
Copy link
Member

FFY00 commented Nov 29, 2020

This should be the same as python/importlib_resources#196 (comment).

So I think you should check the importlib.metadata documentation and/or Python release notes and see if the feature you need is in the standard library or if you need to use this package which backports it.

@jaraco
Copy link
Member Author

jaraco commented Jan 10, 2021

Thanks FFY00. That's right, the approach is the same. At this time of writing, most of the functionality of importlib_metadata is in Python 3.8. Some recent features like dist attribute on entry points will only appear in later Pythons (probably 3.10).

@sinoroc
Copy link

sinoroc commented Apr 21, 2021

I guess the following commit also helps with this question: 0c86a02

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants