Python tool to generate environment variables from schemas
Project description
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.
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 pyenvgen-0.2.0.tar.gz.
File metadata
- Download URL: pyenvgen-0.2.0.tar.gz
- Upload date:
- Size: 11.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 |
6b7ad9a1cf70faeea99fdbc3fd112893936539e190081921e16c68a46356bbba
|
|
| MD5 |
a56a3f0c1019886853d712906cb5d766
|
|
| BLAKE2b-256 |
ecfea040d5b7791871e9cbe7ffaf800f9e337858f59aac4a48866ecf08cddd11
|
Provenance
The following attestation bundles were made for pyenvgen-0.2.0.tar.gz:
Publisher:
publish-to-pypi.yml on bastienlc/pyenvgen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyenvgen-0.2.0.tar.gz -
Subject digest:
6b7ad9a1cf70faeea99fdbc3fd112893936539e190081921e16c68a46356bbba - Sigstore transparency entry: 976361609
- Sigstore integration time:
-
Permalink:
bastienlc/pyenvgen@2317b91bb908f7c826b78a57ab3f64281fae9e19 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/bastienlc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@2317b91bb908f7c826b78a57ab3f64281fae9e19 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyenvgen-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pyenvgen-0.2.0-py3-none-any.whl
- Upload date:
- Size: 19.0 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 |
024617ebb51707081e41e2b2b7ec5d8332e283fdb2f800084a53f50083a843cc
|
|
| MD5 |
ac310a8f6c067eb9e4a0ff31be6a84f0
|
|
| BLAKE2b-256 |
027e716eac2158488b2d71f1d427f0dd6b19ece01f878d6ebd355f6d7a642826
|
Provenance
The following attestation bundles were made for pyenvgen-0.2.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on bastienlc/pyenvgen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyenvgen-0.2.0-py3-none-any.whl -
Subject digest:
024617ebb51707081e41e2b2b7ec5d8332e283fdb2f800084a53f50083a843cc - Sigstore transparency entry: 976361611
- Sigstore integration time:
-
Permalink:
bastienlc/pyenvgen@2317b91bb908f7c826b78a57ab3f64281fae9e19 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/bastienlc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@2317b91bb908f7c826b78a57ab3f64281fae9e19 -
Trigger Event:
push
-
Statement type: