Commit e97b950
fix(poetry): pep503 normalize package name (#242)
# Issue
When generating the name of the virtualenv, Poetry honors PEP 503
project name normalization [^1]. In short, the name of the project is
lowercased, and all runs of `-_.` are replaced with a single `-`.
For example, the normalized name of the following extract of
pyproject.toml is `my-project`.
```toml
[project]
name = "my_project"
```
When a project name is modified like this by Poetry, the virtualenv name
generated by this project will not match and the Poetry locator will not
pick up any Poetry virtual environments (with the exception of the
in-project `.venv`).
# PR Description
This PR ports the few lines of Python code from poetry-core [^2] that
implement the name normalization to the Poetry locator in order to fix
this unaligned behavior.
[^1]: https://peps.python.org/pep-0503/#normalized-names
[^2]:
https://github.com/python-poetry/poetry-core/blob/a2c068227358984d835c9684de723b046bdcd67a/src/poetry/core/_vendor/packaging/utils.py#L46-L51
---------
Co-authored-by: Don Jayamanne <don.jayamanne@outlook.com>1 parent d658378 commit e97b950
File tree
2 files changed
+45
-3
lines changed- crates
- pet-poetry/src
- pet-python-utils/src
2 files changed
+45
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
10 | 17 | | |
11 | 18 | | |
12 | 19 | | |
| |||
15 | 22 | | |
16 | 23 | | |
17 | 24 | | |
18 | | - | |
19 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
20 | 36 | | |
21 | 37 | | |
22 | 38 | | |
| |||
85 | 101 | | |
86 | 102 | | |
87 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
88 | 130 | | |
89 | 131 | | |
90 | 132 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| |||
0 commit comments