Skip to content

Describe using importlib-metadata as an alternative to pkg_resources for single-sourcing versions#706

Merged
pradyunsg merged 2 commits intopypa:masterfrom
jwodder:importlib-resource
Mar 20, 2020
Merged

Describe using importlib-metadata as an alternative to pkg_resources for single-sourcing versions#706
pradyunsg merged 2 commits intopypa:masterfrom
jwodder:importlib-resource

Conversation

@jwodder
Copy link
Copy Markdown
Contributor

@jwodder jwodder commented Mar 12, 2020

Item 5 in "Single-sourcing the package version" currently presents its approach using pkg_resources. However, pkg_resources is inefficient (and possibly deprecated?), and more efficient & modern alternatives to it are being developed in the form of importlib.resources and importlib.metadata. This PR extends item 5 to also show how to achieve the same thing using importlib.metadata. It also adds a note that the pkg_resources version requires setuptools as a runtime dependency.

I expect there will be some debate over whether to present both methods side by side or whether to delete the pkg_resources method in favor of importlib.metadata. I'm open to both possibilities.

Copy link
Copy Markdown
Member

@xavfernandez xavfernandez left a comment

Choose a reason for hiding this comment

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

I think the importlib.metadata should be presented before the pkg_resources one.

Copy link
Copy Markdown
Member

@pfmoore pfmoore left a comment

Choose a reason for hiding this comment

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

I agree with @xavfernandez, I'd be in favour of putting the importlib.metadata approach first.

@jwodder
Copy link
Copy Markdown
Contributor Author

jwodder commented Mar 13, 2020

@xavfernandez @pfmoore importlib-metadata section moved before the pkg_resources section.

@pradyunsg pradyunsg merged commit da43812 into pypa:master Mar 20, 2020
@pradyunsg
Copy link
Copy Markdown
Member

Thanks for the PR @jwodder, and the reviews @pfmoore and @xavfernandez!

@jwodder jwodder deleted the importlib-resource branch March 20, 2020 15:26
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.

4 participants