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
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.
Sister Projects in the Dworshak Ecosystem
- CLI/Orchestrator: dworshak
- Interactive UI: dworshak-prompt
- Secrets Storage: dworshak-secret
- Plaintext Pathed Configs: dworshak-config
- Classic .env Injection: dworshak-env
pipx install dworshak
pip install dworshak-secret
pip install dworshak-config
pip install dworshak-env
pip install dworshak-prompt
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
helptree is utility funtion for Typer CLIs, imported from the typer-helptree library.
- GitHub: https://github.com/City-of-Memphis-Wastewater/typer-helptree
- PyPI: https://pypi.org/project/typer-helptree/
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dworshak_env-0.1.7.tar.gz.
File metadata
- Download URL: dworshak_env-0.1.7.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58d8c9cc208355c8eedd306b520b930c57c56d755080086f53f5a79430e91e22
|
|
| MD5 |
e93d4f778042dcd7a4a9869326f31971
|
|
| BLAKE2b-256 |
6e602b5e6a9362045f8676d35a6fffe3d6a24232ae721e4fb596154e7bccabcc
|
Provenance
The following attestation bundles were made for dworshak_env-0.1.7.tar.gz:
Publisher:
publish.yml on City-of-Memphis-Wastewater/dworshak-env
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dworshak_env-0.1.7.tar.gz -
Subject digest:
58d8c9cc208355c8eedd306b520b930c57c56d755080086f53f5a79430e91e22 - Sigstore transparency entry: 1180888983
- Sigstore integration time:
-
Permalink:
City-of-Memphis-Wastewater/dworshak-env@073216ea3b5943b031ae5e59bc18ab9924fd244b -
Branch / Tag:
refs/tags/v0.1.7 - Owner: https://github.com/City-of-Memphis-Wastewater
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@073216ea3b5943b031ae5e59bc18ab9924fd244b -
Trigger Event:
release
-
Statement type:
File details
Details for the file dworshak_env-0.1.7-py3-none-any.whl.
File metadata
- Download URL: dworshak_env-0.1.7-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05d44cc76028ad55f789360342852f530cb909517af34241cc07f674fd1d27a0
|
|
| MD5 |
18979294bc59258c1f9f4df4e558985c
|
|
| BLAKE2b-256 |
f6cf2d768207b6f45b6a3006b8b02d5b316d421c5d0c8aa34f3864b69adeadbd
|
Provenance
The following attestation bundles were made for dworshak_env-0.1.7-py3-none-any.whl:
Publisher:
publish.yml on City-of-Memphis-Wastewater/dworshak-env
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dworshak_env-0.1.7-py3-none-any.whl -
Subject digest:
05d44cc76028ad55f789360342852f530cb909517af34241cc07f674fd1d27a0 - Sigstore transparency entry: 1180889036
- Sigstore integration time:
-
Permalink:
City-of-Memphis-Wastewater/dworshak-env@073216ea3b5943b031ae5e59bc18ab9924fd244b -
Branch / Tag:
refs/tags/v0.1.7 - Owner: https://github.com/City-of-Memphis-Wastewater
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@073216ea3b5943b031ae5e59bc18ab9924fd244b -
Trigger Event:
release
-
Statement type: