Skip to content

fix(poetry): pep503 normalize package name - #242

Merged
Don Jayamanne (DonJayamanne) merged 5 commits into
microsoft:mainfrom
VictorColomb:fix(poetry)/PEP503-normalize-package-name
Oct 9, 2025
Merged

Don Jayamanne (DonJayamanne) merged 5 commits into
microsoft:mainfrom
VictorColomb:fix(poetry)/PEP503-normalize-package-name

Conversation

@VictorColomb

Copy link
Copy Markdown
Contributor

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.

[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.

Footnotes

  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 ↩

@VictorColomb

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@VictorColomb

Copy link
Copy Markdown
Contributor Author

Hi there Don Jayamanne (@DonJayamanne)! Any chance you can look at this?

@vs-code-engineering vs-code-engineering Bot added this to the October 2025 milestone Oct 8, 2025

@Tyriar Daniel Imms (Tyriar) left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Red CI

@DonJayamanne
Don Jayamanne (DonJayamanne) merged commit e97b950 into microsoft:main Oct 9, 2025
36 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants