From 6ec31e2b6a15fec6bb1eb01c96c86fbf1bd43d47 Mon Sep 17 00:00:00 2001 From: Lauri Tirkkonen Date: Wed, 16 Apr 2025 20:52:27 +0900 Subject: [PATCH] executor: propagate original error even if pkg.to_dependency() fails this fixes the following regression, introduced somewhere between 1.8.4 and 2.0.1: a git dependency which fails wheel build does not output the underlying error that caused the wheel build failure. eg. podman run -ti -w /tmp --entrypoint /bin/sh --rm python:3.13.3-alpine3.21 -c "pip install poetry && poetry new . && poetry add 'python-kadmin @ git+https://github.com/authentik-community/python-kadmin.git@v0.2.0'" the root cause is that the exception handling in _execute_operation() calls pkg.to_dependency(), which fails like: ValueError: Invalid git url "/root/.cache/pypoetry/virtualenvs/tmp-6WcazSRI-py3.13/src/python-kadmin" and the underlying build error is therefore never output. --- src/poetry/installation/executor.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/poetry/installation/executor.py b/src/poetry/installation/executor.py index 29cb1879341..92f2de5f6c5 100644 --- a/src/poetry/installation/executor.py +++ b/src/poetry/installation/executor.py @@ -1,5 +1,6 @@ from __future__ import annotations +import contextlib import csv import functools import itertools @@ -326,13 +327,17 @@ def _execute_operation(self, operation: Operation) -> None: # we disable trace here explicitly to workaround incorrect context detection by crashtest with_trace = False pip_command = "pip wheel --no-cache-dir --use-pep517" + requirement = pkg.source_url if pkg.develop: - requirement = pkg.source_url pip_command += " --editable" else: - requirement = ( - pkg.to_dependency().to_pep_508().split(";")[0].strip() - ) + with contextlib.suppress(ValueError): + requirement = ( + pkg.to_dependency() + .to_pep_508() + .split(";")[0] + .strip() + ) if config_settings := self._build_config_settings.get(pkg.name): for setting in config_settings: