Skip to main content

Auto-tracks pip installs/uninstalls in requirements.txt — like package.json for Python

Project description

venvy 🐍

Auto-tracks pip install and pip uninstall in requirements.txt — like package.json for Python.

Once set up, you just use pip normally. venvy silently keeps your requirements.txt in sync automatically.


How it works

venvy injects a small hook (venvy_hook.py) into your venv's site-packages. This hook patches pip's internal InstallCommand.run and UninstallCommand.run — so every successful pip install or pip uninstall automatically updates requirements.txt. No wrappers, no aliases, no shell setup.


Installation

pip install venvy        # global install recommended
# or
pipx install venvy

Quick start

1. Create a venv (hook included automatically)

cd my-project
venvy create venv

Asks two questions:

  [1/2] Install ipykernel? [y/N]: n
  [2/2] Requirements file name [requirements.txt]:

Then: creates .venv/, upgrades pip, injects the tracking hook.

2. Activate your venv normally

# Windows CMD
.venv\Scripts\activate.bat

# Windows PowerShell
.venv\Scripts\Activate.ps1

# macOS / Linux
source .venv/bin/activate

3. Just use pip — requirements.txt updates automatically

pip install flask
# Output:
# Successfully installed flask-3.1.3 ...
# [venvy] + flask==3.1.3 → requirements.txt   ← automatic!

pip install requests httpx
# [venvy] + requests==2.31.0 → requirements.txt
# [venvy] + httpx==0.27.0 → requirements.txt

pip uninstall flask -y
# Successfully uninstalled flask-3.1.3
# [venvy] - flask → requirements.txt   ← automatic!

No extra commands. No wrappers. Just pip.


Using an existing venv

If you already have a venv (not created by venvy):

source .venv/bin/activate      # activate it first (or don't — venvy finds it)
venvy install-hook             # inject the tracking hook

Or specify the path:

venvy install-hook .venv
venvy install-hook my_env

All commands

venvy create venv              Create venv + inject pip hook
  --name -n      Venv directory name (default: .venv)
  --requirements -r  Requirements file name (prompted)
  --ipykernel    Install ipykernel for Jupyter
  --yes -y       Skip all prompts

venvy install-hook [path]      Inject hook into existing venv

venvy pip install <pkg>        Install + update requirements (manual fallback)
  --upgrade -U
venvy pip uninstall <pkg>      Uninstall + update requirements (manual fallback)
  --yes -y

venvy status                   Show venv info + hook status + requirements
venvy list                     List packages in requirements.txt
venvy sync                     Install all packages from requirements.txt

venvy --version

Project structure

my-project/
├── .venv/
│   └── lib/pythonX.Y/site-packages/
│       ├── venvy_hook.py     ← the hook (auto-injected)
│       └── venvy_hook.pth    ← loads hook on every Python start
├── .venvy/
│   └── config.json           ← venvy project config
├── requirements.txt          ← auto-managed ✓
└── your_code.py

.venvy/config.json:

{
  "venv_name": ".venv",
  "requirements_file": "requirements.txt",
  "install_ipykernel": false
}

Restoring a project

git clone https://github.com/user/project
cd project
venvy create venv    # installs from existing requirements.txt automatically
# OR
python -m venv .venv
source .venv/bin/activate
venvy install-hook
venvy sync

Comparison with npm

npm venvy
npm init venvy create venv
npm install pkg pip install pkg (auto-tracked after venvy setup)
npm uninstall pkg pip uninstall pkg (auto-tracked)
npm install venvy sync
package.json requirements.txt
node_modules/ .venv/

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vvenv-0.1.2.tar.gz (28.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vvenv-0.1.2-py3-none-any.whl (37.4 kB view details)

Uploaded Python 3

File details

Details for the file vvenv-0.1.2.tar.gz.

File metadata

  • Download URL: vvenv-0.1.2.tar.gz
  • Upload date:
  • Size: 28.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.6

File hashes

Hashes for vvenv-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4bd45f1d9b002bf7cd1691cf9a7b3919254921f91848d734ed39f75aafdfb06b
MD5 fe2f9c3b2cec4b4c75adef840b723462
BLAKE2b-256 1268bc44a40933b24cfbac80165348c1283656a791243ab09433b348144092cb

See more details on using hashes here.

File details

Details for the file vvenv-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: vvenv-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 37.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.6

File hashes

Hashes for vvenv-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2ef581703754ce4300a1e97a2defa38104c594eeddea2df8087061a2765e8182
MD5 21f59a1c36ac203f6caef4638fb797ae
BLAKE2b-256 36c320640f7ec4794e4376fb4a780053653a3f487cb4d34c9e005a4745352d37

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page