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

Uploaded Python 3

File details

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

File metadata

  • Download URL: dworshak_env-0.1.3.tar.gz
  • Upload date:
  • Size: 9.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.3.tar.gz
Algorithm Hash digest
SHA256 fef720fd3e21895a631f4cd7efc2c7a1f57f0377722d03d8417ace9cf33ad252
MD5 15cb0acd9623610dbef3e6c6ecd1688a
BLAKE2b-256 36a8655714bf1888c1ebe30e2d91ffd4e389f8e81e73edc7add98e96c00dd4ce

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: dworshak_env-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 9.6 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 23403513d93e94bb0b1c9f7c9b70abb40da6860179148004477dd64c6d166a2a
MD5 b2cbc9ff3a3c59d2613f9c598b3d4d6b
BLAKE2b-256 ca979b77a59a8f74a265174fb6734e8d790e7fceb2ec2cb82c580e6f18f40268

See more details on using hashes here.

Provenance

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