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.1.3.tar.gz (161.1 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.1.3-py3-none-any.whl (65.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: envdrift-3.1.3.tar.gz
  • Upload date:
  • Size: 161.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for envdrift-3.1.3.tar.gz
Algorithm Hash digest
SHA256 85759e3e98a747aa9735737b062dd8200a6f8c7953196c15fde85e4e4f6c6e74
MD5 40916f3dcc8c821ef6ffe32f0ae5989c
BLAKE2b-256 4196fdf116b7b531dec59bc1c4fbfcfc9dc97f1492fb294dba7901b9ad9e6156

See more details on using hashes here.

File details

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

File metadata

  • Download URL: envdrift-3.1.3-py3-none-any.whl
  • Upload date:
  • Size: 65.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for envdrift-3.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f223ff64b76c888a6e52d7d81b7db9c5f341e1a64e5ee812098f3609f97b3fce
MD5 f02c2df78c617adbec2ccaab045106a0
BLAKE2b-256 a071a08e8af015d17bd00a8a850d6c2786c786a06872bb57f0e9ca36084a00b4

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