Automatically activate, and deactivate virutal environments when entering or leaving directories.
Project description
Venver
Automatically activate, and deactivate virutal environments when entering or leaving directories.
Installation
bash
Install the venver package. This can be in a virtual environment.
mkdir -p "${HOME}/.local/bin/venver" cd "${HOME}/.local/bin/venver" python -m venv .venv pip --python ./.venv/bin/python install venverAdd this to the bottom of your .bashrc.
venver() { eval "$("${HOME}/.local/bin/venver/.venv/bin/venver")" } PROMPT_COMMAND="venver;${PROMPT_COMMAND}"
Usage
Let’s assume you have a python project with a virtual environment like this:
~/
├─ myapp/
│ ├─ .venv/
│ │ ...
│ ├─ src/
│ │ ...
│ ├─ .gitignore
│ ├─ pyproject.toml
│ ├─ README.rst
Add a .venver file to the project root.
cd ~/myapp
echo './.venv' > .venver
~/
├─ myapp/
│ ├─ .venv/
│ │ ...
│ ├─ src/
│ │ ...
│ ├─ .gitignore
│ ├─ .venver
│ ├─ pyproject.toml
│ ├─ README.rst
Navigating anywhere inside the myapp directory will result in the environment at myapp/.venv being activated. And navigating outside of myapp will deactivate the environment.
~ $ cd myapp
~/myapp (.venv) $ cd src
~/myapp/src (.venv) $ cd ~
~ $ cd myapp/src
~/myapp/src (.venv) $
If you manually deactivate the environment, it won’t be automatically activated again until you navigate outside of myapp, then reenter it.
~ $ cd myapp
~/myapp (.venv) $ deactivate
~/myapp $ cd src
~/myapp/src $ cd ~
~ $ cd myapp
~/myapp (.venv) $
You may specify an environment that isn’t in the project directory. This is useful if you have environments you want to reuse. The activation, and deactivation will still be relative to the .venver directory, and not the environment directory.
~/
├─ venvs/
│ ├─ web-venv/
│ │ ...
│ ├─ console-venv/
│ │ ...
cd ~/myapp
echo '~/venvs/web-venv' > .venver
~ $ cd myapp
~/myapp (web-venv) $ cd src
~/myapp/src (web-venv) $ cd ~
~ $ cd myapp/src
~/myapp/src (web-venv) $
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file venver-0.1.0.tar.gz.
File metadata
- Download URL: venver-0.1.0.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12a96d49778f40d501a7bb066f80690a5c57c5f7a143a2e50db364127f15c462
|
|
| MD5 |
15353f805b218abbd4f5cd636ffc5547
|
|
| BLAKE2b-256 |
1c191d50d365f8115dec79be41d26eed6f0e5086c88be8f3374affe1e9d21983
|
File details
Details for the file venver-0.1.0-py3-none-any.whl.
File metadata
- Download URL: venver-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85472d8f0841f71be6893ea9f1d0f85de101c80b82132a0a303fa362d9dee2be
|
|
| MD5 |
ae1b114e348557bbbaced64c9e48be93
|
|
| BLAKE2b-256 |
cfcba22732ea9e541c79fd36c78dc1c506eac854757cea10c5632a8c94ef6e03
|