1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
|
Metadata-Version: 2.1
Name: dynaconf
Version: 3.1.7
Summary: The dynamic configurator for your Python Project
Home-page: https://github.com/rochacbruno/dynaconf
Author: Bruno Rocha
Author-email: rochacbruno@gmail.com
License: MIT
Platform: any
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: Django
Classifier: Framework :: Flask
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Utilities
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Provides-Extra: redis
Provides-Extra: vault
Provides-Extra: yaml
Provides-Extra: toml
Provides-Extra: ini
Provides-Extra: configobj
Provides-Extra: all
License-File: LICENSE
[](http://dynaconf.com)
> **dynaconf** - Configuration Management for Python.
[](/LICENSE) [](https://pypi.python.org/pypi/dynaconf) []()  [](https://github.com/rochacbruno/dynaconf/actions/workflows/main.yml) [](https://codecov.io/gh/rochacbruno/dynaconf) [](https://www.codacy.com/gh/rochacbruno/dynaconf/dashboard?utm_source=github.com&utm_medium=referral&utm_content=rochacbruno/dynaconf&utm_campaign=Badge_Grade)      [](https://github.com/ambv/black/) [](https://github.com/rochacbruno/dynaconf/discussions) [](https://github.com/rochacbruno/learndynaconf)
[](https://xscode.com/rochacbruno/dynaconf)
## Features
- Inspired by the [12-factor application guide](https://12factor.net/config)
- Settings management (default values, validation, parsing, templating)
- Protection of sensitive information (passwords/tokens)
- Multiple file formats `toml|yaml|json|ini|py` and also customizable loaders.
- Full support for environment variables to override existing settings (dotenv support included).
- Optional layered system for multi environments `[default, development, testing, production]`
- Built-in support for Hashicorp Vault and Redis as settings and secrets storage.
- Built-in extensions for **Django** and **Flask** web frameworks.
- CLI for common operations such as `init, list, write, validate, export`.
- full docs on https://dynaconf.com
## Quick start
> **DEMO:** You can see a working demo here: https://github.com/rochacbruno/learndynaconf
### Install
```bash
$ pip install dynaconf
```
#### Initialize Dynaconf on project root directory
```plain
$ cd path/to/your/project/
$ dynaconf init -f toml
⚙️ Configuring your Dynaconf environment
------------------------------------------
🐍 The file `config.py` was generated.
🎛️ settings.toml created to hold your settings.
🔑 .secrets.toml created to hold your secrets.
🙈 the .secrets.* is also included in `.gitignore`
beware to not push your secrets to a public repo.
🎉 Dynaconf is configured! read more on https://dynaconf.com
```
> **TIP:** You can select `toml|yaml|json|ini|py` on `dynaconf init -f <fileformat>` **toml** is the default and also the most recommended format for configuration.
#### Dynaconf init creates the following files
```plain
.
├── config.py # This is from where you import your settings object (required)
├── .secrets.toml # This is to hold sensitive data like passwords and tokens (optional)
└── settings.toml # This is to hold your application setttings (optional)
```
On the file `config.py` Dynaconf init generates the following boilerpate
```py
from dynaconf import Dynaconf
settings = Dynaconf(
envvar_prefix="DYNACONF", # export envvars with `export DYNACONF_FOO=bar`.
settings_files=['settings.yaml', '.secrets.yaml'], # Load files in the given order.
)
```
> **TIP:** You can create the files yourself instead of using the `init` command as shown above and you can give any name you want instead of the default `config.py` (the file must be in your importable python path) - See more options that you can pass to `Dynaconf` class initializer on https://dynaconf.com
#### Using Dynaconf
Put your settings on `settings.{toml|yaml|ini|json|py}`
```toml
username = "admin"
port = 5555
database = {name='mydb', schema='main'}
```
Put sensitive information on `.secrets.{toml|yaml|ini|json|py}`
```toml
password = "secret123"
```
> **IMPORTANT:** `dynaconf init` command puts the `.secrets.*` in your `.gitignore` to avoid it to be exposed on public repos but it is your responsibility to keep it safe in your local environment, also the recommendation for production environments is to use the built-in support for Hashicorp Vault service for password and tokens.
Optionally you can now use environment variables to override values per execution or per environment.
```bash
# override `port` from settings.toml file and automatically casts as `int` value.
export DYNACONF_PORT=9900
```
On your code import the `settings` object
```py
from path.to.project.config import settings
# Reading the settings
settings.username == "admin" # dot notation with multi nesting support
settings.PORT == 9900 # case insensitive
settings['password'] == "secret123" # dict like access
settings.get("nonexisting", "default value") # Default values just like a dict
settings.databases.name == "mydb" # Nested key traversing
settings['databases.schema'] == "main" # Nested key traversing
```
## More
- Settings Schema Validation
- Custom Settings Loaders
- Vault Services
- Template substitutions
- etc...
There is a lot more you can do, **read the docs:** http://dynaconf.com
## Contribute
Main discussions happens on [t.me/dynaconf](https://t.me/dynaconf) learn more about how to get involved on [CONTRIBUTING.md guide](CONTRIBUTING.md)
## more
If you are looking for something similar to Dynaconf to use in your Rust projects: https://github.com/rubik/hydroconf
|