Skip to content

pip wheel not working on macOS / Python 3.10 #11053

Closed
@wimglenn

Description

@wimglenn

Description

pip fails loading the build backend (pip._vendor.pep517.wrappers.BackendUnavailable)

Expected behavior

python3 -m pip wheel . should create a myproject-0.1-py3-none-any.whl in the cwd.

pip version

22.0.4

Python version

3.10

OS

macOS Montery 12.3.1

How to Reproduce

Note: the failure is only reproducible outside of a venv. In a venv the build works 🤷

I have a minimal source tree:

$ ls                
pyproject.toml
$ cat pyproject.toml
[build-system]
requires = ["setuptools-ext"]
build-backend = "setuptools_ext"

[project]
name = "myproject"
version = "0.1"

Python 3.10 runtime from brew install python@3.10 and a clean pip installation

$ python3 -m pip --version           
pip 22.0.4 from /usr/local/lib/python3.10/site-packages/pip (python 3.10)
$ python3 -m pip freeze --all
pip==22.0.4
setuptools==62.1.0
$ python3 -m pip config list
$

But pip wheel fails:

$ python3 -m pip wheel .
Processing /private/tmp/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
ERROR: Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/pip/_internal/cli/base_command.py", line 167, in exc_logging_wrapper
    status = run_func(*args)
  File "/usr/local/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper
    return func(self, options, args)
  File "/usr/local/lib/python3.10/site-packages/pip/_internal/commands/wheel.py", line 145, in run
    requirement_set = resolver.resolve(reqs, check_supported_wheels=True)
  File "/usr/local/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 75, in resolve
    collected = self.factory.collect_root_requirements(root_reqs)
  File "/usr/local/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 506, in collect_root_requirements
    req = self._make_requirement_from_install_req(
  File "/usr/local/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 468, in _make_requirement_from_install_req
    cand = self._make_candidate_from_link(
  File "/usr/local/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 215, in _make_candidate_from_link
    self._link_candidate_cache[link] = LinkCandidate(
  File "/usr/local/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 288, in __init__
    super().__init__(
  File "/usr/local/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 158, in __init__
    self.dist = self._prepare()
  File "/usr/local/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 227, in _prepare
    dist = self._prepare_distribution()
  File "/usr/local/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 299, in _prepare_distribution
    return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
  File "/usr/local/lib/python3.10/site-packages/pip/_internal/operations/prepare.py", line 487, in prepare_linked_requirement
    return self._prepare_linked_requirement(req, parallel_builds)
  File "/usr/local/lib/python3.10/site-packages/pip/_internal/operations/prepare.py", line 556, in _prepare_linked_requirement
    dist = _get_prepared_distribution(
  File "/usr/local/lib/python3.10/site-packages/pip/_internal/operations/prepare.py", line 58, in _get_prepared_distribution
    abstract_dist.prepare_distribution_metadata(finder, build_isolation)
  File "/usr/local/lib/python3.10/site-packages/pip/_internal/distributions/sdist.py", line 45, in prepare_distribution_metadata
    self._install_build_reqs(finder)
  File "/usr/local/lib/python3.10/site-packages/pip/_internal/distributions/sdist.py", line 104, in _install_build_reqs
    build_reqs = self._get_build_requires_wheel()
  File "/usr/local/lib/python3.10/site-packages/pip/_internal/distributions/sdist.py", line 81, in _get_build_requires_wheel
    return backend.get_requires_for_build_wheel()
  File "/usr/local/lib/python3.10/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 "/usr/local/lib/python3.10/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 "/usr/local/lib/python3.10/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.10/3.10.2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'setuptools_ext'

Interestingly, the same call succeeds when done in a venv:

$ python3 -m venv .venv
$ source .venv/bin/activate
(.venv) $ python3 -m pip install -qU pip setuptools
(.venv) $ python3 -m pip freeze --all
pip==22.0.4
setuptools==62.1.0
(.venv) $ python3 -m pip --version
pip 22.0.4 from /private/tmp/s/.venv/lib/python3.10/site-packages/pip (python 3.10)
(.venv) $ python3 -m pip wheel .
Processing /private/tmp/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: myproject
  Building wheel for myproject (pyproject.toml) ... done
  Created wheel for myproject: filename=myproject-0.1-py3-none-any.whl size=965 sha256=a9471f72e821bcfbc1a8361a2a0f828c99270b1af73849f9f9b6d2af17369dda
  Stored in directory: /private/var/folders/l9/gsl6q67557s4vd8gh4pkqt2c0000gn/T/pip-ephem-wheel-cache-e0ligcse/wheels/91/4d/e6/5c1a7ca4b3201d662a4885a203f45ea99565680187670918b4
Successfully built myproject

Why is that?

Output

I've attached a file with increased verbosity enabled

PYTHONVERBOSE=1 python3 -m pip wheel -vvv . &> out.txt

--> out.txt

Note: There appears to be an assertion firing from this line, however even if I comment out that line the build fails the same way, so it might be a red herring..

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugA confirmed bug or unintended behavior

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions