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.


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.


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

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.8.tar.gz (11.6 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.8-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for dworshak_env-0.1.8.tar.gz
Algorithm Hash digest
SHA256 617947c0436b9e1abc03eaca305656abd4e5563668a967aab1a5aa51e294c53d
MD5 3587b34aff0f57e9f7a60288f8826cc0
BLAKE2b-256 3c73dd6c90aeae360769c2cc6ee4212caa667c76790e63d01663f88daefabd9a

See more details on using hashes here.

Provenance

The following attestation bundles were made for dworshak_env-0.1.8.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.8-py3-none-any.whl.

File metadata

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

File hashes

Hashes for dworshak_env-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 10842812dd926b9909fc2b7b568f8c035bc204291cb3b3013ba16820b88dd026
MD5 710e0450ba1176f5416b52fc6315c171
BLAKE2b-256 6c7fe045125bef93ed51ff1338479c16d5a52d804f7b17a63a42f660ad0c014e

See more details on using hashes here.

Provenance

The following attestation bundles were made for dworshak_env-0.1.8-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