Skip to main content

Damn Simple Environ Vars

Project description

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

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

dsenv-0.2.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

dsenv-0.2.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file dsenv-0.2.0.tar.gz.

File metadata

  • Download URL: dsenv-0.2.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for dsenv-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1322b8a0904068f1a998f7f30f0f8ffd9514b6a6e7889ed237995602e2ed00e9
MD5 80ee19843086f8ec2e2c74620dd0df31
BLAKE2b-256 fbad9cc269bd81a9b998530c517040f06a9b318402bc4c60c0f884e4c0cb9780

See more details on using hashes here.

File details

Details for the file dsenv-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: dsenv-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for dsenv-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 db3c1c94fa30638bae1a8b2449136a33d9f2941c4693cb1fe383796f2d07cf21
MD5 293bd5da38f3ed6e495eab1282e11b93
BLAKE2b-256 7cace7251fdbf7d644fdf43a35d32e3ab1f854ebe4c996d947e17ba542fcfb34

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