Load environment variables from Argus via IPC, with .env fallback
Project description
useargus
Load environment variables from Argus over local IPC, with .env fallback — similar to python-dotenv, but secrets come from your Argus bucket when the desktop app is running.
Requirements
- Python 3.10+
- Argus desktop signed in (IPC socket active)
- Project
.envwithARGUS_BUCKET_IDandARGUS_BUCKET_TOKEN(not the secret values themselves)
Install
pip install useargus
Usage
Call load_env() before other modules read os.environ:
from useargus import load_env
load_env()
Migration from python-dotenv
# Before
from dotenv import load_dotenv
load_dotenv()
# After
from useargus import load_env
load_env()
Project .env
ARGUS_BUCKET_ID=550e8400-e29b-41d4-a716-446655440000
ARGUS_BUCKET_TOKEN=tok_...
# Optional local overrides (override bucket values for the same key)
# DATABASE_URL=postgresql://localhost/dev
Copy .env.example to get started.
How it works
- Parse
.env(no side effects yet). - If
ARGUS_BUCKET_IDandARGUS_BUCKET_TOKENare set (OS env or.env), connect to Argus over IPC and fetch mapped secrets. - Apply bucket values to
os.environ. - Apply
.env— duplicate keys use the.envvalue (overrides bucket). - If bucket credentials are missing, load
.envonly (standard dotenv behavior).
Argus app lock vs sign-out
| State | IPC |
|---|---|
| Signed in, idle app lock | Works — approval popup may appear for new clients |
| Signed out | Returns locked — use fallback_on_locked=True to load .env only |
Idle app lock does not block IPC. Only sign-out returns IPC locked.
First run
The first time a process connects, Argus shows an access approval dialog (up to ~120s). Later requests use the grant TTL from bucket settings.
API
load_env(...)
from useargus import load_env
result = load_env(
path=".env", # default: .env in cwd
override=False, # dotenv-only mode: don't override existing OS env
timeout_ms=130_000, # IPC timeout
fallback_on_locked=False, # if signed out, load .env instead of raising
)
# result.source == "bucket" | "dotenv"
# result.keys — names set (never values)
fetch_bucket_env(...)
Lower-level IPC call if you only need the bucket map:
import os
from useargus import fetch_bucket_env
env = fetch_bucket_env(
bucket_id=os.environ["ARGUS_BUCKET_ID"],
client_token=os.environ["ARGUS_BUCKET_TOKEN"],
)
Errors
| Error | When |
|---|---|
ArgusConnectionError |
Socket missing, Argus not running |
ArgusLockedError |
Argus signed out (status: locked) |
ArgusDeniedError |
User denied or approval timed out |
ArgusError |
Invalid token, bad request, etc. |
Development
python -m venv .venv
# Windows: .venv\Scripts\activate
# macOS/Linux: source .venv/bin/activate
pip install -e ".[dev]"
ruff check .
mypy useargus
pytest
python -m build
Publish
Publishing is manual via GitHub Actions (adding PYPI_TOKEN alone does not publish).
- Add repository secret
PYPI_TOKEN(PyPI API token with publish rights). - Go to Actions → Publish to PyPI → Run workflow.
- Enter the version (e.g.
0.1.0orv0.1.0).
The workflow runs CI, sets pyproject.toml version, publishes to PyPI, tags v<version>, and creates a GitHub release.
Publish locally (optional)
pip install -e ".[dev]"
python -m build
twine upload dist/*
License
MIT
Project details
Release history Release notifications | RSS feed
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 useargus-0.1.0.tar.gz.
File metadata
- Download URL: useargus-0.1.0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
665ae3794a4b1a3ad869a4a34389c5b7e309c22ad7c7781c53d8d9206f1cab4b
|
|
| MD5 |
e15abc0c2b3f99e75b6480724e69f828
|
|
| BLAKE2b-256 |
70957400194a585f52c563de4faf2af9a9a816ab21290792da90dcce26fa7f93
|
File details
Details for the file useargus-0.1.0-py3-none-any.whl.
File metadata
- Download URL: useargus-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03033d5ab8ec21d0208944b3ce098d143def4b3d936d68b5c950381fb0f8f80f
|
|
| MD5 |
bb591bfd720a475c1deb81eefab2a1e2
|
|
| BLAKE2b-256 |
a654c1b8c7f417ae4c4ecf0eeebbf5fca316a0ae5a14c30701f6d0bf6e2ee2f1
|