-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[BUG] AttributeError: 'str' object has no attribute 'name'
with setuptools 60.9.1+
#3293
Comments
With PR #3296 we would have the following: > docker run --rm -it python:3.9.12 bash
mkdir -p testcase/mypackage && touch testcase/mypackage/__init__.py
echo 'from setuptools import setup; setup(name="mypackage", version="0.0.1", packages=["mypackage"])' > testcase/setup.py
pip install 'setuptools @ git+https://github.com/abravalheri/setuptools@issue-3292'
pip install importlib-metadata==0.20
pip install ./testcase Processing /testcase
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [25 lines of output]
/usr/local/lib/python3.9/site-packages/setuptools/_importlib.py:23: UserWarning: `importlib-metadata` version is incompatible with `setuptools`.
This problem is likely to be solved by installing an updated version of `importlib-metadata`.
warnings.warn(msg) # Ensure a descriptive message is shown.
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 14, in <module>
File "/usr/local/lib/python3.9/site-packages/setuptools/__init__.py", line 18, in <module>
from setuptools.dist import Distribution
File "/usr/local/lib/python3.9/site-packages/setuptools/dist.py", line 35, in <module>
from ._importlib import metadata
File "/usr/local/lib/python3.9/site-packages/setuptools/_importlib.py", line 39, in <module>
disable_importlib_metadata_finder(metadata)
File "/usr/local/lib/python3.9/site-packages/setuptools/_importlib.py", line 12, in disable_importlib_metadata_finder
import importlib_metadata
File "/usr/local/lib/python3.9/site-packages/importlib_metadata/__init__.py", line 490, in <module>
__version__ = version(__name__)
File "/usr/local/lib/python3.9/site-packages/importlib_metadata/__init__.py", line 457, in version
return distribution(package).version
File "/usr/local/lib/python3.9/site-packages/importlib_metadata/__init__.py", line 430, in distribution
return Distribution.from_name(package)
File "/usr/local/lib/python3.9/site-packages/importlib_metadata/__init__.py", line 179, in from_name
dists = resolver(name)
File "/usr/local/lib/python3.9/site-packages/setuptools/_vendor/importlib_metadata/__init__.py", line 886, in find_distributions
found = self._search_paths(context.name, context.path)
AttributeError: 'str' object has no attribute 'name'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output. This solution is also not ideal, but the users would at least be able to see a message in the traceback advising to update |
* Downgrading the setuptools issue as a [bug](pypa/setuptools#3293) exist - BOA-99
This is currently blocking TensorFlow releases. |
Hi @mihaimaruseac, I can merge #3296 soon if that helps, however that solution will improve the error message and point out to the user how they can solve the problem (i.e. update Does that improve your workflow? |
Thank you for the hint. We'll try upgrading |
Another attempt at fixing pypa/setuptools#3293
Newer versions have at least one bug under old Python, as per pypa/setuptools#3293
setuptools version
setuptools==62.1.0
(however the earliest affected version issetuptools==60.9.1
)Python version
Python 3.9 (though 3.7 and 3.8 are also affected)
OS
Docker image
python:3.9.12
which is Debian 11 (it also occurs on Ubuntu on Heroku)Additional environment information
Description
Between setuptools 60.9.0 and 60.9.1, a previously working project now encounters an error during the
python setup.py egg_info
phase ofpip install
:The changes between those two setuptools versions are:
v60.9.0...v60.9.1
In addition to the workaround of downgrading setuptools to
60.9.0
, I also found that making any of the following changes prevents the error from occurring:It looks like the two copies of
importlib-metadata
(the older one in the environment, and the newer one vendored in setuptools) are inadvertently interacting.I'm presuming the root cause of this and #3292 are similar/the same, however filing separately in case they are not (particularly given one is build-time, the other run-time etc).
Expected behavior
Either:
python setup.py egg_info
phase ofpip install
succeeds with newer versions of setuptools, as it did before.importlib-metadata
versions.How to Reproduce
docker run --rm -it python:3.9.12 bash
mkdir -p testcase/mypackage && touch testcase/mypackage/__init__.py
echo 'from setuptools import setup; setup(name="mypackage", version="0.0.1", packages=["mypackage"])' > testcase/setup.py
pip install setuptools==62.1.0
pip install importlib-metadata==0.20
pip install ./testcase
Output
The text was updated successfully, but these errors were encountered: