poetry icon indicating copy to clipboard operation
poetry copied to clipboard

Custom Virtual Env Name Not used

Open jainal09 opened this issue 2 years ago • 4 comments

  • Poetry version: Poetry (version 1.5.1
  • Python version:
  • OS version and name: macOS 13.4
  • pyproject.toml: pyproject.toml
  • [X] I am on the latest stable Poetry version, installed using a recommended method.
  • [X] I have searched the issues of this repo and believe that this is not a duplicate.
  • [X] I have consulted the FAQ and blog for any relevant entries or release notes.
  • [X] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

I have the following poetry.toml

[virtualenvs]
name = "evenv"
create = true
in-project = true

This is the output of ❯ poetry config --list

cache-dir = "/Users/jainal/Library/Caches/pypoetry"
experimental.system-git-client = false
installer.max-workers = null
installer.modern-installation = true
installer.no-binary = null
installer.parallel = true
virtualenvs.create = true
virtualenvs.in-project = true
virtualenvs.name = "evenv"
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.no-setuptools = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}/virtualenvs"  # /Users/jainal/Library/Caches/pypoetry/virtualenvs
virtualenvs.prefer-active-python = false
virtualenvs.prompt = "{project_name}-py{python_version}"

The is issue is irrespective of this config, poetry still creates the virtualenv with the name .venv . When it should create virtualenv evenv

Also, one weird thing is when I execute this command poetry config virtualenvs.name evenv --local I am getting this error Setting virtualenvs.name does not exist

even if virtualenvs.name = "evenv" is in the config list above

jainal09 avatar Jun 08 '23 23:06 jainal09

This is a bug in config listing via CLI. There is no option virtualenv.name. It's listed in the output of poetry config --list only because you put it in poetry.toml manually.

Secrus avatar Jun 08 '23 23:06 Secrus

So, is there a way to set the name of the virtualenv that poetry creates ?

jainal09 avatar Jun 09 '23 01:06 jainal09

No. You can manually create your virtualenv, under any name you like, and activate it, poetry will use that virtual environment then.

clintonroy avatar Jun 09 '23 04:06 clintonroy

Oh, I see. What I wanted to ask is, what about the bug in which poetry config --list list all the key value pairs under the

[[virtualenvs]

for example

[virtualenvs]
name = "evenv"
create = true
in-project = true
xyz="a"

then the output of the poetry config --list

❯ poetry config  --list
virtualenvs.create = true
virtualenvs.in-project = true
virtualenvs.name = "evenv"
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.no-setuptools = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}/virtualenvs"  # /Users/***/Library/Caches/pypoetry/virtualenvs
virtualenvs.prefer-active-python = false
virtualenvs.prompt = "{project_name}-py{python_version}"
virtualenvs.xyz = "a"

Does it needs to be fixed or is it some sort of intended behavior ?

jainal09 avatar Jun 09 '23 14:06 jainal09