Metadata-Version: 2.4
Name: pyenvcheck
Version: 0.1.1
Summary: Validate environment configuration at Python app startup with security-first design
Project-URL: Homepage, https://github.com/yourusername/pyenvcheck
Project-URL: Documentation, https://pyenvcheck.readthedocs.io
Project-URL: Repository, https://github.com/yourusername/pyenvcheck.git
Project-URL: Bug Tracker, https://github.com/yourusername/pyenvcheck/issues
Author-email: Your Name <your.email@example.com>
License: MIT
License-File: LICENSE
Keywords: config,env,environment,security,startup,validation
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Systems Administration
Requires-Python: >=3.8
Requires-Dist: python-dotenv>=0.20.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: tomli>=1.2.0; python_version < '3.11'
Provides-Extra: dev
Requires-Dist: black>=23.0; extra == 'dev'
Requires-Dist: build>=0.10; extra == 'dev'
Requires-Dist: flake8>=6.0; extra == 'dev'
Requires-Dist: isort>=5.12; extra == 'dev'
Requires-Dist: mkdocs-material>=9.0; extra == 'dev'
Requires-Dist: mkdocs>=1.4; extra == 'dev'
Requires-Dist: mypy>=1.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
Requires-Dist: pytest-mock>=3.10; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: twine>=4.0; extra == 'dev'
Provides-Extra: django
Requires-Dist: django>=3.2; extra == 'django'
Provides-Extra: fastapi
Requires-Dist: fastapi>=0.100.0; extra == 'fastapi'
Provides-Extra: flask
Requires-Dist: flask>=2.0; extra == 'flask'
Provides-Extra: pydantic
Requires-Dist: pydantic>=2.0; extra == 'pydantic'
Description-Content-Type: text/markdown

# pyenvcheck

[![PyPI](https://img.shields.io/pypi/v/pyenvcheck.svg)](https://pypi.org/project/pyenvcheck/)
[![Python Version](https://img.shields.io/pypi/pyversions/pyenvcheck.svg)](https://pypi.org/project/pyenvcheck/)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![CI Status](https://github.com/yourusername/pyenvcheck/workflows/CI/badge.svg)](https://github.com/yourusername/pyenvcheck/actions)

**Validate environment configuration at Python app startup with security-first design.**

Python applications often fail late because configuration is not validated at startup. `pyenvcheck` provides a clean, secure way to:

- ✅ Load and validate environment configuration from `.env`, TOML, and YAML files
- ✅ Define required/optional keys with type coercion and defaults
- ✅ Apply custom validators and transformations
- ✅ Mask sensitive values in startup summaries
- ✅ Get structured config as dataclass or Pydantic models
- ✅ Use the CLI to check config validity before deployment
- ✅ Integrate seamlessly with Django, FastAPI, and Flask

## Quick Start

### Installation

```bash
pip install pyenvcheck
```

### Basic Usage

```python
from pyenvcheck import Config

config = Config({
    'DATABASE_URL': {'required': True},
    'DEBUG': {'type': bool, 'default': False},
    'PORT': {'type': int, 'default': 8000},
    'SECRET_KEY': {'required': True, 'mask': True},
})

# Load from environment
validated_config = config.validate()

# Or load from .env file
validated_config = config.load_env('.env').validate()

# Access config
print(validated_config.DATABASE_URL)

# Get startup summary (secrets masked)
print(validated_config.summary())
```

### Output as Pydantic Model

```python
from pydantic import BaseModel
from pyenvcheck import Config

class Settings(BaseModel):
    database_url: str
    debug: bool = False
    port: int = 8000

config = Config.from_pydantic(Settings)
settings = config.load_env('.env').validate_as(Settings)
```

### CLI Check

```bash
# Validate configuration before deploying
pyenvcheck check --config config.yaml --env production

# Generate example config
pyenvcheck generate --output .env.example
```

### Django Integration

```python
# settings.py
from pyenvcheck.adapters.django import get_settings

ALLOWED_HOSTS = get_settings(settings_dict).ALLOWED_HOSTS
```

### FastAPI Integration

```python
from pyenvcheck.adapters.fastapi import get_settings

settings = get_settings()
app = FastAPI()
```

## Features

- **Multiple Source Support**: Load config from environment variables, `.env` files, YAML, and TOML
- **Source Merging**: Combine multiple config sources with defined priority
- **Type Coercion**: Automatic conversion to int, bool, float, list, etc.
- **Validation**: Required fields, optional with defaults, custom validators
- **Security**: Mask sensitive values in logs and summaries
- **Structured Output**: Pydantic or dataclass-style access
- **CLI Tools**: Validate config and generate examples
- **Framework Integration**: Django, FastAPI, Flask adapters
- **Comprehensive Errors**: Clear error messages with suggestions

## Documentation

- [Getting Started Guide](docs/getting_started.md)
- [API Reference](docs/api_reference.md)
- [Framework Adapters](docs/adapters.md)
- [Examples](examples/)

## Development

```bash
# Clone and install in development mode
git clone https://github.com/yourusername/pyenvcheck.git
cd pyenvcheck
pip install -e ".[dev]"

# Run tests
pytest

# Format code
black src tests
isort src tests

# Type checking
mypy src

# Build docs
mkdocs serve
```

## License

MIT License - see [LICENSE](LICENSE) file for details.

## Contributing

Contributions are welcome! Please see our [contribution guidelines](CONTRIBUTING.md).
