|
3 | 3 | from typing import TYPE_CHECKING |
4 | 4 |
|
5 | 5 | from cleo.io.null_io import NullIO |
| 6 | +from packaging.utils import NormalizedName |
6 | 7 | from packaging.utils import canonicalize_name |
7 | 8 |
|
8 | 9 | from poetry.installation.executor import Executor |
@@ -63,7 +64,7 @@ def __init__( |
63 | 64 |
|
64 | 65 | self._whitelist: list[str] = [] |
65 | 66 |
|
66 | | - self._extras: list[str] = [] |
| 67 | + self._extras: list[NormalizedName] = [] |
67 | 68 |
|
68 | 69 | if executor is None: |
69 | 70 | executor = Executor( |
@@ -175,7 +176,7 @@ def whitelist(self, packages: Iterable[str]) -> Installer: |
175 | 176 | return self |
176 | 177 |
|
177 | 178 | def extras(self, extras: list[str]) -> Installer: |
178 | | - self._extras = extras |
| 179 | + self._extras = [canonicalize_name(extra) for extra in extras] |
179 | 180 |
|
180 | 181 | return self |
181 | 182 |
|
@@ -259,8 +260,12 @@ def _do_install(self) -> int: |
259 | 260 | "</warning>" |
260 | 261 | ) |
261 | 262 |
|
| 263 | + locker_extras = { |
| 264 | + canonicalize_name(extra) |
| 265 | + for extra in self._locker.lock_data.get("extras", {}) |
| 266 | + } |
262 | 267 | for extra in self._extras: |
263 | | - if extra not in self._locker.lock_data.get("extras", {}): |
| 268 | + if extra not in locker_extras: |
264 | 269 | raise ValueError(f"Extra [{extra}] is not specified.") |
265 | 270 |
|
266 | 271 | # If we are installing from lock |
@@ -547,11 +552,17 @@ def _get_extra_packages(self, repo: Repository) -> list[str]: |
547 | 552 |
|
548 | 553 | Maybe we just let the solver handle it? |
549 | 554 | """ |
550 | | - extras: dict[str, list[str]] |
| 555 | + extras: dict[NormalizedName, list[NormalizedName]] |
551 | 556 | if self._update: |
552 | 557 | extras = {k: [d.name for d in v] for k, v in self._package.extras.items()} |
553 | 558 | else: |
554 | | - extras = self._locker.lock_data.get("extras", {}) |
| 559 | + raw_extras = self._locker.lock_data.get("extras", {}) |
| 560 | + extras = { |
| 561 | + canonicalize_name(extra): [ |
| 562 | + canonicalize_name(dependency) for dependency in dependencies |
| 563 | + ] |
| 564 | + for extra, dependencies in raw_extras.items() |
| 565 | + } |
555 | 566 |
|
556 | 567 | return list(get_extra_package_names(repo.packages, extras, self._extras)) |
557 | 568 |
|
|
0 commit comments