Skip to main content

Python >=3.11 Code style: black Nox

Python tests

eggviron


Manage loading key:value pairs at runtime from various sources. Values can then be accessed from os.environ similar to the python-dotenv library. Additionally, the Eggviron object provides a dictionary-like interface for accessing all loaded values. All keys and values are stored as strings with methods in Eggviron for converting to int, float, and bool as needed.

Eggviron is designed to fail early and fail often. This allows for failures of environment setup to be caught quickly, removing assumption.

Don't want to mutate the os.environ? Turn off mutation when using the Eggviron class.

Loaders allow the selection of source for the key:value pairs and which order they are loaded in. Prevent clobbering existing values when loading multiple sources by default.

Install

pip install eggviron

Example:

from eggviron import Eggviron
from eggviron import EnvFileLoader
from eggviron import AWSParamStoreLoader

environ = Eggviron().load(
    # Load the local '.env' file
    EnvFileLoader(),
    # Load all key:value pairs from AWS Parameter Store
    AWSParamStoreLoader(parameter_path="/prod/frontend-api/"),
)

print(f"Using local account: {environ['ACCOUNT_ID']}")
print(f"New UI feature flag: {environ.get_bool('FEATURE_FLAG_NEW_UI')}")

Logging

  • Logger name: eggviron
  • No handlers, levels, or formatters are applied to the core library
  • Minimal logging is used.

API Reference

Eggviron(*, raise_on_overwrite: bool = True, mutate_environ: bool = True)

A key:value store optionally loaded through Loaders. By default, key:value pairs added

  • raise_on_overwrite: If True a KeyError will be raised when an existing key is overwritten by an assignment or load() action.
  • mutate_environ: If True then the os.environ values are mutated when .load() is run or Eggviron is updated.

load(loader: Loader) -> Eggviron

Use loader(s) to update the loaded values. Loaders are used in the order provided. Key:value pairs are added to os.environ after each loader is run if mutation is allow.

get(key: str, default: str | None = None) -> str

Get a value from the Eggviron. If default is None and the key is not found, a KeyError will be raised.

get_int(key: str, default: int | None = None) -> int

Get a value from the Eggviron, converting it to an int. If default is None and the key is not found, a KeyError will be raised.

get_float(key: str, default: float | None = None) -> float

Get a value from the Eggviron, converting it to an float. If default is None and the key is not found, a KeyError will be raised.

get_bool(key: str, default: bool | None = None) -> bool

Get a value from the Eggviron, converting it to an bool. If default is None and the key is not found, a KeyError will be raised.

Valid boolean values are "true", "false", "1", and "0" (case insensitive)

EnvironLoader()

Load current os.environ key:value pairs into the Eggviron instance.

EnvFileLoader(filename: str = "./.env")

Load a local '.env' file into the Eggviron instance.

AWSParamStoreLoader (*, parameter_path: str, parameter_name: str, aws_region: str | None = None, truncate_key: bool = False, recursive: bool = False)

Load all key:value pairs found under given path from AWS Parameter Store (SSM). Requires AWS access keys to be set in the environment variables. Only parameter_path or parameter_name is accepted, not both.

  • parameter_path: Path of parameters. e.g.: /Finance/Prod/IAD/WinServ2016/
  • parameter_name: Parameter name to load. e.g.: /Finance/Prod/IAD/WinServ2016/license33
  • aws_region: Region to load from. Defaults to AWS_DEFAULT_REGION environment variable
  • truncate_key: When True only the final component of the path will be used as the key
  • recursive: Recursively load all nested paths under given parameter_path

The AWSParamStoreLoader requires boto3 and botocore to be installed. If eggviron is installed with the aws extra, these packages will be included.

For convenience, AWSParamStoreLoader will raise AWSParamStoreException for all boto3 client errors with detailed attributes for troubleshooting.

AWSParamStoreException(message: str, code: str | None, request_id: str | None, http_status_code: int | None = None, http_headers: dict[str, str] = {}, retry_attemps: int | None = None)

Raised from all botocore.exceptions.ClientError and botocore.exceptions.BotoCoreError exceptions in AWSParamStoreLoader. If available, contains the required information for troubleshooting the error.


env file format

The env file format supports many formatting features.

# Comments are allowed
; With either leading charater
simple=value # Inline comments are supported
complex = value; there must be a leading whitespace for inline comments
quoted = 'First layer of matching quotes is stripped'
trickery="We're #1 but only because of the quotes here"
# leading export keywords are stripped
export TOKEN = sometoken
; Whitespace around key:pairs is trimmed except when quoted
    whitespace    =    trimmed
{
  "simple": "value",
  "complex": "value; there must be a leading whitespace for inline comments",
  "quoted": "First layer of matching quotes is stripped",
  "trickery": "We're #1 but only because of the quotes here",
  "TOKEN": "sometoken",
  "whitespace": "trimmed"
}

Metadata

Release files for eggviron 1.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 eggviron 1.2.0
File Size Uploaded Provenance Actions
eggviron-1.2.0.tar.gz 115.2 kB With provenance Details for eggviron-1.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 126.2 kB

Release files / eggviron-1.2.0.tar.gz

Download URL eggviron-1.2.0.tar.gz
Size 115.2 kB
Tags Source
SHA-256 checksum
How to use checksums
f67ff2bee475aec096cfcdf0d1f090f501d30a4295e29c5b7df501061e23481b
BLAKE2b-256 checksum
How to use checksums
183160d0b4df0d8c5ce14d6d5aea1d0169334f310e104cb39589fa8cd812d395
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 24, 2026.

Transparency log

Release files / eggviron-1.2.0-py3-none-any.whl

Download URL eggviron-1.2.0-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
18113531fa2d2fb8310aa87afb61883bad64352af096f94615ae5e9269d32199
BLAKE2b-256 checksum
How to use checksums
f3e9d80b728d3abd1da63084e724eea92a50e6884f85519bd78fff66087575d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 24, 2026.

Transparency log

Security for eggviron 1.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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for eggviron-1.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 Oct 24, 2026.

Transparency log

A 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.

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