Python Application Configuration. Py-config organizes hierarchical configurations for your app deployments.
Usage
Installation
pip install py-app-config
Best Practice
Firstly, you should have a config folder under the codebase of your application, like this:
.
├── config
│ ├── __init__.py
│ ├── default.json
│ ├── development.json
│ ├── production.json
│ └── test.json
.
Secondly, set environment variable PY_ENV to one of the names of JOSN files in the config folder, and it defaults to be development.
In your __init__.py under config folder, these codes can be used:
import os
from py_config import set_config_dir, get_config
config_dir = os.path.abspath(os.path.dirname(__file__))
set_config_dir(config_dir)
config = get_config()
Then, you can use from config import config to import your app config in any other places in you codebase.
The final config would merge default.json and <PY_ENV>.json. See dict-recursive-update for the recursive update rules.
APIs
# Set the config directory path
set_config_dir(
config_dir=None # Directory path of `config` folder
)
# Get final config according to the `config_dir`.
# It should be executed every time after a new `config_dir` is set.
get_config()
Relatives
License
Metadata
Release files for py-app-config 1.0.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 |
|---|---|---|---|---|
| py-app-config-1.0.0.tar.gz | 2.7 kB | Without provenance | Details for py-app-config-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| py_app_config-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for py_app_config-1.0.0-py3-none-any.whl |
Total release size: 7.6 kB
Release files / py-app-config-1.0.0.tar.gz
| Download URL | py-app-config-1.0.0.tar.gz |
|---|---|
| Size | 2.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
caf679cc3338a3c767925dcf15168b73e8a04f2407817904f2b4dd952f0a2df0
|
|
BLAKE2b-256 checksum How to use checksums |
5a140bee1d4aec62434064347fefa93e1c50cd98ec977e321aa71201f02a6643
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / py_app_config-1.0.0-py3-none-any.whl
| Download URL | py_app_config-1.0.0-py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
21678da979ee5e42703f175b53df73b4f807a1923dfb2f1f692b653b79f2bd25
|
|
BLAKE2b-256 checksum How to use checksums |
1a9612d273ab1e62aae7ccc54a6d329188ced6dffac44bd9ca4dec1930219958
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for py-app-config 1.0.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.