dotenvyaml
Load environment variables from .env.yaml files. Like python-dotenv, but for YAML — powered by Rust for blazing-fast performance.
Features
- Blazing Fast: Rust backend with 4-5x speedup over PyYAML
- Type-aware: Preserves YAML types (strings, ints, bools, lists)
- Nested keys: Automatically flattens
database.host→DATABASE_HOST - Variable interpolation: Supports
${VAR}and${VAR:-default}syntax - Flexible API: Load into dict or directly into
os.environ - Zero Python dependencies: No PyYAML needed
- Pre-compiled wheels: No Rust toolchain required for installation
- 100% test coverage: Comprehensive Python + Rust test suites
Install
pip install dotenvyaml
# or with uv (recommended)
uv pip install dotenvyaml
Pre-compiled wheels available for:
- Linux: x86_64, aarch64
- macOS: x86_64 (Intel), aarch64 (Apple Silicon)
- Windows: x86_64
Usage
Basic Usage
from dotenvyaml import load, load_env
# Returns dict without modifying os.environ
config = load()
print(config["DATABASE_HOST"])
# Load directly into os.environ
load_env()
print(os.environ["DATABASE_HOST"])
Advanced Usage
from dotenvyaml import load, load_env
# Specify file path
config = load("config/.env.production.yaml")
# Override existing environment variables
load_env(override=True)
# Disable nested key flattening
config = load(flatten=False) # Returns nested dict
Backwards Compatibility
# Old API still works
from dotenvyaml import load_dotenvyaml
load_dotenvyaml() # Same as load_env()
.env.yaml Format
Simple Key-Value Pairs
PROJECT_ID: my-project
REGION: us-central1
SERVICE_ACCOUNT: sa@my-project.iam.gserviceaccount.com
Nested Keys (Auto-Flattened)
database:
host: localhost
port: 5432
credentials:
username: admin
password: secret
# Becomes:
# DATABASE_HOST=localhost
# DATABASE_PORT=5432
# DATABASE_CREDENTIALS_USERNAME=admin
# DATABASE_CREDENTIALS_PASSWORD=secret
Type Support
# Strings
API_KEY: "sk-1234567890"
# Numbers
PORT: 8080
TIMEOUT: 30.5
# Booleans
DEBUG: true
ENABLED: false
# Lists (converted to comma-separated)
ALLOWED_HOSTS:
- localhost
- example.com
- 0.0.0.0
# Becomes: ALLOWED_HOSTS=localhost,example.com,0.0.0.0
API Reference
load(file_path=None, flatten=True, interpolate=False)
Load environment variables from YAML file and return as dict.
Args:
file_path(str | Path | None): Path to YAML file. Auto-discovers.env.yamlif not provided.flatten(bool): Flatten nested keys (default: True).interpolate(bool): Enable${VAR}and${VAR:-default}expansion (default: False).
Returns: dict[str, Any]
Raises: FileNotFoundError, ParseError
load_env(file_path=None, override=False, flatten=True, interpolate=False)
Load environment variables from YAML file into os.environ.
Args:
file_path(str | Path | None): Path to YAML file.override(bool): Override existing environment variables (default: False).flatten(bool): Flatten nested keys (default: True).interpolate(bool): Enable variable expansion (default: False).
Returns: dict[str, Any]
Performance
Benchmarks show 4-5x speedup over PyYAML:
| File Size | Rust (parse+flatten) | PyYAML (parse only) | Speedup |
|---|---|---|---|
| 0.2 KB | 85 μs | 272 μs | 3.2x |
| 1.8 KB | 777 μs | 2.71 ms | 3.5x |
| 20.3 KB | 5.02 ms | 23.66 ms | 4.7x |
| 116 KB | 32.49 ms | 135.73 ms | 4.2x |
Run benchmarks: uv run python benchmarks/bench.py
Development
See CONTRIBUTING.md for detailed development guidelines.
Quick start:
# Install Rust toolchain
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install UV package manager
curl -LsSf https://astral.sh/uv/install.sh | sh
# Install dependencies and build
uv pip install maturin pytest pytest-cov ruff
maturin develop
# Run tests
uv run pytest tests/ -v --cov=dotenvyaml
cargo test -p dotenvyaml-core
# Run benchmarks
uv run python benchmarks/bench.py
Roadmap
- Variable expansion:
${VAR}and${VAR:-default} - Rust backend for 4-5x performance improvement
- Multi-file support:
.env.yaml,.env.yaml.local,.env.production.yaml - CLI tool for debugging
- Schema validation
License
MIT
Metadata
Release files for dotenvyaml 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dotenvyaml-0.2.0.tar.gz | 12.8 kB | With provenance | Details for dotenvyaml-0.2.0.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dotenvyaml-0.2.0-cp312-cp312-win_amd64.whl | CPython 3.12 | CPython 3.12 | Windows x86-64 | Details for dotenvyaml-0.2.0-cp312-cp312-win_amd64.whl |
| dotenvyaml-0.2.0-cp312-cp312-macosx_11_0_arm64.whl | CPython 3.12 | CPython 3.12 | macOS 11.0+ ARM64 | Details for dotenvyaml-0.2.0-cp312-cp312-macosx_11_0_arm64.whl |
| dotenvyaml-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.8 | CPython 3.8 | Linux glibc 2.17+ x86-64 | Details for dotenvyaml-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
Total release size: 962.0 kB
Release files / dotenvyaml-0.2.0.tar.gz
| Download URL | dotenvyaml-0.2.0.tar.gz |
|---|---|
| Size | 12.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
74e86972fc8bf7488703feabcf3ac8bdcb326dcd91057535108dbbb49dd24e6e
|
|
BLAKE2b-256 checksum How to use checksums |
6d6c49ad72d580a033d8bf113ea4897a28d32248301d9c1af1748cf49333200b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 12, 2026.
Transparency logRelease files / dotenvyaml-0.2.0-cp312-cp312-win_amd64.whl
| Download URL | dotenvyaml-0.2.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 228.9 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
fd8c2851f5a4cef6d85c475ebbe798ba1cb408a30cc308101e2168bc0a743e54
|
|
BLAKE2b-256 checksum How to use checksums |
9a537f0665ba234128e246fe36186a9d074304aa00c792149e7fd56fa3d34b36
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 12, 2026.
Transparency logRelease files / dotenvyaml-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | dotenvyaml-0.2.0-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 335.8 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
e57f0bbcb49e9699a6f63a6fc2c5b6c40d99daf4292d8191341eb9aefa8e5c38
|
|
BLAKE2b-256 checksum How to use checksums |
b6687bf98a5ef36ed691a2c42576219905daa66b82b9925e71b02cf508b4f50b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 12, 2026.
Transparency logRelease files / dotenvyaml-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | dotenvyaml-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 384.5 kB |
| Tags | CPython 3.8 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
518f4782efba416252f7712ac10332984a4be275c9957f27a707b0a191c9bbc6
|
|
BLAKE2b-256 checksum How to use checksums |
c05d67d0932a225e2a1e45de88789e96a7456697cb5c9db59ee92cd66776a75f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 12, 2026.
Transparency logSecurity for dotenvyaml 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 4 files in this release have been uploaded with provenance metadata.
Attestation for dotenvyaml-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 12, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.