Open
Description
I think, this is somewhat of important information that ought to be in the output when the error is raised. It's also in a temporary directory that is cleaned up once done, making it extra difficult to get the output.
See the error in aio-libs/frozenlist#652 when trying to install frozenlist
It fails with:
ERROR: Exception:
Traceback (most recent call last):
File "/usr/lib/python3.12/site-packages/pip/_internal/cli/base_command.py", line 105, in _run_wrapper
status = _inner_run()
^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/pip/_internal/cli/base_command.py", line 96, in _inner_run
return self.run(options, args)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/pip/_internal/cli/req_command.py", line 68, in wrapper
return func(self, options, args)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/pip/_internal/commands/install.py", line 387, in run
requirement_set = resolver.resolve(
^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 77, in resolve
collected = self.factory.collect_root_requirements(root_reqs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 545, in collect_root_requirements
reqs = list(
^^^^^
File "/usr/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 501, in _make_requirements_from_install_req
cand = self._make_base_candidate_from_link(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 233, in _make_base_candidate_from_link
self._link_candidate_cache[link] = LinkCandidate(
^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 306, in __init__
super().__init__(
File "/usr/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 159, in __init__
self.dist = self._prepare()
^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 236, in _prepare
dist = self._prepare_distribution()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 317, in _prepare_distribution
return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/pip/_internal/operations/prepare.py", line 532, in prepare_linked_requirement
return self._prepare_linked_requirement(req, parallel_builds)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/pip/_internal/operations/prepare.py", line 647, in _prepare_linked_requirement
dist = _get_prepared_distribution(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/pip/_internal/operations/prepare.py", line 71, in _get_prepared_distribution
abstract_dist.prepare_distribution_metadata(
File "/usr/lib/python3.12/site-packages/pip/_internal/distributions/sdist.py", line 69, in prepare_distribution_metadata
self.req.prepare_metadata()
File "/usr/lib/python3.12/site-packages/pip/_internal/req/req_install.py", line 575, in prepare_metadata
self.metadata_directory = generate_metadata(
^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/pip/_internal/operations/build/metadata.py", line 34, in generate_metadata
distinfo_dir = backend.prepare_metadata_for_build_wheel(metadata_dir)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/pip/_internal/utils/misc.py", line 723, in prepare_metadata_for_build_wheel
return super().prepare_metadata_for_build_wheel(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_impl.py", line 224, in prepare_metadata_for_build_wheel
return self._call_hook(
^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_impl.py", line 402, in _call_hook
raise BackendUnavailable(
pip._vendor.pyproject_hooks._impl.BackendUnavailable: Cannot import 'pep517_backend.hooks'
but the error does not specify why the import of the custom build backend failed.
Upon patching pyproject-hooks to print things around https://github.com/pypa/pyproject-hooks/blob/main/src/pyproject_hooks/_impl.py#L403-L412, the actual issue is visible.
It's a missing module!
{'unsupported': False, 'return_val': None, 'no_backend': True, 'traceback': 'Traceback (most recent call last):\n File "/usr/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 70, in _build_backend\n obj = import_module(mod_path)\n ^^^^^^^^^^^^^^^^^^^^^^^\n File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module\n return _bootstrap._gcd_import(name[level:], package, level)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "<frozen importlib._bootstrap>", line 1387, in _gcd_import\n File "<frozen importlib._bootstrap>", line 1360, in _find_and_load\n File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked\n File "<frozen importlib._bootstrap>", line 935, in _load_unlocked\n File "<frozen importlib._bootstrap_external>", line 999, in exec_module\n File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed\n File "/run/build/python3-frozenlist/packaging/pep517_backend/hooks.py", line 8, in <module>\n from ._backend import ( # type: ignore[assignment]\n File "/run/build/python3-frozenlist/packaging/pep517_backend/_backend.py", line 45, in <module>\n from ._cython_configuration import get_local_cython_config as _get_local_cython_config\n File "/run/build/python3-frozenlist/packaging/pep517_backend/_cython_configuration.py", line 11, in <module>\n from expandvars import expandvars\nModuleNotFoundError: No module named \'expandvars\'\n', 'backend_error': "Cannot import 'pep517_backend.hooks'"}
something like this:
diff --git a/src/pyproject_hooks/_impl.py b/src/pyproject_hooks/_impl.py
index 14484fa..7e2c347 100644
--- a/src/pyproject_hooks/_impl.py
+++ b/src/pyproject_hooks/_impl.py
@@ -54,7 +54,10 @@ class BackendUnavailable(Exception):
self.backend_name = backend_name
self.backend_path = backend_path
- self.traceback = traceback
- super().__init__(message or "Error while importing backend")
+ self.traceback = traceback or ""
+ super().__init__(
+ f"{message or 'Error while importing backend'}"
+ + (f"\n\nTraceback:\n{self.traceback}" if self.traceback else "")
+ )
class HookMissing(Exception):
Metadata
Metadata
Assignees
Labels
No labels