Easy to manage Config variables separate from App code. Useful while developing and deploying( CI/CD) django web-apps
Project description
dynamic-config
Project configuration variables are declared beforehand and inferred from environment variables or configuration files. Useful while developing and deploying( CI/CD) django web-apps
Install
pip install dynamic-conf
Features
- supports
.envor.pyfiles - supports casting with type annotations
- You also don't need to include a sample file. Since the
Configobject would be able to generate.env.pyitself. - It also loads Configuration variables from environment variables.
The order of preference is
env variables>env.py - Attributes are lazily evaluated.
Getting Started
- You need to subclass the
Configclass. - The config file should define all the variables needed for a project.
# project/conf.py
from dynamic_conf import Config
class CONFIG(Config):
"""singleton to be used for configuring from os.environ and env.py"""
SECRET_KEY:str # required value
# default settings
ENV = "prod" # optional field with a default value
DB_NAME = "db"
DB_HOST = "127.0.0.1"
DB_USER = "postgres"
DB_PASS = None # even None could be given as default value
- to create
project/env.pyjust run with the path to CONFIG class's module
# you could pass environment variables or set already with export
env DB_PASS='123' dynamic-conf project/conf.py
dynamic-conf project/conf.py DB_USER='user-1' DB_PASS='123' # pass as list of key-value pair
#to filter environment variables with a prefix
env VARS_PREFIX="PROD_" dynamic-conf project/conf.py PROD_DB_USER="user-2"
Usage
- To use the config simply import and use particular attribute
# project/settings.py
from conf import CONFIG
DATABASES = {
"default": {
"ENGINE": "django.contrib.gis.db.backends.postgis",
"HOST": CONFIG.DB_HOST,
"NAME": CONFIG.DB_NAME,
"USER": CONFIG.DB_USER,
"PASSWORD": CONFIG.DB_PASSWORD,
"PORT": "5432",
}
}
New release
- create a new release from Github web interface. The package is published to PyPI using Github Actions.
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 dynamic_conf-1.1.0.tar.gz.
File metadata
- Download URL: dynamic_conf-1.1.0.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6cbfd22b483a3a411fab2aaedb594bc0bd38dbbf4be9a57edab38983850009c
|
|
| MD5 |
206d42a07feae82e1f518be901950137
|
|
| BLAKE2b-256 |
91ef2d995e338f0eec9ed5ca8b9308d4d9c4464ff1d685c2b283bde56d550656
|
Provenance
The following attestation bundles were made for dynamic_conf-1.1.0.tar.gz:
Publisher:
release.yml on jnoortheen/dynamic-conf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dynamic_conf-1.1.0.tar.gz -
Subject digest:
e6cbfd22b483a3a411fab2aaedb594bc0bd38dbbf4be9a57edab38983850009c - Sigstore transparency entry: 180349459
- Sigstore integration time:
-
Permalink:
jnoortheen/dynamic-conf@d7e948b7c4c959750b0230768eef7a735cd4c8ac -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/jnoortheen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d7e948b7c4c959750b0230768eef7a735cd4c8ac -
Trigger Event:
push
-
Statement type:
File details
Details for the file dynamic_conf-1.1.0-py3-none-any.whl.
File metadata
- Download URL: dynamic_conf-1.1.0-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
540b995717e6fb62b94e8f97835045ca987fb5448f93ab0a86b145937f4243f8
|
|
| MD5 |
4fffcc37b3d2e773950b4092e4a1d307
|
|
| BLAKE2b-256 |
0fdcd20e92df2b9276a736a8451878ba9e37cbb0f2783460607895ae3bda44c0
|
Provenance
The following attestation bundles were made for dynamic_conf-1.1.0-py3-none-any.whl:
Publisher:
release.yml on jnoortheen/dynamic-conf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dynamic_conf-1.1.0-py3-none-any.whl -
Subject digest:
540b995717e6fb62b94e8f97835045ca987fb5448f93ab0a86b145937f4243f8 - Sigstore transparency entry: 180349460
- Sigstore integration time:
-
Permalink:
jnoortheen/dynamic-conf@d7e948b7c4c959750b0230768eef7a735cd4c8ac -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/jnoortheen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d7e948b7c4c959750b0230768eef7a735cd4c8ac -
Trigger Event:
push
-
Statement type: