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

Removed usage of deprecated pkg_resources #541

Merged
merged 1 commit into from
Nov 17, 2023

Conversation

sliverc
Copy link
Contributor

@sliverc sliverc commented Apr 25, 2023

Fixes #503

pkg_resources is deprecated and should not be used anymore. We encountered this in our CI see django-json-api/django-rest-framework-json-api#1146

The version is now defined in polymorphic/__init__.py and setup.py extracts it from there. This way, there is also no need for setuptools to be installed when using django polymorphic.

@markgras
Copy link

markgras commented May 2, 2023

A few things:

  1. Did you give the attr: directive a try in setup.cfg? I think that that would be a cleaner drop-in replacement, would be less prone to error than a custom regex, and would keep all project metadata in setup.cfg instead of splitting it up between that and setup.py. Reference.
  2. PEP 396 has been rejected, so perhaps the best solution here is actually to make a breaking change and remove the __version__ attribute in __init__.py altogether.

Define version instead in polymorphic/__init__.py file.
@sliverc
Copy link
Contributor Author

sliverc commented May 3, 2023

Thanks @markgras for the hinter. I wasn't aware of attr directive. I have updated it accordingly. Furthermore, I added a version synonym for backwards compatibility, but if the maintainers decide this is not needed I am happy to remove it as well.

@markgras
Copy link

markgras commented May 3, 2023

Happy to help! The module attribute being accessed can have any name. In your new commit you could assign the version string to __version__ directly and then access that attribute in setup.cfg if you'd like. I believe that setuptools' example purposely doesn't use a dunder variable so as to not unintentionally imply that the rejected PEP 396 should be followed.

@sliverc
Copy link
Contributor Author

sliverc commented Oct 19, 2023

Just as an update. Python 3.12 removed pkg_resources, so it is not possible to use django-polymorphic anymore with Python 3.12. This PR fixes this as well. Great if it could get merged.

j-antunes pushed a commit to j-antunes/django-polymorphic that referenced this pull request Nov 14, 2023
@jleclanche jleclanche merged commit 3e830a3 into jazzband:master Nov 17, 2023
@sliverc sliverc deleted the define_version branch November 17, 2023 03:54
@alphatownsman
Copy link

ran into this in python 3.12 as well. thanks for fixing it. hope we can get a release soon.

sliverc added a commit to sliverc/django-rest-framework-json-api that referenced this pull request Nov 20, 2023
This way Python 3.12 will work as following PR was merged.

jazzband/django-polymorphic#541
sliverc added a commit to sliverc/django-rest-framework-json-api that referenced this pull request Nov 20, 2023
This way Python 3.12 will work as following PR was merged.

jazzband/django-polymorphic#541
amanning9 added a commit to cedadev/jasmin-services that referenced this pull request Mar 5, 2024
This is fixed in jazzband/django-polymorphic#541
, but there has not yet been a release.
@martin-thoma
Copy link

polymorphic/init.py:9: DeprecationWarning: pkg_resources is deprecated as an API

The last release is from 2021: https://pypi.org/project/django-polymorphic/#history , but in this repository are many updates.

Is djanog-polymorphic dead (on pypi)?

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.

Missing setuptools runtime dependency
6 participants