Automatically activate and deactivate Python environments as you move around the file system.
Heavily inspired by autoenv.
pyautoenv activates a
Poetry or
venv
Python environment when you cd into the directory that defines that environment
(i.e., when a directory, or any of its parents,
contains a poetry.lock file or a .venv/ directory).
Environments are automatically deactivated when you leave the directory.
Supports Python versions 3.9 and up.
Follow the installation instructions for your favourite shell.
Expand instructions
If you're using oh-my-zsh,
clone this repo into ~/.oh-my-zsh/plugins or ${ZSH_CUSTOM}/plugins.
Then add pyautoenv to the list of enabled plugins in your .zshrc:
plugins=(
pyautoenv
)If you're not using oh-my-zsh, source the pyautoenv.plugin.zsh script.
source pyautoenv.plugin.zshAdd this to your .zshrc to activate the application permanently.
Expand instructions
To enable the application in bash, source the bash script.
source <path to pyautoenv>/pyautoenv.bashAdd this to your .bashrc to activate the application permanently.
Note that this script will clobber the cd command.
It is highly recommended to use a more modern shell,
like ZSH or Fish, when using pyautoenv.
Expand instructions
To enable the application in fish-shell, source the fish script.
source <path to pyautoenv>/pyautoenv.fishAdd this to your config.fish file to activate the application permanently.
Expand instructions
To enable the application in PowerShell, dot the .ps1 file.
. <path to pyautoenv>\PyAutoEnv.ps1Add this to your profile to activate the application permanently.
There are some environment variables you can set to configure pyautoenv.
PYAUTOENV_DISABLE: Set to a non-zero value to disable all functionality.PYAUTOENV_VENV_NAME: If you name your virtualenv directories something other than.venv, you can use this to override directory names to search within. Use;as a delimiter to separate directory names. For example, if set to.venv;venv, on each directory change,pyautoenvwill look for an environment within.venv, if that directory does not exist, it will look for an environment invenv.PYAUTOENV_IGNORE_DIR: If you wish to disablepyautoenvfor a specific set of directories, you can list these directories here, separated with a;. The directories, and their children, will be treated as though no virtual environment exists for them. This means any active environment will be deactivated when changing to them.PYAUTOENV_DEBUG: Set to a non-zero value to enable logging. When active, you can also usePYAUTOENV_LOG_LEVELto set the logging level to something supported by Python'sloggingmodule. The default log level isDEBUG.
See CONTRIBUTING.md.