Load environment variables from .env.yaml files. Like python-dotenv, but for YAML. Powered by Rust.
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dotenvyaml-0.2.0.tar.gz.
File metadata
- Download URL: dotenvyaml-0.2.0.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74e86972fc8bf7488703feabcf3ac8bdcb326dcd91057535108dbbb49dd24e6e
|
|
| MD5 |
8cd8bcd85a77783da4d03c3a73e82088
|
|
| BLAKE2b-256 |
6d6c49ad72d580a033d8bf113ea4897a28d32248301d9c1af1748cf49333200b
|
Provenance
The following attestation bundles were made for dotenvyaml-0.2.0.tar.gz:
Publisher:
ci.yml on Raviguntakala/dotenvyaml
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dotenvyaml-0.2.0.tar.gz -
Subject digest:
74e86972fc8bf7488703feabcf3ac8bdcb326dcd91057535108dbbb49dd24e6e - Sigstore transparency entry: 1091385929
- Sigstore integration time:
-
Permalink:
Raviguntakala/dotenvyaml@3c465f28f32dc9338b5d8493f8380ae3a939679d -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Raviguntakala
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@3c465f28f32dc9338b5d8493f8380ae3a939679d -
Trigger Event:
push
-
Statement type:
File details
Details for the file dotenvyaml-0.2.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: dotenvyaml-0.2.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 228.9 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd8c2851f5a4cef6d85c475ebbe798ba1cb408a30cc308101e2168bc0a743e54
|
|
| MD5 |
535f54787e9fbb0adccdf84c4ffad602
|
|
| BLAKE2b-256 |
9a537f0665ba234128e246fe36186a9d074304aa00c792149e7fd56fa3d34b36
|
Provenance
The following attestation bundles were made for dotenvyaml-0.2.0-cp312-cp312-win_amd64.whl:
Publisher:
ci.yml on Raviguntakala/dotenvyaml
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dotenvyaml-0.2.0-cp312-cp312-win_amd64.whl -
Subject digest:
fd8c2851f5a4cef6d85c475ebbe798ba1cb408a30cc308101e2168bc0a743e54 - Sigstore transparency entry: 1091385968
- Sigstore integration time:
-
Permalink:
Raviguntakala/dotenvyaml@3c465f28f32dc9338b5d8493f8380ae3a939679d -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Raviguntakala
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@3c465f28f32dc9338b5d8493f8380ae3a939679d -
Trigger Event:
push
-
Statement type:
File details
Details for the file dotenvyaml-0.2.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: dotenvyaml-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 335.8 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e57f0bbcb49e9699a6f63a6fc2c5b6c40d99daf4292d8191341eb9aefa8e5c38
|
|
| MD5 |
0b3b87a135bb28016b35c5e927b3b09a
|
|
| BLAKE2b-256 |
b6687bf98a5ef36ed691a2c42576219905daa66b82b9925e71b02cf508b4f50b
|
Provenance
The following attestation bundles were made for dotenvyaml-0.2.0-cp312-cp312-macosx_11_0_arm64.whl:
Publisher:
ci.yml on Raviguntakala/dotenvyaml
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dotenvyaml-0.2.0-cp312-cp312-macosx_11_0_arm64.whl -
Subject digest:
e57f0bbcb49e9699a6f63a6fc2c5b6c40d99daf4292d8191341eb9aefa8e5c38 - Sigstore transparency entry: 1091385990
- Sigstore integration time:
-
Permalink:
Raviguntakala/dotenvyaml@3c465f28f32dc9338b5d8493f8380ae3a939679d -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Raviguntakala
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@3c465f28f32dc9338b5d8493f8380ae3a939679d -
Trigger Event:
push
-
Statement type:
File details
Details for the file dotenvyaml-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: dotenvyaml-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 384.5 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
518f4782efba416252f7712ac10332984a4be275c9957f27a707b0a191c9bbc6
|
|
| MD5 |
f8df17c140e5842a6df0e58f4053a9df
|
|
| BLAKE2b-256 |
c05d67d0932a225e2a1e45de88789e96a7456697cb5c9db59ee92cd66776a75f
|
Provenance
The following attestation bundles were made for dotenvyaml-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
ci.yml on Raviguntakala/dotenvyaml
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dotenvyaml-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
518f4782efba416252f7712ac10332984a4be275c9957f27a707b0a191c9bbc6 - Sigstore transparency entry: 1091386023
- Sigstore integration time:
-
Permalink:
Raviguntakala/dotenvyaml@3c465f28f32dc9338b5d8493f8380ae3a939679d -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Raviguntakala
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@3c465f28f32dc9338b5d8493f8380ae3a939679d -
Trigger Event:
push
-
Statement type: