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:
- dworshak-prompt — prompting and configuration
- dworshak-config — JSON-based configuration
- dworshak-secret — secure secret storage
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
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.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f38e66c0d9529f6770ef678e21b6a3e7a69ce6fd825caf034540266c2f9f5910
|
|
| MD5 |
6be3ef68190e6b7eb694ea9594864cd9
|
|
| BLAKE2b-256 |
2dcfb403c8fd25e274ab0949e76d1cd957f7263e88f5bec91f15744f9b74c401
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dworshak_env-0.1.2.tar.gz -
Subject digest:
f38e66c0d9529f6770ef678e21b6a3e7a69ce6fd825caf034540266c2f9f5910 - Sigstore transparency entry: 949746938
- Sigstore integration time:
-
Permalink:
City-of-Memphis-Wastewater/dworshak-env@432436286d15ea3dce5277dfe1ebab6bd1869b0e -
Branch / Tag:
refs/tags/v0.1.2 - 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@432436286d15ea3dce5277dfe1ebab6bd1869b0e -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a657e588e5d21099e49494e17dae4d04d3b4460ba30e28b6a454de04f95354ea
|
|
| MD5 |
286f91d6eca07cc4ec067e67d64f57de
|
|
| BLAKE2b-256 |
e039cd8f47d996df755a5ac68f05a217e95dc189e09090dba054d5d4d01a02ff
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dworshak_env-0.1.2-py3-none-any.whl -
Subject digest:
a657e588e5d21099e49494e17dae4d04d3b4460ba30e28b6a454de04f95354ea - Sigstore transparency entry: 949746987
- Sigstore integration time:
-
Permalink:
City-of-Memphis-Wastewater/dworshak-env@432436286d15ea3dce5277dfe1ebab6bd1869b0e -
Branch / Tag:
refs/tags/v0.1.2 - 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@432436286d15ea3dce5277dfe1ebab6bd1869b0e -
Trigger Event:
release
-
Statement type: