question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[virtualenvs] configuration not working with pyproject.toml

See original GitHub issue
  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: Linux 5.8.9-arch2-1 x86_64
  • Poetry version: 1.0.10
  • Link of a Gist with the contents of your pyproject.toml file: 👇
[tool.poetry]
name = "name"
version = "0.1.0"
description = "description"
authors = ["my-name my-name@mail.com"]
license = "BSD-3-Clause"

[tool.poetry.dependencies]
python = "^3.8"

[tool.poetry.dev-dependencies]
pre-commit = "^2.7.1"
pylint = "^2.6.0"
pytest = "^6.0.2"
pytest-cov = "^2.10.1"

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

[virtualenvs]
create = true
in-project = true

Issue

Hello, I’ve been trying to make Poetry create the virtual environment folder in the project’s root but it kept installing in home/leleco/.cache/pypoetry/virtualenvs despite the configuration set in pyproject.toml file.

After a few tries, I ran poetry config --list and the output was this 👇

cache-dir = "/home/leleco/.cache/pypoetry"
virtualenvs.create = true
virtualenvs.in-project = false
virtualenvs.path = "{cache-dir}/virtualenvs"  # /home/leleco/.cache/pypoetry/virtualenvs

This got me startled, so I tried poetry config virtualenvs.in-project true, then poetry install and it worked: a .venv was created inside my project’s root directory. I then tried the same, except that with virtualenvs.create 👇

# pyproject.toml

[virtualenvs]
create = false
in-project = true

And the result from poetry config --list was this 👇

cache-dir = "/home/leleco/.cache/pypoetry"
virtualenvs.create = true
virtualenvs.in-project = true
virtualenvs.path = "{cache-dir}/virtualenvs"  # /home/leleco/.cache/pypoetry/virtualenvs

With this, I concluded that [virtualenvs] does not work with pyproject.toml (which was expected to me, as a user). Furthermore, poetry config virtualenvs.in-project true --local creates a poetry.toml instead of adding an entry in pyproject.toml. 👇

# poetry.toml

[virtualenvs]
in-project = true

Is this expected? If so, I couldn’t find the documentation explaining this… also, is there a chance that we convert this issue from Bug to Feature Request in case the described behavior is the expected behavior? I’m more than glad to update this description and convert it to a feature request with proper use-case description.

Thanks in advance, Hope I can be useful to resolve this, or to implement this feature, somehow 🥳

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:16
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

20reactions
lcbmcommented, Sep 21, 2020

I see your point and partially agree with the argument. Nevertheless, I believe there’s at least one action item for this issue: better document poetry.toml. I read through the docs for a while and found nothing on this issue (pyproject.toml vs poetry.toml). Not even on stackoverflow I found much about it (the most I got was someone mentioning poetry.toml existed, but it was such an old post that I simply thought it was a deprecated Poetry configuration file).

For me, this is really a pain because VS Code doesn’t work with the default poetry venv dir (there are issues open on this) and VS Code users HAVE to change venv’s directory in order to use poetry venv. In order to avoid that my team has problems with poetry and VS Code, I looked for a way to enforce poetry to install venv in the project’s root everytime (that way, VS Code would always find the venv folder). This being said, I can see that lots of developers will spend considerable time looking for an appropriate solution for their professional projects and not finding proper documentation and relying on trial and error or workarounds. I believe this justifies adding some documentation on poetry.toml and it’s usage, what configs could go there and so on.

Lastly, an opinion on the separation of files: we have black, isort and many other tool configurations under pyproject.toml -> [tools.<tool-name>]. I don’t see why we can’t have a project setting (where to install venv, for this specific project) in the same file (pyproject.toml) under different keys in order to avoid increasing the number of files. 🤔

See this example of a all-in-one configuration file (there are many other examples).

Just to be clear, I really appreciate your help and opinion… this is a IMO response only, based on bad UX regarding the documentation (not Poetry itself, which is so awesome that I’m trying to change my peers mind to use it in our project) 😄

13reactions
Secruscommented, Jun 19, 2022

poetry.toml is now mentioned in the documentation. There is no plan on adding poetry settings control to pyproject.toml file.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setting settings.virtualenvs.in-project does not exist
So just type poetry config virtualenvs.in-project true . Concerning the subprocess warning: This seems to be just a warning and has no influence ......
Read more >
Configuration | Documentation | Poetry - Python dependency ...
Create the virtualenv inside the project's root directory. If not set explicitly, poetry by default will create virtual environment under {cache-dir}/ ...
Read more >
Configuration - tox
Skip installation of the package. This can be used when you need the virtualenv management but do not want to install the current...
Read more >
Dependency Management With Python Poetry
You'll be prepared to work with pyproject.toml files, ... management issues with tools like Pip, PyPI, Virtualenv, and requirements files.
Read more >
Configure a Poetry environment | PyCharm Documentation
Configure a Poetry environment ... Project dependencies are recorded in the pyproject.toml file that ... Do that by running the following command:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found