direnv / direnv

unclutter your .profile
http://direnv.net
MIT License
12k stars 625 forks source link

Activate python venv by default? #1264

Open AwesomeDog opened 3 months ago

AwesomeDog commented 3 months ago

Is your feature request related to a problem? Please describe. sourcing .envrc files goes fine. But activating python virtualenv requires tedious work.
As far as I have searched, one has to define it in the .envrc file, or something.

Describe the solution you'd like when the directory has ./venv/bin/activate file, then activate it by default, without any configuration. and deactivate when leaves the directory.

Describe alternatives you've considered

Additional context

steinybot commented 3 months ago

Have you read https://github.com/direnv/direnv/wiki/Python?

You just need to put this in .envrc:

layout python

Then it will create the virtual environment within .direnv/python-$python_version (not ./venv like you might be used to)

brunns commented 2 months ago

And you can override the name of the virtual environment to .venv if you like:

export VIRTUAL_ENV=."venv"
layout python