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.4.tar.gz (9.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.4-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dworshak_env-0.1.4.tar.gz
  • Upload date:
  • Size: 9.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.4.tar.gz
Algorithm Hash digest
SHA256 b676cac841694923235a6fc5729928e9edfdc2e85b3c8cb5200192ec259e005c
MD5 509597fb1568f7bf8cc3e0dc7c4b884f
BLAKE2b-256 d93f090cb4acac19c9a19a942b3f9ac132cb2522227ada9f04e63c9129c67959

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: dworshak_env-0.1.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4488f6496323dd096dd2139a61dee52f25228b7aa996fa80b63ee1f6769c52bf
MD5 ebfc95e0f1a75817d87cbad5f948b785
BLAKE2b-256 124a5d17bea03e0b398f619a67e38c01120fb5fbc34d2a243e081a8d432a7fe5

See more details on using hashes here.

Provenance

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