poetry icon indicating copy to clipboard operation
poetry copied to clipboard

Suggestion for different naming of virtual env in non-package mode

Open Evan0000000000 opened this issue 9 months ago • 2 comments

Issue Kind

Change in current behaviour

Description

Currently with non-package-mode = false when poetry creates the virtual environment it seems like the folder name for the venv is something like: "non-package-mode-{pseudo random string}-{python version}" e.g., "non-package-mode-WCWsJ_DC-py3.11"

I'm curious if there's a technical reason for that particular string being used--obviously there's not necessarily a project name as poetry would otherwise use in pyproject.toml , but compared to e.g., using the last element of the path the project is in I could see it causing some confusion in a case like this:

  • I have several paths each using poetry in NPM to fiddle with different things
  • I activate one, prepending some variation on "non-package-mode-some_string-py3.11" to my prompt
  • I navigate away from the path the virtual env is relevant to
  • it's no longer apparent which of my couple of experimental envs are active (since they would all prepend non-package-mode-py3.11) somewhat removing the utility of modifying the prompt

Impact

I imagine this causing some amount of confusion with developers who have multiple terminals open or work on several things at once.

Workarounds

I assume the activation script could be modified manually for each virtual env should this be a pressing issue for anyone

Evan0000000000 avatar Mar 19 '25 15:03 Evan0000000000

"the last element of a path" is also not unique.

suggest naming your projects

dimbleby avatar Mar 19 '25 17:03 dimbleby

For anyone else encountering this issue, a workaround is to add a name under [tool.poetry] in pyproject.toml, as poetry does not use name from the [project] section when naming a new virtual enviornment.

eriktm avatar Jul 13 '25 18:07 eriktm