Skip to content

Fixes to work with Python 3.12+#254

Open
bje- wants to merge 3 commits into
klen:developfrom
bje-:develop
Open

Fixes to work with Python 3.12+#254
bje- wants to merge 3 commits into
klen:developfrom
bje-:develop

Conversation

@bje-

@bje- bje- commented Jun 21, 2024

Copy link
Copy Markdown

This patch removes the dependence on pkg_resources which is not available by default in Python 3.12 and beyond. It switches from pkg_resources.iter_entry_points to import_metadata.entry_points. import_metadata is available in all supported versions of Python.

The other change removes the use of parse_requirements and just hardcodes the package dependencies in setup.py, which is arguably good practice anyway since not all developer-installed packages are required by the installation.

Finally, setuptools is added to requirements.txt since it is also no longer installed by default with Python 3.12.

- Eliminate the use of pkg_resources which is no longer installed with
  Python 3.12 and greater.

- Add setuptools to requirements.txt which is no longer included in
  Python distributions (>= 3.12).
@bje-

bje- commented Apr 9, 2025

Copy link
Copy Markdown
Author

Ping?

@bje-

bje- commented Jun 8, 2025

Copy link
Copy Markdown
Author

Can this PR be merged, please?

@Famlam

Famlam commented Jun 8, 2025

Copy link
Copy Markdown

Maybe ping @klen in case it went unnoticed

It seems that even installing setuptools manually will stop working soon

UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.

@mshonichev

Copy link
Copy Markdown

ping @klen :)

Can this PR be merged, please, it's very annoying to suppress warnings in CI and it freaks me out that pylama would stop working after CI pipelines upgrade to python 3.12

@b-layer b-layer left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Are you sure about import_metadata (with underscore)? Not found for me when I merged this locally. Docs say import.metadata (with period) and that works. (Python 3.12.12)

@cjwatson

Copy link
Copy Markdown

Are you sure about import_metadata (with underscore)? Not found for me when I merged this locally. Docs say import.metadata (with period) and that works. (Python 3.12.12)

importlib_metadata does exist as a backport, but at this point there's no reason to use it any more; all supported Python versions have importlib.metadata in the stdlib. It might be worth explicitly declaring a new enough python_requires.

@bje-

bje- commented Jan 29, 2026

Copy link
Copy Markdown
Author

importlib_metadata does exist as a backport, but at this point there's no reason to use it any more; all supported Python versions have importlib.metadata in the stdlib. It might be worth explicitly declaring a new enough python_requires.

I've updated the PR.

@cnagarjuna

Copy link
Copy Markdown

Can this PR be merged, please?

@Marc-marc-marc

Copy link
Copy Markdown

For your information, there is another fork that seems more advanced, with fixes for this issue as well.
https://github.com/ccxcz/pylama.git
It might be useful for the two fixes to check each other and converge towards a common fix.
This would be useful if this upstream ever comes back to life.
ping @ccxcz @tunecrew involved in these improvements

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.

7 participants