Skip to main content

Automates virtual environment management for Git repositories

Project description

                      ░██   ░██    
                            ░██    
 ░████████ ░██    ░██ ░██░████████ 
░██    ░██ ░██    ░██ ░██   ░██    
░██    ░██  ░██  ░██  ░██   ░██    
░██   ░███   ░██░██   ░██   ░██    
 ░█████░██    ░███    ░██    ░████ 
       ░██                         
 ░███████                          


Git-aware Virtual Environment Manager

Automates virtual environment management for Git repositories.

gvit is a command-line tool that automatically creates and manages virtual environments when you clone repositories. Its goal is to eliminate friction between version control and Python environment management.


🚀 Motivation

Have you ever cloned a project and had to do all this?

git clone https://github.com/someone/project.git
cd project
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

With gvit, all of that happens automatically:

# Clone from scratch
gvit clone https://github.com/someone/project.git

# Or setup an existing repo
cd existing-project
gvit setup

🎉 Environment created and dependencies installed!

Examples

gvit clone example

gvit prune example


⚙️ What gvit does

  • 🪄 Automatically creates environments when cloning or initializing repos
  • 📦 Installs dependencies from requirements.txt, pyproject.toml, or custom paths
  • 🎯 Supports extra dependencies (dev, test, etc.) from pyproject.toml or separate files
  • 🧠 Remembers your preferences via local configuration (~/.config/gvit/config.toml)
  • 📝 Tracks environments in registry (~/.config/gvit/envs/) with metadata and dependency hashes
  • 🧘 Cleans orphaned environments automatically with prune command
  • 🌳 Visual command tree to explore available commands
  • Smart priority resolution: CLI options → repo config → local config → defaults
  • 🔧 Flexible configuration: per-repository (.gvit.toml) or global settings
  • 🐍 Multiple backends: venv (built-in), conda, and virtualenv support

💻 Installation

pip install gvit

Or with pipx (recommended for CLI tools):

pipx install gvit

🧩 Usage

Initial Configuration

Set up your default preferences (interactive):

gvit config setup

Or specify options directly:

gvit config setup --backend venv --python 3.11 --base-deps requirements.txt

# or use conda
gvit config setup --backend conda --python 3.11

# or use virtualenv (faster, more features)
gvit config setup --backend virtualenv --python 3.11

Clone a Repository

Basic clone with automatic environment creation:

gvit clone https://github.com/user/repo.git

Advanced options:

# Custom environment name
gvit clone https://github.com/user/repo.git --venv-name my-env

# Specify Python version
gvit clone https://github.com/user/repo.git --python 3.12

# Install extra dependencies from pyproject.toml
gvit clone https://github.com/user/repo.git --extra-deps dev,test

# Skip dependency installation
gvit clone https://github.com/user/repo.git --no-deps

# Force overwrite existing environment
gvit clone https://github.com/user/repo.git --force

# Verbose output
gvit clone https://github.com/user/repo.git --verbose

Initialize a New Project

Similar to git init but with environment setup:

# In current directory
gvit init

# In specific directory
gvit init my-project

# With remote repository
gvit init --remote-url https://github.com/user/my-project.git

# With all options
gvit init my-project \
  --remote-url https://github.com/user/my-project.git \
  --python 3.12 \
  --extra-deps dev,test

Setup an Existing Repository

If you already have a cloned repository and want to set up the environment:

# In the repository directory
cd my-existing-repo
gvit setup

# Or specify a different directory
gvit setup path/to/repo

# With custom options
gvit setup --python 3.12 --extra-deps dev,test

# Skip dependency installation
gvit setup --no-deps

Pull Changes and Update Dependencies

Smart git pull that automatically detects and reinstalls changed dependencies:

# Pull and auto-update dependencies if changed
gvit pull

# Pull without checking dependencies
gvit pull --no-deps

# Force reinstall all dependencies even if unchanged
gvit pull --force-deps

# Pass options to git pull
gvit pull --rebase origin main

Configuration Management

# Add extra dependency groups to local config
gvit config add-extra-deps dev requirements-dev.txt
gvit config add-extra-deps test requirements-test.txt

# Remove extra dependency groups
gvit config remove-extra-deps dev

# Show current configuration
gvit config show

Environment Management

# List all tracked environments
gvit envs list

# Show details of a specific environment
gvit envs show my-env

# Remove an environment (registry and backend)
gvit envs delete my-env

# Clean up orphaned environments (repos that no longer exist)
gvit envs prune

# Preview what would be removed
gvit envs prune --dry-run

# Auto-confirm removal
gvit envs prune --yes

Explore Commands

# Show all available commands in tree structure
gvit tree

🧠 How it works

Commands

gvit clone: Clones repository + creates environment

  1. Clones the repository using standard git clone
  2. Detects repository name from URL (handles .git suffix correctly)
  3. Proceeds to environment setup (steps 3-7 below)

gvit init: Initializes Git repository + creates environment

  1. Initializes Git repository using git init
  2. Optionally adds remote if --remote-url is provided
  3. Proceeds to environment setup (steps 3-7 below)

