Skip to content

Replace pkg_resources with importlib_metadata#2354

Merged
waylan merged 1 commit into
mkdocs:masterfrom
waylan:entrypoints
Apr 6, 2021
Merged

Replace pkg_resources with importlib_metadata#2354
waylan merged 1 commit into
mkdocs:masterfrom
waylan:entrypoints

Conversation

@waylan

@waylan waylan commented Apr 6, 2021

Copy link
Copy Markdown
Contributor

Related to #2347.

Comment thread setup.py
'ghp-import>=1.0',
'pyyaml_env_tag>=0.1'
'pyyaml_env_tag>=0.1',
'importlib_metadata>=3.10'

This comment was marked as abuse.

@waylan waylan Apr 6, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, the API changes in Python 3.10 and we are using the new API. Therefore, we need the backport for all supported versions of Python (3.6-3.9).

@waylan waylan Apr 6, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

From the docs:

Compatibility Note

The “selectable” entry points were introduced in importlib_metadata 3.6 and Python 3.10. Prior to those changes, entry_points accepted no parameters and always returned a dictionary of entry points, keyed by group. For compatibility, if no parameters are passed to entry_points, a SelectableGroups object is returned, implementing that dict interface. In the future, calling entry_points with no parameters will return an EntryPoints object. Users should rely on the selection interface to retrieve entry points by group.

Note that we are calling entry_points with the group parameter, which is using the new API (the "selection interface"), which is recommended.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

While the change was introduced in 3.6 of the backport (as noted above), there have been various improvements to the new API up through version 3.10. Therefore we are requiring importlib_metadata>=3.10.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

By the way, I had intended to include an explanation in the commit message. So thanks for the reminder.

@waylan
waylan merged commit ec64ab4 into mkdocs:master Apr 6, 2021
@waylan
waylan deleted the entrypoints branch April 6, 2021 15:51
@oprypin

This comment was marked as abuse.

@oprypin

This comment was marked as abuse.

@waylan

waylan commented Apr 25, 2021

Copy link
Copy Markdown
Contributor Author

The docs state:

This functionality intends to replace most uses of pkg_resources entry point API and metadata API. Along with importlib.resources in Python 3.7 and newer (backported as importlib_resources for older versions of Python), this can eliminate the need to use the older and less efficient pkg_resources package.

So I find it interesting that the opposite effect is observed.

@oprypin

This comment was marked as abuse.

ultrabug added a commit to ultrabug/mkdocs that referenced this pull request May 7, 2021
As per discussion on mkdocs#2347 our new babel code base should be
migrated to not require setuptools and use importlib_metadata
instead
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants