Skip to content

Conversation

VictorColomb
Copy link

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
Author

@microsoft-github-policy-service agree

@DonJayamanne DonJayamanne self-requested a review August 21, 2025 11:10
@DonJayamanne DonJayamanne self-assigned this Aug 21, 2025
@VictorColomb
Copy link
Author

Hi there @DonJayamanne! Any chance you can look at this?

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.

2 participants