[BUG] v70.0.0 removes 'packaging' from pkg_resources
dmick opened this issue · 6 comments
setuptools version
setuptools=70.0.0
Python version
3.8
OS
Ubuntu 22.04
Additional environment information
first noticed on readthedocs.org builds today
Description
from pkg_resources import packaging
fails with
ImportError: cannot import name 'packaging' from 'pkg_resources'
Expected behavior
expected the import to succeed as in v69.5.1 and prior
How to Reproduce
python3 -mvenv v
v/bin/pip install pkg_resources
v/bin/python3
from pkg_resources import packaging
Output
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'packaging' from 'pkg_resources' (/home/dmick/vsetup/lib64/python3.9/site-packages/pkg_resources/__init__.py)
This is also breaking PyTorch 2.1 (not PyTorch 2.2+). Will you consider adding it back?
(aws_neuron_venv_pytorch) ubuntu@ip-10-0-8-190:~$ python -c "from torch.utils import cpp_extension"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/ubuntu/aws_neuron_venv_pytorch/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 28, in <module>
from pkg_resources import packaging # type: ignore[attr-defined]
ImportError: cannot import name 'packaging' from 'pkg_resources' (/home/ubuntu/aws_neuron_venv_pytorch/lib/python3.8/site-packages/pkg_resources/__init__.py)
Hi @dmick , please see the explanation for the behaviour you are observing in #4376 (comment).
Tl;DR: the package you are using was relying on an internal implementation detail of pkg_resources
and that implementation detail was not part of the public API.
I recommend contacting the maintainers of that package and reporting the bug on their end. The easiest way to fix this is to install and import packaging
directly.
The API documentation for pkg_resources
can be found in https://setuptools.pypa.io/en/latest/pkg_resources.html.
You can also check which "names" are public in the package by inspecting the __all__
property.