print-env
CLI to print environment variables from supported sources.
This is derived from projects that:
- Use environment variables as the main interface for configuration
- Use source-control ignored files to store environment variables for scenarios such as local development
Install
$ pipenv install print-env
# or
$ pip install print-env
Usage
Assume a .env file that contains the following content:
# .env
FLASK_APP=app.py
FLASK_DEBUG=1
SQL_URI=<SQL connection string that may contain credentials>
# and more...
Then simply
$ print-env
FLASK_APP=app.py FLASK_DEBUG=1 SQL_URI=<redacted> # and more...
The above would print out environment variables stored in .env, or env.yml, or env.json (roughly attempted in this order). You can also exclusively specify the file:
$ print-env /path/to/env/file.yml
and the script would attempt to parse the file based on its extension given. Note that any file extension that is not of YAML or JSON type is attempted as a dotenv file.
In fact, you can specify a series of files. Note that in case of duplicates, the last files take precedence, for example:
# content of base.env
LOG_LVL=warning
API_TOKEN=aabbcc
# content of dev.env
LOG_LVL=debug
$ print-env base.env dev.env
LOG_LVL=debug API_TOKEN=aabbcc
Another common case is when an external file is used to supply environment variables at deploy-time, for example, when used with the serverless framework with a serverless.yml that may look like:
service: env-vars
package:
exclude:
- node_modules/**
- '*env.yml'
- Pipefile
- Pipfile.lock
functions:
test:
# test.py - handler()
handler: test.handler
# sourcing env vars from ./env.yml
environment: ${file(./env.yml):}
and for local test runs you can utilize print-env to reuse the same env.yml:
$ env $(print-env) python test.py # omitted file path since env.yml is on the default try-list
Similarly, print-env can be used for build-time configuration. For example, with an imaginary client-side project with a package.json that may look like:
{
"name": "TestApp",
"version": "1.0.1",
"scripts": {
"build": "env $(print-env local-env.json) parcel build index.html",
"build:dev": "env $(print-env dev-env.json) parcel build index.html",
"build:prod": "env $(print-env prod-env.json) parcel build index.html"
}
}
Metadata
Release files for print-env 2.3.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 | Provenance | Actions |
|---|---|---|---|---|
| print-env-2.3.0.tar.gz | 7.4 kB | Without provenance | Details for print-env-2.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| print_env-2.3.0-py3-none-any.whl | Python 3 | none | any | Details for print_env-2.3.0-py3-none-any.whl |
Total release size: 16.0 kB
Release files / print-env-2.3.0.tar.gz
| Download URL | print-env-2.3.0.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7a787aabc2c34c0fb3bb3b2353d32b97596b25a9606a1a793e0abb255de1fa19
|
|
BLAKE2b-256 checksum How to use checksums |
09737d7fc297c8f82d2b13f9c26ea7d1cec418d4156fcd053422060ec02470e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Release files / print_env-2.3.0-py3-none-any.whl
| Download URL | print_env-2.3.0-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9f5618573f4de7449ededaac31bb4b7466688fa7bec22c5655190f5234057f6c
|
|
BLAKE2b-256 checksum How to use checksums |
2882c83c81d1729b2ca6e67e86f9a6830888cfc4f1f49469017ca38f64d21e5e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Security for print-env 2.3.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.