-
Notifications
You must be signed in to change notification settings - Fork 1
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
Replace pkg_resources with importlib.metadata; bump minor version number #3
Conversation
A related questions are: |
description = "A plaster plugin to configure pyramid app with Yaml" | ||
readme = "README.md" | ||
authors = ["Guillaume Gauvrit <guillaume@gauvr.it>"] | ||
include = ["CHANGELOG.md"] | ||
license = "BSD-derived" | ||
|
||
[tool.poetry.dependencies] | ||
# See: https://pypi.org/project/backports.entry-points-selectable | ||
importlib_metadata = { version = ">=3.6", python = "<3.10" } |
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.
I was waiting to drop the python 3.7 support to remove pkg_resources usage.
Is it ok for you to drop python 3.7 support ?
importlib.metadata is avaible in python 3.8
so updating the ligne 13 with the code below should be enough.
python = "^3.8"
|
||
setattr(importlib, "metadata", importlib_metadata) | ||
else: | ||
import importlib.metadata |
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 is why I dislike that. 11 lines of code to retrieve a version number. this is outstanding.
please remove python 3.7 support and everything will be much simpler.
Honnestly, can't tell.
I've created this module years ago and I can't remember.
Yes, completely
No, egg means that the data to read is in the package metadata and it is not related to setuptools |
On Sat, 30 Mar 2024 01:40:37 -0700 Guillaume Gauvrit ***@***.***> wrote:
@mardiros commented on this pull request.
> description = "A plaster plugin to configure pyramid app with
> Yaml"
readme = "README.md"
authors = ["Guillaume Gauvrit ***@***.***>"]
include = ["CHANGELOG.md"]
license = "BSD-derived"
[tool.poetry.dependencies]
+# See: https://pypi.org/project/backports.entry-points-selectable
+importlib_metadata = { version = ">=3.6", python = "<3.10" }
I was waiting to drop the python 3.7 support to remove pkg_resources
usage.
Is it ok for you to drop python 3.7 support ?
importlib.metadata is avaible in python 3.8
so updating the ligne 13 with the code below should be enough.
```
python = "^3.8"
```
Unfortunately it is not enough. The entry_points() API did
not stabilize until python 3.10. See:
https://pypi.org/project/backports.entry-points-selectable/
So you have to use a backport if you want to use the same code
in 3.8 and 3.9 as in 3.10. In that case you may as well
support 3.7.
Also, take a look at the last paragraphs of:
https://docs.python.org/3/library/importlib.metadata.html#entry-points
I'm running python 3.11, and used it to successfully run the regression
tests. So the existing code works, but it's not certain that
it will continue to work on 3.12. My reading of the importlib.metadata
entry point docs above lead me to believe that EntryPoints is
an iterable object. But I'm not all that steeped in Python's
vocabulary so I'm not 100% certain I'm right.
(I suppose I could try reading the source. It's probably
easier to ask in #python. :-)
> @@ -1,5 +1,15 @@
-import pkg_resources
+import sys
+
+if sys.version_info < (3, 10):
+ import importlib_metadata
+
+ class importlib:
+ pass
+
+ setattr(importlib, "metadata", importlib_metadata)
+else:
+ import importlib.metadata
this is why I dislike that. 11 lines of code to retrieve a version
number. this is outstanding.
Agreed. But at least it's an easy-to-maintain 11 lines. It's clear
what needs to be done and when it's time to do it.
please remove python 3.7 support and everything will be much simpler.
Let me know how you'd like to proceed.
Regards,
Karl ***@***.***>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein
|
I will fix it it the main branch and release it |
I've release a 1.0.0 version here. let me know if something is wrong in a new issue. Thanks for the contribution. |
Hi,
Thanks for this package.
pkg_resources is depreciated. importlib.metadata replaces it.
I ran into PyYAML issue #601: yaml/pyyaml#601
The 5.4 .* releases all have the problem, so I bumped the required PyYAML version. PyYAML claims to support Python >=3.6, so that should not cause problems with your supported Python version. I can't say if this change would cause any other issues.
I can't say I know what I'm doing when it comes to python packaging. I'm also not sure that I properly ran the regression tests. I did run them and they passed, but only on Debian 12 (bookworm) with Python 3.11 (in a virtual environment containing the latest poetry and other tooling). (You see two commits here because I goofed the regression test run, at first.)
It is probably a good idea to bump the pyramid-helloworld required package version from 0.1.2. The current version is 1.0.0, and I sent in a PR that removes pkg_resources and bumps the pyramid-helloworld version to 1.1.0. In any case, leaving the required pyramid-helloworld version untouched in this package avoids some sort of reflexive mutual conflict which might prevent both from running their tests.
Notes on backported standard library modules:
I like to conditionally import backported standard library modules. I like to see the version number in the code so the version number is explicit, and in an obvious place. That way it is clear when it is time to remove the conditional import and just use the standard library.
I find that creating a class to act as the top-level module in the module path, when the backported library is not top-level, helps with mocks when unit testing.