setuptools 60: "No module named 'setuptools'" when installing Poetry from source
See original GitHub issuesetuptools version
60.0.0
Python version
3.9.6
OS
macOS 11.5.2
Additional environment information
No response
Description
Installing a package which uses a Poetry backend from source fails on 60.0.0. Poetry packages that I’ve tried (my own, as well as Poetry itself) fail to install. Package installs are successful after reverting to previous setuptools versions.
The changelog states that v60.0.0 introduces a breaking change:
pypa/setuptools#2896: Setuptools once again makes its local copy of distutils the default. To override, set SETUPTOOLS_USE_DISTUTILS=stdlib.
When using the environment variable as suggested, the package installs are again successful.
I tried a few flit and setuptools projects and observed no issues with those.
Expected behavior
The package should install without error.
How to Reproduce
Poetry itself uses poetry as a build tool, so installing poetry from source fails.
pip install --upgrade pip setuptools==60.0.0
unset SETUPTOOLS_USE_DISTUTILS
pip install git+ssh://git@github.com/python-poetry/poetry
Alternatively, clone poetry and run pip install .
locally inside the repo.
Output
pip install git+ssh://git@github.com/python-poetry/poetry
pip install git+ssh://git@github.com/python-poetry/poetry
Collecting git+ssh://****@github.com/python-poetry/poetry
Cloning ssh://****@github.com/python-poetry/poetry to /private/var/folders/k6/2dzjkwsd1mj8m52xz1b2swym0000gp/T/pip-req-build-oq1rbxm7
Running command git clone --filter=blob:none -q 'ssh://****@github.com/python-poetry/poetry' /private/var/folders/k6/2dzjkwsd1mj8m52xz1b2swym0000gp/T/pip-req-build-oq1rbxm7
Resolved ssh://****@github.com/python-poetry/poetry to commit 6a35cc41e950d4ff0f1efad649c1d15d689a9ce2
Installing build dependencies ... done
Getting requirements to build wheel ... done
ERROR: Exception:
Traceback (most recent call last):
File "/Users/alkasm/prog/setuptools-60.0.0-install-error/venv/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 164, in exc_logging_wrapper
status = run_func(*args)
File "/Users/alkasm/prog/setuptools-60.0.0-install-error/venv/lib/python3.9/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper
return func(self, options, args)
File "/Users/alkasm/prog/setuptools-60.0.0-install-error/venv/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 338, in run
requirement_set = resolver.resolve(
File "/Users/alkasm/prog/setuptools-60.0.0-install-error/venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 73, in resolve
collected = self.factory.collect_root_requirements(root_reqs)
File "/Users/alkasm/prog/setuptools-60.0.0-install-error/venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 468, in collect_root_requirements
req = self._make_requirement_from_install_req(
File "/Users/alkasm/prog/setuptools-60.0.0-install-error/venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 430, in _make_requirement_from_install_req
cand = self._make_candidate_from_link(
File "/Users/alkasm/prog/setuptools-60.0.0-install-error/venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 201, in _make_candidate_from_link
self._link_candidate_cache[link] = LinkCandidate(
File "/Users/alkasm/prog/setuptools-60.0.0-install-error/venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 281, in __init__
super().__init__(
File "/Users/alkasm/prog/setuptools-60.0.0-install-error/venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 156, in __init__
self.dist = self._prepare()
File "/Users/alkasm/prog/setuptools-60.0.0-install-error/venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 225, in _prepare
dist = self._prepare_distribution()
File "/Users/alkasm/prog/setuptools-60.0.0-install-error/venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 292, in _prepare_distribution
return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
File "/Users/alkasm/prog/setuptools-60.0.0-install-error/venv/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 482, in prepare_linked_requirement
return self._prepare_linked_requirement(req, parallel_builds)
File "/Users/alkasm/prog/setuptools-60.0.0-install-error/venv/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 546, in _prepare_linked_requirement
dist = _get_prepared_distribution(
File "/Users/alkasm/prog/setuptools-60.0.0-install-error/venv/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 58, in _get_prepared_distribution
abstract_dist.prepare_distribution_metadata(finder, build_isolation)
File "/Users/alkasm/prog/setuptools-60.0.0-install-error/venv/lib/python3.9/site-packages/pip/_internal/distributions/sdist.py", line 47, in prepare_distribution_metadata
self._install_build_reqs(finder)
File "/Users/alkasm/prog/setuptools-60.0.0-install-error/venv/lib/python3.9/site-packages/pip/_internal/distributions/sdist.py", line 106, in _install_build_reqs
build_reqs = self._get_build_requires_wheel()
File "/Users/alkasm/prog/setuptools-60.0.0-install-error/venv/lib/python3.9/site-packages/pip/_internal/distributions/sdist.py", line 83, in _get_build_requires_wheel
return backend.get_requires_for_build_wheel()
File "/Users/alkasm/prog/setuptools-60.0.0-install-error/venv/lib/python3.9/site-packages/pip/_vendor/pep517/wrappers.py", line 172, in get_requires_for_build_wheel
return self._call_hook('get_requires_for_build_wheel', {
File "/Users/alkasm/prog/setuptools-60.0.0-install-error/venv/lib/python3.9/site-packages/pip/_vendor/pep517/wrappers.py", line 332, in _call_hook
raise BackendUnavailable(data.get('traceback', ''))
pip._vendor.pep517.wrappers.BackendUnavailable: Traceback (most recent call last):
File "/Users/alkasm/prog/setuptools-60.0.0-install-error/venv/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 89, in _build_backend
obj = import_module(mod_path)
File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/private/var/folders/k6/2dzjkwsd1mj8m52xz1b2swym0000gp/T/pip-build-env-hp7wsna4/overlay/lib/python3.9/site-packages/poetry/core/masonry/__init__.py", line 10, in <module>
from .builder import Builder
File "/private/var/folders/k6/2dzjkwsd1mj8m52xz1b2swym0000gp/T/pip-build-env-hp7wsna4/overlay/lib/python3.9/site-packages/poetry/core/masonry/builder.py", line 7, in <module>
from .builders.sdist import SdistBuilder
File "/private/var/folders/k6/2dzjkwsd1mj8m52xz1b2swym0000gp/T/pip-build-env-hp7wsna4/overlay/lib/python3.9/site-packages/poetry/core/masonry/builders/__init__.py", line 2, in <module>
from .wheel import WheelBuilder
File "/private/var/folders/k6/2dzjkwsd1mj8m52xz1b2swym0000gp/T/pip-build-env-hp7wsna4/overlay/lib/python3.9/site-packages/poetry/core/masonry/builders/wheel.py", line 23, in <module>
from packaging.tags import sys_tags
File "/private/var/folders/k6/2dzjkwsd1mj8m52xz1b2swym0000gp/T/pip-build-env-hp7wsna4/overlay/lib/python3.9/site-packages/poetry/core/_vendor/packaging/tags.py", line 7, in <module>
import distutils.util
File "/Users/alkasm/prog/setuptools-60.0.0-install-error/venv/lib/python3.9/site-packages/_distutils_hack/__init__.py", line 92, in create_module
return importlib.import_module('setuptools._distutils')
File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'setuptools'
Code of Conduct
- I agree to follow the PSF Code of Conduct
Issue Analytics
- State:
- Created 2 years ago
- Reactions:12
- Comments:24 (16 by maintainers)
Top GitHub Comments
Released as 60.1.1. Please test and let me know if there are outstanding issues.
Thanks for the report. In this case, I’d like someone from the poetry project to help triage and ascertain what’s going wrong in Setuptools that’s triggering issues in poetry. I can likely help debug after I deal with another emergent issue on Ubuntu.