diff --git a/src/poetry/installation/executor.py b/src/poetry/installation/executor.py index 474850011ab..2f5f550a619 100644 --- a/src/poetry/installation/executor.py +++ b/src/poetry/installation/executor.py @@ -33,6 +33,7 @@ from poetry.utils.helpers import remove_directory from poetry.utils.isolated_build import IsolatedBuildError from poetry.utils.isolated_build import IsolatedBuildInstallError +from poetry.vcs.git import Git if TYPE_CHECKING: @@ -46,6 +47,12 @@ from poetry.utils.env import Env +def _package_get_name(package: Package) -> str | None: + if url := package.repository_url: + return Git.get_name_from_source_url(url) + return None + + class Executor: def __init__( self, @@ -167,8 +174,9 @@ def execute(self, operations: list[Operation]) -> int: if is_parallel_unsafe: serial_operations.append(operation) elif operation.package.source_type == "git": - # Git operations on the same repository should be executed serially - serial_git_operations[operation.package.source_url].append( + # Serially execute git operations that get cloned to the same directory, + # to prevent multiple parallel git operations in the same repo. + serial_git_operations[_package_get_name(operation.package)].append( operation ) else: @@ -604,8 +612,6 @@ def _prepare_archive( ) def _prepare_git_archive(self, operation: Install | Update) -> Path: - from poetry.vcs.git import Git - package = operation.package assert package.source_url is not None diff --git a/tests/installation/test_executor.py b/tests/installation/test_executor.py index 91a3c9f30f9..d953b693b94 100644 --- a/tests/installation/test_executor.py +++ b/tests/installation/test_executor.py @@ -1133,7 +1133,6 @@ def test_executor_should_install_multiple_packages_from_same_git_repository( assert spy.call_count == 2 -@pytest.mark.xfail def test_executor_should_install_multiple_packages_from_forked_git_repository( mocker: MockerFixture, tmp_venv: VirtualEnv,