gvit setup: Creates environment for existing repository

  1. Verifies Git repository exists in target directory
  2. Detects remote URL if available
  3. Proceeds to environment setup (steps 3-7 below)

gvit pull: Pulls changes and syncs dependencies

  1. Finds tracked environment for current repository
  2. Runs git pull with any extra arguments you provide
  3. Compares dependency file hashes (stored in registry vs. current files)
  4. Reinstalls only changed dependencies automatically
  5. Updates registry with new hashes

Environment Setup Process (common to all commands)

  1. Creates virtual environment using your preferred backend:
    • venv: Python's built-in venv module (creates .venv/ in repo)
    • virtualenv: Enhanced virtual environments (creates .venv/ in repo, faster than venv)
    • conda: Conda environments (centralized management)
  2. Resolves dependencies with priority system:
    • CLI arguments (highest priority)
    • Repository config (.gvit.toml)
    • Local config (~/.config/gvit/config.toml)
    • Default values (lowest priority)
  3. Installs dependencies from:
    • pyproject.toml (with optional extras support)
    • requirements.txt or custom paths
    • Multiple dependency groups (base, dev, test, etc.)
  4. Tracks environment in registry:
    • Saves environment metadata to ~/.config/gvit/envs/{env_name}.toml
    • Records dependency file hashes for change detection
    • Stores repository information (path, URL)
  5. Validates and handles conflicts:
    • Detects existing environments
    • Offers options: rename, overwrite, or abort
    • Auto-generates unique names if needed

⚙️ Configuration

Local Configuration

Global preferences: ~/.config/gvit/config.toml

[gvit]
backend = "venv"  # or "conda", "virtualenv"
python = "3.11"

[deps]
base = "requirements.txt"
dev = "requirements-dev.txt"
test = "requirements-test.txt"

[backends.venv]
name = ".venv"  # Directory name for venv (default: .venv)

[backends.virtualenv]
name = ".venv"  # Directory name for virtualenv (default: .venv)

[backends.conda]
path = "/path/to/conda"  # Optional: custom conda path

Environment Registry

Environment tracking: ~/.config/gvit/envs/{env_name}.toml

[environment]
name = "my-project"
backend = "conda"
python = "3.11"
created_at = "2025-01-22T20:53:01.123456"

[repository]
path = "/Users/user/projects/my-project"
url = "https://github.com/user/my-project.git"

[deps]
base = "requirements.txt"
dev = "requirements-dev.txt"

[deps.installed]
base_hash = "a1b2c3d4e5f6g7h8"  # SHA256 hash for change detection
dev_hash = "i9j0k1l2m3n4o5p6"
installed_at = "2025-01-22T20:53:15.789012"

Repository Configuration

Per-project settings: .gvit.toml (in repository root)

[gvit]
python = "3.12"  # Override Python version for this project

[deps]
base = "requirements.txt"
dev = "requirements-dev.txt"
internal = "requirements-internal.txt"

Or use pyproject.toml (tool section):

[tool.gvit]
python = "3.12"

[tool.gvit.deps]
base = "pyproject.toml"

🧱 Architecture

gvit/
├── src/gvit/
│   ├── cli.py              # CLI entry point (Typer app)
│   ├── env_registry.py     # Environment registry management
│   ├── commands/
│   │   ├── _common.py      # Shared functions between commands
│   │   ├── clone.py        # Clone command logic
│   │   ├── init.py         # Init command logic
│   │   ├── setup.py        # Setup command logic (existing repos)
│   │   ├── pull.py         # Pull command with smart dependency sync
│   │   ├── tree.py         # Tree command (show command structure)
│   │   ├── config.py       # Config management commands
│   │   └── envs.py         # Environment management commands
│   ├── backends/
│   │   ├── venv.py         # Venv backend implementation
│   │   ├── virtualenv.py   # Virtualenv backend implementation
│   │   └── conda.py        # Conda backend implementation
│   ├── utils/
│   │   ├── exceptions.py   # Custom exceptions
│   │   ├── utils.py        # Helper functions
│   │   ├── validators.py   # Input validation
│   │   ├── globals.py      # Constants and defaults
│   │   └── schemas.py      # Type definitions (TypedDict)
│   └── __init__.py
└── pyproject.toml          # Project metadata

🧭 Roadmap

Current Release (v0.0.3)

Feature Status Description
Clone command Full repository cloning with environment setup
Init command Initialize new Git repos with environment setup
Setup command Create environment for existing repositories
Pull command Smart git pull with automatic dependency sync
Tree command Visual command structure explorer
Venv backend Python's built-in venv support
Conda backend Complete conda integration
Virtualenv backend Complete virtualenv integration
Config management setup, add-extra-deps, remove-extra-deps, show
Environment registry Track environments with metadata and dependency hashes
Environment management list, show, delete, prune commands
Orphan cleanup Automatic detection and removal of orphaned environments
Dependency resolution Priority-based resolution (CLI > repo > local > default)
pyproject.toml support Install base + optional dependencies (extras)
Requirements.txt support Standard pip requirements files
Custom dependency paths Flexible path specification via config or CLI
Environment validation Detect conflicts, offer resolution options
TypedDict schemas Full type safety with typed configuration schemas

Next Releases

Version Status Description
0.2.0 📋 Planned Add checkout command to switch branches and sync deps
0.3.0 📋 Planned Shell integration (gvit activate) and completions
0.4.0 📋 Planned gvit sync command for full dependency refresh
1.0.0 🎯 Goal Stable release with all core features

🧑‍💻 Example Workflows

First Time Setup

# Install gvit
pipx install gvit

# Configure defaults (use venv or conda)
gvit config setup --backend venv --python 3.11

# Add common dependency groups
gvit config add-extra-deps dev requirements-dev.txt
gvit config add-extra-deps test requirements-test.txt

Standard Project

# Clone with base dependencies
gvit clone https://github.com/user/project.git

# Activate environment
conda activate project

Project with Extra Dependencies

# Clone and install dev dependencies
gvit clone https://github.com/user/project.git --extra-deps dev

# Or multiple groups
gvit clone https://github.com/user/project.git --extra-deps dev,test

# Activate
conda activate project

Project with pyproject.toml

# Install base dependencies from pyproject.toml
gvit clone https://github.com/user/project.git

# Install with optional dependencies defined in [project.optional-dependencies]
gvit clone https://github.com/user/project.git --extra-deps dev,test

Custom Configuration

# Override everything from CLI
gvit clone https://github.com/user/project.git \\
  --venv-name custom-env \\
  --python 3.12 \\
  --backend conda \\
  --base-deps requirements/prod.txt \\
  --extra-deps dev:requirements/dev.txt,test:requirements/test.txt \\
  --verbose

Initialize a New Project

# Create a new project from scratch
mkdir my-new-project
cd my-new-project
gvit init --remote-url https://github.com/user/my-new-project.git

# Now ready to work
echo "# My Project" > README.md
git add .
git commit -m "Initial commit"
git push -u origin main

Setup an Existing Repository

# You already cloned a repo manually
git clone https://github.com/user/project.git
cd project

# Now set up the environment
gvit setup

# Or with specific options
gvit setup --python 3.12 --extra-deps dev,test

Daily Workflow with Pull

# Update your project (code + dependencies)
cd my-project
gvit pull

# If requirements.txt changed:
# - Dependency changes detected: base
# - Reinstalling base dependencies from requirements.txt...
# 🎉 Repository and dependencies updated successfully!

# Continue working
conda activate my-project

Managing Tracked Environments

# See all environments gvit knows about
gvit envs list

# Check environment details (shows registry file with syntax highlighting)
gvit envs show my-project

# Remove specific environment (registry + conda env)
gvit envs delete old-project

# Clean up all orphaned environments
gvit envs prune

# See what would be cleaned without actually removing
gvit envs prune --dry-run

Explore Available Commands

# Show command tree
gvit tree

# Output:
# gvit
# ├── clone
# ├── config/
# │   ├── add-extra-deps
# │   ├── remove-extra-deps
# │   ├── setup
# │   └── show
# ├── envs/
# │   ├── delete
# │   ├── list
# │   ├── prune
# │   └── show
# ├── pull
# ├── init
# ├── setup
# └── tree

🤝 Contributing

Contributions are welcome! Areas we'd love help with:

  • Additional backends (pyenv, poetry)
  • checkout and other commands
  • Cross-platform testing
  • Documentation improvements

Open an issue or submit a pull request on GitHub.


⚖️ License

MIT © 2025


⭐ Vision

“One repo, its own environment — without thinking about it.”

The goal of gvit is to eliminate the need to manually create or update virtual environments. Git and Python should work together seamlessly — this tool makes it possible.

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

gvit-0.1.0.tar.gz (259.4 kB view details)

Uploaded Source

Built Distribution

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

gvit-0.1.0-py3-none-any.whl (37.2 kB view details)

Uploaded Python 3

File details

Details for the file gvit-0.1.0.tar.gz.

File metadata

  • Download URL: gvit-0.1.0.tar.gz
  • Upload date:
  • Size: 259.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for gvit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a598c35ef835536b2603b7bf974f42d0f6a98a2f045e1dcebb83fb25c96d7501
MD5 35029c2729846efa2b076e64cd05e7ab
BLAKE2b-256 5b25950cc64cfbad0d5c2673ec8445628fb80ecc217eda151de7a7c1ff65ee6a

See more details on using hashes here.

File details

Details for the file gvit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: gvit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 37.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for gvit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f6523fdfd5f077089341e8ebb6f5b3f704d482deb0ed4021db2d7886e5f35628
MD5 97bebb0a77d416bfd7ced90e31f85c6a
BLAKE2b-256 f12a317e136220c0752ee0a300fec70a8c0a0b7d4cb8438efefb838064e544e8

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