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:

Think of it as joining the herd: use modern .env patterns without creating a Dworshak-specific cult in ~/.dworshak/.


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(dotenv_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

Integration with dworshak-prompt and dworshak-obtain

dworshak-env can be used alongside DworshakPrompt and DworshakObtain to fetch values from the environment when prompting for config or secrets:

from dworshak_prompt import DworshakPrompt

prompt = DworshakPrompt()
api_url = prompt.env("API_URL", default="https://api.github.com")

Or within dworshak_obtain:

from dworshak_prompt import dworshak_obtain

token = dworshak_obtain(service="github", key="api_token", store="env")

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.


Links


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.5.tar.gz (10.5 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.5-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dworshak_env-0.1.5.tar.gz
  • Upload date:
  • Size: 10.5 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.5.tar.gz
Algorithm Hash digest
SHA256 692397210d4467071d23359f1d9d5fee4769d723e74fd92aaf90f125352165e1
MD5 3430aa19f742c0d5f7cd331a21a87191
BLAKE2b-256 7295ed685dae066cdcfeb7f1b1423ea2452f6f279a758366942f82ce83025033

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: dworshak_env-0.1.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 2936bd99d49e58c45ae1da83dbd338d0b48eb29fc24643e896873cc962e3f49b
MD5 b855b7b326cdd0421d64c483637dbd18
BLAKE2b-256 4c9aee145bcfa27700270489483964bdbe7d4136b3ad43cd14d11a2054321261

See more details on using hashes here.

Provenance

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