Skip to content

Option to create virtual environments in the project root (.venv) #108

@jacebrowning

Description

@jacebrowning

I'm considering migrating some of my projects from pipenv to poetry. I would like to be able to tell poetry to create virtual environments at ./.venv/ to support Makefile target dependencies, CI build caching, and automatic IDE support.

I added a feature to pipenv to detect and use virtual environments located at ./.venv/ based on the mere presence of a directory of that name. It looks like poetry nearly has the same behavior:

https://github.com/sdispater/poetry/blob/87c4aaf9cadbbb6c5657101d715b5a4e1a8d9a05/poetry/utils/venv.py#L55-L59

but I noticed that if .venv is an empty directory (in order to let the tool populate it) poetry seems to install dependencies into my global Python instead.

Would you consider a PR to add another case to this logic to create virtual environments in the root of a project? This should allow poetry to handle all of the following scenarios:

  • Use the currently activated virtual environment ($VIRTUAL_ENV set)
  • Use the exiting local virtual environment (./.venv/<bin>/python exists)
  • [NEW] Create a new local virtual environment (./.venv/ is empty)
  • Use the previously cached virtual environment
  • Create a new cached virtual environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/configRelated to configuration managementkind/featureFeature requests/implementations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions