Skip to main content

Prevent environment variable drift with Pydantic schema validation, pre-commit hooks, and dotenvx encryption

Project description

envdrift logo

envdrift

PyPI version Python 3.11+ License: MIT Docs Ruff Pyrefly codecov SLOC

Prevent environment variable drift between dev, staging, and production.

The Problem

  • A missing DATABASE_URL in production causes a 3am outage
  • Staging has NEW_FEATURE_FLAG=true but production doesn't
  • "It works on my machine!" becomes your team's motto

The Solution

# Validate .env against Pydantic schema
envdrift validate .env --schema config.settings:Settings

# Compare dev vs prod
envdrift diff .env.development .env.production

# Check encryption status
envdrift encrypt .env.production --check

Installation

pip install envdrift

Quick Start

Define your schema:

from pydantic import Field
from pydantic_settings import BaseSettings, SettingsConfigDict

class Settings(BaseSettings):
    model_config = SettingsConfigDict(extra="forbid")

    DATABASE_URL: str = Field(json_schema_extra={"sensitive": True})
    API_KEY: str = Field(json_schema_extra={"sensitive": True})
    DEBUG: bool = False

Validate:

envdrift validate .env --schema config.settings:Settings

Features

Feature envdrift
Schema validation Pydantic-based
Cross-env diff Yes
Pre-commit hooks Yes
Encryption (dotenvx) Yes
Vault integration Azure, AWS, HashiCorp
CI/CD mode Yes

Documentation

Full documentation: jainal09.github.io/envdrift

Development

git clone https://github.com/jainal09/envdrift.git
cd envdrift
make dev
make test
make docs-serve

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

envdrift-3.0.2.tar.gz (153.7 kB view details)

Uploaded Source

Built Distribution

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

envdrift-3.0.2-py3-none-any.whl (63.1 kB view details)

Uploaded Python 3

File details

Details for the file envdrift-3.0.2.tar.gz.

File metadata

  • Download URL: envdrift-3.0.2.tar.gz
  • Upload date:
  • Size: 153.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for envdrift-3.0.2.tar.gz
Algorithm Hash digest
SHA256 45ae5f567b0f47d12d5b935daf173c969c10707cb9fd15e6d2f1d1678a1c6608
MD5 49e856bc22098ba5daa4fb18291a2aff
BLAKE2b-256 162f44356338e250e5b67057c0722d04cc48f197d0e08e32ae0f7fac8227b797

See more details on using hashes here.

File details

Details for the file envdrift-3.0.2-py3-none-any.whl.

File metadata

  • Download URL: envdrift-3.0.2-py3-none-any.whl
  • Upload date:
  • Size: 63.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for envdrift-3.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cd4dee219e21d019a3549c3b4809c91dc55af0b11502f2d0c878f969f00827a4
MD5 cf905aee4e1907b7dd008ad057a04763
BLAKE2b-256 3da6a9464bf9804c07f543fff010c1735e7bd6d6a540476138230bd7c5bb1964

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