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", item="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.2.tar.gz (9.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.2-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dworshak_env-0.1.2.tar.gz
  • Upload date:
  • Size: 9.6 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.2.tar.gz
Algorithm Hash digest
SHA256 f38e66c0d9529f6770ef678e21b6a3e7a69ce6fd825caf034540266c2f9f5910
MD5 6be3ef68190e6b7eb694ea9594864cd9
BLAKE2b-256 2dcfb403c8fd25e274ab0949e76d1cd957f7263e88f5bec91f15744f9b74c401

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: dworshak_env-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.9 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a657e588e5d21099e49494e17dae4d04d3b4460ba30e28b6a454de04f95354ea
MD5 286f91d6eca07cc4ec067e67d64f57de
BLAKE2b-256 e039cd8f47d996df755a5ac68f05a217e95dc189e09090dba054d5d4d01a02ff

See more details on using hashes here.

Provenance

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