Python Development Workflow for Humans.
—
Environment variable-based configuration system controlling pipenv behavior. The Setting class provides access to all configuration options and settings that control how pipenv operates.
Access pipenv configuration through environment variables.
class Setting:
"""
Configuration management through environment variables.
All settings are accessed as properties that read from environment variables.
50+ configuration options available.
"""
# Core directories and paths
PIPENV_CACHE_DIR: str # Cache directory location
PIPENV_VENV_IN_PROJECT: bool # Create venv in project directory
PIPENV_PIPFILE: str # Custom Pipfile location
PIPENV_DOTENV_LOCATION: str # Custom .env file location
# Python and environment management
PIPENV_PYTHON: str # Python executable path
PIPENV_DEFAULT_PYTHON_VERSION: str # Default Python version
PIPENV_DONT_USE_PYENV: bool # Disable pyenv integration
PIPENV_DONT_USE_ASDF: bool # Disable asdf integration
PIPENV_IGNORE_VIRTUALENVS: bool # Ignore existing virtualenvs
# Output and display control
PIPENV_VERBOSE: bool # Verbose output
PIPENV_QUIET: bool # Quiet output
PIPENV_NOSPIN: bool # Disable spinner animations
PIPENV_SPINNER: str # Spinner type
PIPENV_HIDE_EMOJIS: bool # Hide emoji output
# Package installation and resolution
PIPENV_PYPI_MIRROR: str # PyPI mirror URL
PIPENV_INSTALL_TIMEOUT: int # Package install timeout (900s)
PIPENV_TIMEOUT: int # Virtualenv creation timeout (120s)
PIPENV_REQUESTS_TIMEOUT: int # HTTP requests timeout (10s)
PIPENV_MAX_RETRIES: int # Network retry attempts
PIPENV_RESOLVE_VCS: bool # Resolve VCS dependencies
PIPENV_SKIP_LOCK: bool # Skip automatic locking
PIPENV_SKIP_VALIDATION: bool # Skip requirement validation
# Project discovery and behavior
PIPENV_MAX_DEPTH: int # Max directory search depth (10)
PIPENV_NO_INHERIT: bool # Don't inherit parent directories
# Shell and environment loading
PIPENV_SHELL_EXPLICIT: str # Preferred shell path
PIPENV_SHELL_FANCY: bool # Use fancy shell mode
PIPENV_EMULATOR: str # Terminal emulator name
PIPENV_DONT_LOAD_ENV: bool # Skip loading .env files
# Development and testing
PIPENV_TEST_INDEX: str # Test PyPI index URL
PIPENV_SITE_PACKAGES: bool # Include system site-packages
PIPENV_SYSTEM: bool # Use system pip
# Safety and security
PIPENV_PYUP_API_KEY: str # PyUp API key for safety checks
# Internal behavior
PIPENV_VIRTUALENV: str # Virtualenv location override
PIPENV_CUSTOM_VENV_NAME: str # Custom virtualenv name
USING_DEFAULT_PYTHON: bool # Whether using default PythonUsage examples:
from pipenv.environments import Setting
settings = Setting()
# Check configuration
print(f"Cache directory: {settings.PIPENV_CACHE_DIR}")
print(f"Verbose mode: {settings.PIPENV_VERBOSE}")
print(f"Venv in project: {settings.PIPENV_VENV_IN_PROJECT}")
# Check behavior settings
if settings.PIPENV_SKIP_LOCK:
print("Automatic locking is disabled")
if settings.PIPENV_IGNORE_VIRTUALENVS:
print("Existing virtualenvs will be ignored")Control where pipenv stores files and creates environments.
class Setting:
PIPENV_CACHE_DIR: str # Cache directory (default: ~/.cache/pipenv)
PIPENV_VENV_IN_PROJECT: bool # Create .venv in project directory
PIPENV_CUSTOM_VENV_NAME: str # Custom virtualenv name
PIPENV_DONT_USE_PYENV: bool # Don't use pyenv for Python resolutionUsage examples:
import os
from pipenv.environments import Setting
settings = Setting()
# Configure cache directory
print(f"Cache directory: {settings.PIPENV_CACHE_DIR}")
# Check if venv should be in project
if settings.PIPENV_VENV_IN_PROJECT:
print("Virtual environment will be created in project/.venv")
else:
print("Virtual environment will be created in default location")
# Set custom cache directory
os.environ["PIPENV_CACHE_DIR"] = "/custom/cache/path"Control pipenv's output behavior and display formatting.
class Setting:
PIPENV_VERBOSE: bool # Enable verbose output
PIPENV_QUIET: bool # Enable quiet mode
PIPENV_COLORBLIND: bool # Disable colored output
PIPENV_NOSPIN: bool # Disable spinner animations
PIPENV_HIDE_EMOJIS: bool # Hide emoji characters
PIPENV_NO_INHERIT: bool # Don't inherit parent shell settingsUsage examples:
import os
from pipenv.environments import Setting
# Enable verbose mode
os.environ["PIPENV_VERBOSE"] = "1"
settings = Setting()
if settings.PIPENV_VERBOSE:
print("Verbose mode enabled - detailed output will be shown")
# Configure for CI/automation
os.environ["PIPENV_QUIET"] = "1"
os.environ["PIPENV_NOSPIN"] = "1"
os.environ["PIPENV_HIDE_EMOJIS"] = "1"
settings = Setting()
print(f"Quiet mode: {settings.PIPENV_QUIET}")
print(f"Spinner disabled: {settings.PIPENV_NOSPIN}")Control Python interpreter selection and environment behavior.
class Setting:
PIPENV_PYTHON: str # Specific Python executable
PIPENV_DEFAULT_PYTHON_VERSION: str # Default Python version
PIPENV_DONT_USE_PYENV: bool # Disable pyenv integration
PIPENV_IGNORE_VIRTUALENVS: bool # Ignore existing virtualenvs
PIPENV_SHELL_FANCY: bool # Use fancy shell prompt
PIPENV_SHELL: str # Shell executable to useUsage examples:
import os
from pipenv.environments import Setting
# Configure Python version
os.environ["PIPENV_PYTHON"] = "3.9"
os.environ["PIPENV_DEFAULT_PYTHON_VERSION"] = "3.9"
settings = Setting()
print(f"Python executable: {settings.PIPENV_PYTHON}")
print(f"Default version: {settings.PIPENV_DEFAULT_PYTHON_VERSION}")
# Disable pyenv
os.environ["PIPENV_DONT_USE_PYENV"] = "1"
if settings.PIPENV_DONT_USE_PYENV:
print("pyenv integration disabled")
# Configure shell
os.environ["PIPENV_SHELL_FANCY"] = "1"
os.environ["PIPENV_SHELL"] = "/bin/zsh"Control package installation and network behavior.
class Setting:
PIPENV_PYPI_MIRROR: str # PyPI mirror URL
PIPENV_TIMEOUT: int # Network timeout seconds
PIPENV_INSTALL_TIMEOUT: int # Package install timeout
PIPENV_RESOLVE_VCS: bool # Resolve VCS dependencies
PIPENV_SKIP_VALIDATION: bool # Skip requirement validation
PIPENV_MAX_RETRIES: int # Max retry attemptsUsage examples:
import os
from pipenv.environments import Setting
# Configure PyPI mirror
os.environ["PIPENV_PYPI_MIRROR"] = "https://pypi.example.com/simple"
os.environ["PIPENV_TIMEOUT"] = "120"
os.environ["PIPENV_INSTALL_TIMEOUT"] = "900"
settings = Setting()
print(f"PyPI mirror: {settings.PIPENV_PYPI_MIRROR}")
print(f"Network timeout: {settings.PIPENV_TIMEOUT}")
print(f"Install timeout: {settings.PIPENV_INSTALL_TIMEOUT}")
# Configure VCS resolution
os.environ["PIPENV_RESOLVE_VCS"] = "1"
if settings.PIPENV_RESOLVE_VCS:
print("VCS dependencies will be resolved")Control dependency resolution and lock file behavior.
class Setting:
PIPENV_SKIP_LOCK: bool # Skip automatic lock generation
PIPENV_MAX_DEPTH: int # Max Pipfile search depth
PIPENV_PIPFILE: str # Custom Pipfile location
PIPENV_DONT_LOAD_ENV: bool # Don't load .env files
PIPENV_DOTENV_LOCATION: str # Custom .env file locationUsage examples:
import os
from pipenv.environments import Setting
# Configure locking behavior
os.environ["PIPENV_SKIP_LOCK"] = "1"
os.environ["PIPENV_MAX_DEPTH"] = "5"
settings = Setting()
if settings.PIPENV_SKIP_LOCK:
print("Automatic lock file generation disabled")
print(f"Max search depth: {settings.PIPENV_MAX_DEPTH}")
# Configure custom Pipfile
os.environ["PIPENV_PIPFILE"] = "/custom/path/Pipfile"
print(f"Custom Pipfile: {settings.PIPENV_PIPFILE}")
# Configure .env file handling
os.environ["PIPENV_DONT_LOAD_ENV"] = "1"
os.environ["PIPENV_DOTENV_LOCATION"] = "/custom/.env"Control security checks and validation behavior.
class Setting:
PIPENV_CHECK_FLAGS: str # Safety check flags
PIPENV_IGNORE_PIPFILE: bool # Ignore Pipfile for installs
PIPENV_SKIP_VALIDATION: bool # Skip requirement validation
PIPENV_EMULATOR: str # Terminal emulator for shellUsage examples:
import os
from pipenv.environments import Setting
# Configure security checks
os.environ["PIPENV_CHECK_FLAGS"] = "--db /custom/safety-db"
settings = Setting()
print(f"Safety check flags: {settings.PIPENV_CHECK_FLAGS}")
# Configure validation
os.environ["PIPENV_SKIP_VALIDATION"] = "1"
if settings.PIPENV_SKIP_VALIDATION:
print("Requirement validation disabled")While pipenv primarily uses environment variables, it also supports configuration files.
# .env file content
PIPENV_VENV_IN_PROJECT=1
PIPENV_VERBOSE=1
PIPENV_PYTHON=3.9
PIPENV_PYPI_MIRROR=https://pypi.example.com/simpleUsage in code:
from pipenv.environments import Setting
# pipenv automatically loads .env files
settings = Setting()
# Settings from .env are available
print(f"Venv in project: {settings.PIPENV_VENV_IN_PROJECT}")
print(f"Verbose mode: {settings.PIPENV_VERBOSE}")Change configuration at runtime:
import os
from pipenv.environments import Setting
# Initial settings
settings = Setting()
print(f"Initial verbose: {settings.PIPENV_VERBOSE}")
# Change environment variable
os.environ["PIPENV_VERBOSE"] = "1"
# Create new Setting instance to pick up changes
new_settings = Setting()
print(f"Updated verbose: {new_settings.PIPENV_VERBOSE}")import os
# Development-friendly settings
os.environ.update({
"PIPENV_VENV_IN_PROJECT": "1", # Keep venv in project
"PIPENV_VERBOSE": "1", # Detailed output
"PIPENV_SHELL_FANCY": "1", # Nice shell prompt
"PIPENV_IGNORE_VIRTUALENVS": "0", # Use existing venvs
})import os
# CI/CD-friendly settings
os.environ.update({
"PIPENV_QUIET": "1", # Minimal output
"PIPENV_NOSPIN": "1", # No animations
"PIPENV_HIDE_EMOJIS": "1", # No emojis
"PIPENV_COLORBLIND": "1", # No colors
"PIPENV_SKIP_LOCK": "0", # Always generate locks
"PIPENV_INSTALL_TIMEOUT": "1200", # Longer timeout
})import os
# Corporate network settings
os.environ.update({
"PIPENV_PYPI_MIRROR": "https://corporate-pypi.company.com/simple",
"PIPENV_TIMEOUT": "60", # Shorter timeout
"PIPENV_MAX_RETRIES": "5", # More retries
"PIPENV_CACHE_DIR": "/shared/cache/pipenv", # Shared cache
})Validate configuration settings:
from pipenv.environments import Setting
import os
from pathlib import Path
def validate_configuration():
"""Validate pipenv configuration settings."""
settings = Setting()
# Validate cache directory
cache_dir = Path(settings.PIPENV_CACHE_DIR)
if not cache_dir.exists():
print(f"Warning: Cache directory does not exist: {cache_dir}")
# Validate Python executable
if settings.PIPENV_PYTHON:
python_path = Path(settings.PIPENV_PYTHON)
if not python_path.exists():
print(f"Warning: Python executable not found: {python_path}")
# Check for conflicting settings
if settings.PIPENV_VERBOSE and settings.PIPENV_QUIET:
print("Warning: Both verbose and quiet modes enabled")
# Validate timeout values
if settings.PIPENV_TIMEOUT and settings.PIPENV_TIMEOUT < 30:
print("Warning: Network timeout may be too short")
validate_configuration()Debug configuration issues:
from pipenv.environments import Setting
import os
def debug_configuration():
"""Debug pipenv configuration."""
settings = Setting()
print("=== Pipenv Configuration ===")
# Core settings
config_vars = [
"PIPENV_CACHE_DIR", "PIPENV_VENV_IN_PROJECT", "PIPENV_VERBOSE",
"PIPENV_QUIET", "PIPENV_PYTHON", "PIPENV_PYPI_MIRROR",
"PIPENV_SKIP_LOCK", "PIPENV_MAX_DEPTH", "PIPENV_TIMEOUT"
]
for var in config_vars:
value = getattr(settings, var, None)
env_value = os.environ.get(var, "Not set")
print(f"{var}: {value} (env: {env_value})")
debug_configuration()Install with Tessl CLI
npx tessl i tessl/pypi-pipenv