Metadata-Version: 2.3
Name: venver
Version: 0.3.0
Summary: Automatically activate, and deactivate virutal environments when entering or leaving directories.
Author: Narvin Singh
Author-email: Narvin Singh <Narvin.A.Singh@gmail.com>
License: Automatically activate, and deactivate virutal environments when entering or leaving directories.
         Copyright (C) 2026  Narvin Singh
         
         This program is free software: you can redistribute it and/or modify
         it under the terms of the GNU General Public License as published by
         the Free Software Foundation, either version 3 of the License, or
         (at your option) any later version.
         
         This program is distributed in the hope that it will be useful,
         but WITHOUT ANY WARRANTY; without even the implied warranty of
         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
         GNU General Public License for more details.
         
         You should have received a copy of the GNU General Public License
         along with this program.  If not, see <https://www.gnu.org/licenses/>.
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Classifier: Operating System :: OS Independent
Requires-Dist: python-docs-theme~=2025.2 ; extra == 'doc'
Requires-Dist: sphinx~=8.1 ; extra == 'doc'
Requires-Python: >=3.10
Project-URL: Homepage, https://venver.readthedocs.io
Project-URL: Documentation, https://venver.readthedocs.io
Project-URL: Repository, https://codeberg.org/venver
Project-URL: Issues, https://codeberg.org/venver/issues
Provides-Extra: doc
Description-Content-Type: text/x-rst

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.

    .. code-block:: shell

        mkdir -p "${HOME}/.local/bin/venver"
        cd "${HOME}/.local/bin/venver"
        python -m venv .venv
        pip --python ./.venv/bin/python install venver

#. Add this to the bottom of your ``.bashrc``.

    .. code-block:: shell

        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:

.. code-block::

    ~/
    ├─ myapp/
    │  ├─ .venv/
    │  │   ...
    │  ├─ src/
    │  │   ...
    │  ├─ .gitignore
    │  ├─ pyproject.toml
    │  ├─ README.rst

Add a ``.venver`` file to the project root.

.. code-block:: shell

    cd ~/myapp
    echo './.venv' > .venver

.. code-block::

    ~/
    ├─ 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.

.. code-block:: console

    ~ $ 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.

.. code-block:: console

    ~ $ 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.

.. code-block::

    ~/
    ├─ venvs/
    │  ├─ web-venv/
    │  │   ...
    │  ├─ console-venv/
    │  │   ...

.. code-block:: shell

    cd ~/myapp
    echo '~/venvs/web-venv' > .venver

.. code-block:: console

    ~ $ cd myapp
    ~/myapp (web-venv) $ cd src
    ~/myapp/src (web-venv) $ cd ~
    ~ $ cd myapp/src
    ~/myapp/src (web-venv) $
