Skip to main content

dsenv

Python PyPI - Python Version PyPI Downloads PyPI Version GitHub Stars License

Damn Simple Environment Variables loader for Python. Supports Python 3.7 and newer.

Install

pip install dsenv

Usage

from dsenv import load_env, load_merged_envs

# Load from ~/.env
load_env()

# Load from a custom path
load_env("./.env", override_env=False)

# Force override values already present in the environment
load_env("./.env", override_env=True)

# Merge multiple env files (later files win), but keep existing process env vars
load_merged_envs(".env", ".env.local", override_env=False)

# Merge multiple env files and override existing process env vars
load_merged_envs(".env", ".env.local", override_env=True)

Supported .env Syntax

  • KEY=VALUE
  • export KEY=VALUE
  • KEY="VALUE" or KEY='VALUE'
  • Comments with # on empty lines or after unquoted values

Tests

pytest

Or use tox (if you have multiple Python versions installed):

tox

TODO

  • Add more parser behavior tests (especially edge cases) before changing parsing rules.
  • Expand support for escape sequences in quoted values (starting with double quotes).
  • Refine comment parsing edge cases (quoted vs unquoted values, # handling).
  • Evaluate multiline values support.
  • Evaluate variable interpolation support.

License

BSD-3

Metadata

Release files for dsenv 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dsenv 0.2.0
File Size Uploaded
dsenv-0.2.0.tar.gz 4.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dsenv 0.2.0
File Interpreter ABI Platform
dsenv-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.9 kB

Release files / dsenv-0.2.0.tar.gz

Download URL dsenv-0.2.0.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1322b8a0904068f1a998f7f30f0f8ffd9514b6a6e7889ed237995602e2ed00e9
BLAKE2b-256 checksum
How to use checksums
fbad9cc269bd81a9b998530c517040f06a9b318402bc4c60c0f884e4c0cb9780
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / dsenv-0.2.0-py3-none-any.whl

Download URL dsenv-0.2.0-py3-none-any.whl
Size 3.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db3c1c94fa30638bae1a8b2449136a33d9f2941c4693cb1fe383796f2d07cf21
BLAKE2b-256 checksum
How to use checksums
7cace7251fdbf7d644fdf43a35d32e3ab1f854ebe4c996d947e17ba542fcfb34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page