OneEnv 🌟

Python environment variable management made simple.
OneEnv automatically discovers environment variable templates from your installed packages and manages them with namespaces.
Core Features 🎯
1. 🏗️ Intelligent Scaffolding System
Organize environment templates by categories (Database, VectorStore, LLM, etc.) with structured discovery and selective generation.
2. 📦 Package Environment Variable Discovery
Automatically collect environment variable templates from all installed packages - no manual configuration required.
3. 🏷️ Namespace Management
Organize environment variables by service/component with intelligent fallback.
4. 🛠️ Tool-Friendly APIs
Programmatic access to template structure for building custom scaffolding tools and integrations.
Installation 📦
pip install oneenv
Quick Start 🚀
Generate Environment Template
oneenv template
Explore Available Templates
oneenv template --structure
oneenv template --info Database
oneenv template --preview Database postgres
oneenv template --generate Database:postgres VectorStore:chroma
Use Named Environments
import oneenv
oneenv.env().load_dotenv("common.env")
oneenv.env("database").load_dotenv("database.env")
oneenv.env("web").load_dotenv("web.env")
db_host = oneenv.env("database").get("HOST", "localhost")
web_port = oneenv.env("web").get("PORT", "8000")
timeout = oneenv.env("database").get("TIMEOUT", "30")
Example: Before vs After
Before OneEnv:
DATABASE_URL = os.getenv("DATABASE_URL")
WEB_HOST = os.getenv("WEB_HOST")
API_KEY = os.getenv("API_KEY")
After OneEnv:
db_url = oneenv.env("database").get("URL")
web_host = oneenv.env("web").get("HOST")
api_key = oneenv.env("api").get("KEY")
How It Works
- Discovery: OneEnv finds environment variable templates from installed packages
- Generation: Creates consolidated
.env.example
files
- Namespace: Loads variables into separate namespaces with fallback to common settings
Advanced Usage: Scaffolding System 🏗️
OneEnv's intelligent scaffolding system organizes templates by categories and provides powerful APIs for custom tool development:
Interactive Template Discovery
oneenv template --structure
oneenv template --info Database
oneenv template --preview Database postgres
oneenv template --generate Database:postgres VectorStore:chroma LLM:openai
oneenv template --structure --json
Programmatic API for Custom Tools 🛠️
Build sophisticated scaffolding tools using OneEnv's comprehensive APIs:
import oneenv
structure = oneenv.get_all_template_structure()
print("Available categories:", list(structure.keys()))
if oneenv.has_category("Database"):
options = oneenv.get_options("Database")
print(f"Database options: {options}")
info = oneenv.get_category_info("Database")
print(f"Total variables: {info['total_variables']}")
print(f"Critical variables: {info['critical_variables']}")
preview = oneenv.get_option_preview("Database", "postgres")
for var_name, config in preview['variables'].items():
print(f"{var_name}: {config['importance']} - {config['description']}")
selections = [
{"category": "Database", "option": "postgres"},
{"category": "VectorStore", "option": "chroma"},
{"category": "LLM", "option": "openai"}
]
content = oneenv.generate_template(".env.example", selections)
print("Generated custom template with selected components!")
Create Package Templates 📦
Developers can create discoverable templates using the new scaffolding format:
def database_template():
return [
{
"category": "Database",
"option": "postgres",
"env": {
"DATABASE_URL": {
"description": "PostgreSQL connection URL",
"default": "postgresql://user:pass@localhost:5432/dbname",
"required": True,
"importance": "critical"
},
"DATABASE_POOL_SIZE": {
"description": "Connection pool size",
"default": "10",
"required": False,
"importance": "important"
}
}
},
{
"category": "Database",
"option": "sqlite",
"env": {
"DATABASE_URL": {
"description": "SQLite database file path",
"default": "sqlite:///app.db",
"required": True,
"importance": "critical"
}
}
}
]
Register in pyproject.toml
:
[project.entry-points."oneenv.templates"]
database = "mypackage.templates:database_template"
Key Features:
- Category-based organization - Group related templates (Database, VectorStore, LLM, etc.)
- Multiple options per category - Provide alternatives (postgres, sqlite, mysql)
- Importance levels - Critical, Important, Optional for better user guidance
- Automatic discovery - Users automatically see your templates with
oneenv template --structure
Learn More 📚
Step-by-Step Tutorials
🌱 Basics (5-10 min each)
🚀 Practical (10-15 min each)
⚡ Advanced (15-20 min each)
🚀 New Scaffolding Features (10-20 min each)
📚 Documentation
Start here: Step 1: Basic dotenv Usage
License ⚖️
MIT License