pyenvgen
Warning: This project was vibe coded and is in early development. Expect breaking changes and incomplete features. Contributions are welcome!
Python tool to generate environment variables from YAML schemas.
- Define variables in a YAML schema, including types, generation rules, and validation constraints.
- Existing values are loaded from the chosen storage backend.
- Values are generated (with existing/overridden values taking precedence), then validated.
- The final environment is written back to the storage backend.
Installation
pip install pyenvgen
Usage
pyenvgen <schema.yaml> [-s STORAGE] [-b BACKEND] [-o KEY=VALUE ...] [--force]
| Flag | Description |
|---|---|
-s, --storage |
Storage (default: stdout), path to a file to store output to. |
-b, --backend |
Storage backend, when the file extension is ambiguous (e.g. komodo vs toml backend). |
-o, --override |
Override a value via KEY=VALUE (repeatable) |
--force |
Regenerate all values, ignoring existing stored values |
# Print to stdout
pyenvgen examples/basic.yaml
# Write to a .env file
pyenvgen examples/basic.yaml -s .env
# Override a value
pyenvgen examples/basic.yaml -o APP_PORT=9000
Schema format
variables:
MY_VAR:
type: str # str | int | float | bool (default: str)
description: "..."
internal: false # default: false
generation:
rule: default
value: "hello"
validation:
length:
min: 1
max: 128
Variable types
str, int, float, bool
Generation rules
All string fields in generation rules are rendered as Jinja2 templates against already-generated values before execution.
default– use a static value (supports Jinja2, e.g."postgres://{{ HOST }}:{{ PORT }}/app")command– run a shell command and capture its stdoutopenssl– generate cryptographic material via thecryptographypackage
openssl commands
| Command | Description | Key args |
|---|---|---|
rsa |
RSA private key (PEM or DER base64) | key_size (default 2048), encoding (pem|der_b64) |
ec |
EC private key | curve (secp256r1|secp384r1|secp521r1|secp256k1), encoding (pem|der_b64) |
ed25519 |
Ed25519 private key | encoding (pem|raw_b64) |
x25519 |
X25519 private key | encoding (pem|raw_b64, default raw_b64) |
fernet |
URL-safe base64 Fernet key | — |
random |
Random bytes | length (default 32), encoding (hex|base64|base64url) |
Validation rules
Backed by marshmallow.
| Rule | Applies to | Fields |
|---|---|---|
length |
str |
min, max |
range |
int, float |
min, max, min_inclusive, max_inclusive |
one_of |
any | choices: [...] |
regexp |
any | pattern |
Storage backends
| Value | Description |
|---|---|
stdout |
Print to standard output |
.env |
Read/write a .env file |
json |
Read/write a JSON file |
toml |
Read/write a TOML file |
yaml |
Read/write a YAML file |
komodo |
Read/write a Komodo-style TOML |
Special properties
internal: true– the variable is generated and available to Jinja2 templates but excluded from the output.
Metadata
Release files for pyenvgen 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyenvgen-0.4.0.tar.gz | 12.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyenvgen-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.4 kB
Release files / pyenvgen-0.4.0.tar.gz
| Download URL | pyenvgen-0.4.0.tar.gz |
|---|---|
| Size | 12.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c978204832b2c110d0435a0671b7be4342927ed1be681b335a0135f4a3e08db1
|
|
BLAKE2b-256 checksum How to use checksums |
38b2fcfcf724d6db277bfc4349a5e46eaa62fa92d8a84fb0f640c4341adc7d85
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 22, 2026.
Transparency logRelease files / pyenvgen-0.4.0-py3-none-any.whl
| Download URL | pyenvgen-0.4.0-py3-none-any.whl |
|---|---|
| Size | 19.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
94719a1b0010067df7425d0ae9cec757ab3fde7b0d49def87068562b6181260f
|
|
BLAKE2b-256 checksum How to use checksums |
7a9734d8d7b3ad665afae84c1e9527c251f16d4dd5bc9891ddf6cf5f2a1ee0a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 22, 2026.
Transparency log