model_utils/__init__ uses deprecated pkg_resources module, raises a DeprecationWarning
jacobian-latacora opened this issue · 2 comments
jacobian-latacora commented
Problem
Using model_utils
raises a DeprecationWarning
-- for example, when running tests:
=== warnings summary ===
../../../[REDACTED]/lib/python3.11/site-packages/pkg_resources/__init__.py:121
[REDACTED]lib/python3.11/site-packages/pkg_resources/__init__.py:121: DeprecationWarning: pkg_resources is deprecated as an API
warnings.warn("pkg_resources is deprecated as an API", DeprecationWarning)
This comes from model_utils/__init__
, which calls pkg_resources. I think it's just doing this to work out __version__
, which seems pretty safe to remove?
Environment
- Django Model Utils version: 4.3.1
- Django version: 4.2
- Python version: 3.11.2
- Other libraries used, if any:
[tool.poetry.dependencies]
python = "^3.11"
django = "^4.2"
django-markdownfield = "^0.10.0"
django-model-utils = "^4.3.1"
pytest = "^7.3.1"
pytest-django = "^4.5.2"
pytest-cov = "^4.0.0"
pip is 22.3.1
allynt commented
Adding setuptools to your packages will resolve this: poetry add setuptools
Incidentally, I actually got an error rather than a warning.
But I definitely agree that all this is used for is versioning, so it should probably be removed.
foarsitter commented
Thanks for reporting this issue. Running the tests against 3.12-dev triggered the same issue. @hugovk solved it in #545 by replacing pg_resources with importlib, see #545 (comment) for details.