Repository: DavidVujic/python-polylith

Issue:
poly check: library discovery when the name differs from the import.
**Describe the bug**
The `pyjwt` library is highlighted as missing when using the `--strict` flag with the `poly check` command.

This is because the Library name differs in three places:
the import `jwt`
the pypi package name `pyjwt`
and the installed library name `PyJWT`.

The bug in The Polylith source code: it doesn't handle casings when doing the library-name/package lookups by key (lowercase/upper-lower-case)

**Expected behavior**
The `pyjwt` library should be recognized as added to the venv.

**Additional context**
Discussion: https://github.com/DavidVujic/python-polylith/discussions/209

Discussion:
sonarcloud[bot]: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=DavidVujic_python-polylith&pullRequest=238) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=DavidVujic_python-polylith&pullRequest=238&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=DavidVujic_python-polylith&pullRequest=238&issueStatuses=ACCEPTED)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=DavidVujic_python-polylith&pullRequest=238&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=DavidVujic_python-polylith&pullRequest=238&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=DavidVujic_python-polylith&pullRequest=238&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=DavidVujic_python-polylith&pullRequest=238)



Patch:
diff --git a/components/polylith/alias/core.py b/components/polylith/alias/core.py
index 4b3c647..370291f 100644
--- a/components/polylith/alias/core.py
+++ b/components/polylith/alias/core.py
@@ -16,7 +16,9 @@ def parse(aliases: List[str]) -> Dict[str, List[str]]:
 
 
 def pick(aliases: Dict[str, List[str]], keys: Set) -> Set:
-    matrix = [v for k, v in aliases.items() if k in keys]
+    normalized_keys = {str.lower(k) for k in keys}
+
+    matrix = [v for k, v in aliases.items() if str.lower(k) in normalized_keys]
 
     flattened: List = sum(matrix, [])
 
diff --git a/projects/poetry_polylith_plugin/pyproject.toml b/projects/poetry_polylith_plugin/pyproject.toml
index c360715..e400089 100644
--- a/projects/poetry_polylith_plugin/pyproject.toml
+++ b/projects/poetry_polylith_plugin/pyproject.toml
@@ -1,6 +1,6 @@
 [tool.poetry]
 name = "poetry-polylith-plugin"
-version = "1.25.0"
+version = "1.25.1"
 description = "A Poetry plugin that adds tooling support for the Polylith Architecture"
 authors = ["David Vujic"]
 homepage = "https://davidvujic.github.io/python-polylith-docs/"
diff --git a/projects/polylith_cli/pyproject.toml b/projects/polylith_cli/pyproject.toml
index f04b87f..98e4d90 100644
--- a/projects/polylith_cli/pyproject.toml
+++ b/projects/polylith_cli/pyproject.toml
@@ -1,6 +1,6 @@
 [tool.poetry]
 name = "polylith-cli"
-version = "1.12.0"
+version = "1.12.1"
 description = "Python tooling support for the Polylith Architecture"
 authors = ['David Vujic']
 homepage = "https://davidvujic.github.io/python-polylith-docs/"


Test patch:
diff --git a/test/components/polylith/alias/test_alias.py b/test/components/polylith/alias/test_alias.py
index 1c7a7aa..e97b98e 100644
--- a/test/components/polylith/alias/test_alias.py
+++ b/test/components/polylith/alias/test_alias.py
@@ -44,6 +44,21 @@ def test_pick_aliases_by_keys():
     assert res == {"cv2", "mpl_toolkits", "matplotlib"}
 
 
+def test_pick_aliases_by_case_insensitive_keys():
+    aliases = {
+        "opencv-python": ["cv2"],
+        "PyJWT": ["jwt"],
+        "Jinja2": ["jinja2"],
+        "PyYAML": ["_yaml", "yaml"],
+    }
+
+    keys = {"one", "two", "jinja2", "pyyaml", "opencv-python", "pyjwt"}
+
+    res = alias.pick(aliases, keys)
+
+    assert res == {"cv2", "jinja2", "jwt", "_yaml", "yaml"}
+
+
 def test_pick_empty_alias_by_keys():
     aliases = {}