question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

build with setup.py errors with 60.9.1 [BUG]

See original GitHub issue

setuptools version

setuptools==60.9.1

Python version

Python 3.7.6

OS

Linux

Additional environment information

This was encountered on TravisCI using the pypi deployment provider, happens with multiple linux versions from precise to xenial. Not tested on Linux outside of Travis. Cannot reproduce it on MacOS.

Description

Running python setup.py sdist bdist_wheel errors with newest version of setuptools errors. Fixed by using version previous to 60.9.

This might be related to #3113 as the error occurs at setuptools/_vendor/importlib_metadata/__init__.py

Expected behavior

dist/* to be built without errors

How to Reproduce

  1. Have a python package using setup.py calling setup()
  2. Have TravisCI build distributions during it’s deploy step
deploy:
  provider: pypi
  distributions: "sdist bdist_wheel"
  username: ${PYPI_USERNAME}
  password: ${PYPI_PASSWORD}

that boils down to the following commands that can be reproduced

script:
  # mimic travis deploy steps concerning build during deployment step
  # https://github.com/travis-ci/dpl/blob/v1.10.16/lib/dpl/provider/pypi.rb
  # https://github.com/travis-ci/dpl/blob/b577682ac17ff10b7f3fe58c5da1113b05e68cb7/lib/dpl/provider.rb#L187
  - |
    if [ -z ${VIRTUAL_ENV+x} ]; then export PIP_USER=yes; fi && \
    wget -nv -O - https://bootstrap.pypa.io/get-pip.py | python - --no-setuptools --no-wheel && \
    pip install --upgrade --upgrade-strategy eager setuptools twine wheel
  - python setup.py sdist bdist_wheel

This can be fixed by reverting to version previous to 60.9. For example on travis they provide a parameter:

deploy:
  provider: pypi
  distributions: "sdist bdist_wheel"
  username: ${PYPI_USERNAME}
  password: ${PYPI_PASSWORD}
  setuptools_version: "60.8.2"

Output

Deploying application
Traceback (most recent call last):
  File "setup.py", line 8, in <module>
    setup()
  File "/home/travis/virtualenv/python3.7.6/lib/python3.7/site-packages/setuptools/__init__.py", line 155, in setup
    return distutils.core.setup(**attrs)
  File "/home/travis/virtualenv/python3.7.6/lib/python3.7/site-packages/setuptools/_distutils/core.py", line 109, in setup
    _setup_distribution = dist = klass(attrs)
  File "/home/travis/virtualenv/python3.7.6/lib/python3.7/site-packages/setuptools/dist.py", line 462, in __init__
    for k, v in attrs.items()
  File "/home/travis/virtualenv/python3.7.6/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 293, in __init__
    self.finalize_options()
  File "/home/travis/virtualenv/python3.7.6/lib/python3.7/site-packages/setuptools/dist.py", line 850, in finalize_options
    for ep in sorted(loaded, key=by_order):
  File "/home/travis/virtualenv/python3.7.6/lib/python3.7/site-packages/setuptools/dist.py", line 849, in <lambda>
    loaded = map(lambda e: e.load(), filtered)
  File "/home/travis/virtualenv/python3.7.6/lib/python3.7/site-packages/setuptools/_vendor/importlib_metadata/__init__.py", line 196, in load
    return functools.reduce(getattr, attrs, module)
AttributeError: type object 'Distribution' has no attribute '_finalize_feature_opts'

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:12
  • Comments:17 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
jaracocommented, Jun 12, 2022

is this something we can expect to go away with future versions independent of travis fixing the virtual environment? Or is this not something you plan to accommodate for?

I’m not confident there’s anything Setuptools could do here, and until we have a repro that can be used to locally investigate, we’re kinda stuck. Besides some of the workarounds described above, there may be other options, such as writing a routine to clear out manually old versions of setuptools before running build tools.

If we could identify something that could be patched in the current or perhaps a past version of Setuptools that would hepl the situation, I’d consider it, but at this point I’ve no options to consider.

2reactions
mriedemcommented, Jun 3, 2022

Quick follow up on this, I found that building in Travis CI with python 3.9 works around this problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

setuptools 8.2.1 - PyPI
Easily download, build, install, upgrade, and uninstall Python packages.
Read more >
Docker image build error (python setup.py error)
I have a problem building a docker image for my python server. when running: docker image build -t server:latest . I get the...
Read more >
pip is giving an error because it can't find a matching ... - Reddit
It's trying to install setuptools>=43.0.0, when 51.0.0 is already installed. It's trying to install this after running pip install .
Read more >
python setup.py egg_info did not run successfully. - You.com ...
preparing metadata (setup.py) ... error error: ... Get it with "Microsoft C++ Build Tools"", but I have already installed Microsoft Visual C++ according...
Read more >
Build "can not execute setup.py since setuptools is not available"
│ exit code: 1 ╰─> [1 lines of output] ERROR: Can not execute `setup.py` since setuptools is not available in the build environment....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found