Skip to main content

dworshak-env exists to make environment variables and .env files easy to access in Python programs and through the Dworshak ecosystem. With dworshak-env, Dworshak enables Python devs who already know how they like their configuration by inviting them to leverage the dworshak-prompt library and the dworshak CLI.

Project description

dworshak-env

GitHub: dworshak-env

dworshak-env provides a small, convenient interface for working with environment variables and .env files. It is designed to fit into existing workflows without introducing surprises.

This library does not replace os.getenv. Instead, it helps you manage environment variables in a predictable, Pythonic way and integrates naturally with the broader Dworshak ecosystem:


Installation

pip install dworshak-env

Usage

Simple access to environment variables

from dworshak_env import DworshakEnv

env = DworshakEnv()
api_url = env.get("API_URL", default="https://api.github.com")
print(api_url)

Loading from a .env file

env = DworshakEnv(path=".env")
db_password = env.get("DB_PASSWORD")

Setting defaults

You can instantiate DworshakEnv with defaults that act as fallbacks:

defaults = {"API_URL": "https://api.github.com", "DEBUG": "0"}
env = DworshakEnv(defaults=defaults)

print(env.get("API_URL"))  # returns the default if not set in environment

Philosophy

dworshak-env exists to make environment variables and .env files easy to access in Python programs.

It joins the mainstream patterns that Python developers already know, while providing smooth prompting to users via DworshakPrompt - because developers are users too.

Use it wherever you want predictable, Pythonic environment variable access, with optional integration into the Dworshak ecosystem.


Sister Projects in the Dworshak Ecosystem

pipx install dworshak
pip install dworshak-secret
pip install dworshak-config
pip install dworshak-env
pip install dworshak-prompt

CLI

The dworshak layer is the intended primary CLI entry point, but the dworshak-env CLI can be used directly.

pipx install "dworshak-env[typer]"
dworshak-env --version
dworshak-env --help
dworshak-env set "key" 0
dworshak-env helptree

Screenshot of the dworshak-env CLI helptree

helptree is utility funtion for Typer CLIs, imported from the typer-helptree library.


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

dworshak_env-0.1.7.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

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

dworshak_env-0.1.7-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file dworshak_env-0.1.7.tar.gz.

File metadata

  • Download URL: dworshak_env-0.1.7.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dworshak_env-0.1.7.tar.gz
Algorithm Hash digest
SHA256 58d8c9cc208355c8eedd306b520b930c57c56d755080086f53f5a79430e91e22
MD5 e93d4f778042dcd7a4a9869326f31971
BLAKE2b-256 6e602b5e6a9362045f8676d35a6fffe3d6a24232ae721e4fb596154e7bccabcc

See more details on using hashes here.

Provenance

The following attestation bundles were made for dworshak_env-0.1.7.tar.gz:

Publisher: publish.yml on City-of-Memphis-Wastewater/dworshak-env

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dworshak_env-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: dworshak_env-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dworshak_env-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 05d44cc76028ad55f789360342852f530cb909517af34241cc07f674fd1d27a0
MD5 18979294bc59258c1f9f4df4e558985c
BLAKE2b-256 f6cf2d768207b6f45b6a3006b8b02d5b316d421c5d0c8aa34f3864b69adeadbd

See more details on using hashes here.

Provenance

The following attestation bundles were made for dworshak_env-0.1.7-py3-none-any.whl:

Publisher: publish.yml on City-of-Memphis-Wastewater/dworshak-env

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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