From 020ebe5547f0267cac16cd73f111c23269e621cb Mon Sep 17 00:00:00 2001 From: Alois Klink Date: Sat, 15 Oct 2022 07:54:57 +0100 Subject: [PATCH] fix: fix support for packaging v20.4 Poetry v1.2.2 does not work with packaging v20.4 (which is an allowed version of packaging in the pyproject.toml file). This is because the `from packaging.utils import NormalizedName` line before [packaging v20.5][1] only works if `typing.TYPE_CHECKING` is True. This is not an issue on the `master` branch, since there this import is already hidden behind an `if TYPE_CHECKING:` guard. However, the v1.2 branch never cherry-picked the appropriate commit adding this change. [1]: https://github.com/pypa/packaging/commit/eca30e0435f99084682d529d997f5c5fe1cd43fb Fixes: https://github.com/python-poetry/poetry/commit/04c5cbf043610dd5d89b7d980bf8a137948c4fa5 --- src/poetry/installation/installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/poetry/installation/installer.py b/src/poetry/installation/installer.py index 288ec2db620..7ea1fe19c3a 100644 --- a/src/poetry/installation/installer.py +++ b/src/poetry/installation/installer.py @@ -3,7 +3,6 @@ from typing import TYPE_CHECKING from cleo.io.null_io import NullIO -from packaging.utils import NormalizedName from packaging.utils import canonicalize_name from poetry.installation.executor import Executor @@ -24,6 +23,7 @@ from collections.abc import Sequence from cleo.io.io import IO + from packaging.utils import NormalizedName from poetry.core.packages.project_package import ProjectPackage from poetry.config.config import Config