Simple, flexible, and secure settings management for Python.
Project description
Three ways to use your settings, guaranteed to work the way you’ve always just wanted!
Simply set and get in sfs-settings itself
Simply set and get in the calling module
Simply use it for your own settings pattern
Full documentation is available here.
Requirements
Python 3.11+
Poetry 1.9+
Pydantic 2.0+
keyring = “^25.0.0”
dotenv = “^0.9.0”
How to use
Set and get in sfs-settings itself
import sfs_settings as sfs
sfs.track_env_var("URL", str)
sfs.track_secret_var("API_KEY", str)
print(sfs.URL)
print(sfs.API_KEY)
Do use this if:
You’re an end application only and don’t need to combine settings obtained from multiple sources.
Don’t use this if:
You’re a re-usable module.
Need to combine settings obtained from multiple sources.
Set and get in the calling module
from sfs_settings import set_env_var_locally, set_secret_var_locally
set_env_var_locally("URL", str)
set_secret_var_locally("API_KEY", str)
print(URL)
print(API_KEY)
Do use this if:
You’re an end application only and don’t need to combine settings obtained from multiple sources.
You’re a re-usable module.
Don’t use this if:
Need to combine settings obtained from multiple sources.
Use it for your own settings pattern
from sfs_settings import return_env_var, return_secret_var
URL: str = return_env_var("URL", str)
API_KEY: str = return_secret_var("API_KEY", str)
print(URL)
print(API_KEY)
Do use this if:
You’re an end application only and don’t need to combine settings obtained from multiple sources.
You’re a re-usable module.
Need to combine settings obtained from multiple sources.
Don’t use this if:
You can use a simpler pattern above.
.env support
sfs-settings supports .env files! It automatically loads them from the current working directory. If you need to have easy swapping between development, local, testing, cloud, and other configurations then swapping .env files is a great way to do it.
per-user application settings
sfs-settings does not yet support keeping settings somewhere in ~/.config/… We’re working on it.
debugging support?
It’s kinda complicated inside sfs-settings actually. So when if you’re using a more complicated setup and things seem a little too magical? It isn’t implemented yet, but it is on the roadmap to add a DEBUG mode.
No downtime to atomically change settings? Transaction locks incoming!
While not here yet, sfs-settings will support transaction locks so that you don’t need to stop your container or VM in order to guarantee correct settings at all times. So, how do you feel about sub-millisecond not even downtime, but pauses? We think that they’re just swell!
When it lands, you’ll be able to do something like this:
export sfs_settings_TRANSACTION_LOCK="*"
export MY_SETTING_ONE="Hello"
export MY_SETTING_TWO="World"
unset sfs_settings_TRANSACTION_LOCK
Just remember that these will ONLY work for settings which have reobtain_each_usage=True!
Looking for something with more nuance than ‘halt everything’? We’ve got you covered! See the specific for transactional locks documentation for more details.
Integrations
sfs-settings does its best to promote 12-factor app principles. This means that it does its best to integrate with other modules which do the same. Here are some of the integrations it supports:
keyring backends
keyring, the python module for integrating with system password managers like Windows Credential Manager, macOS Keychain, and GNOME Keyring, is supported by this module. However, not all backends are supported out of the box, particularly for cloud deployments. If you need support for additional backends, more can be found at the keyring pypi page <https://pypi.org/project/keyring/>. For examples on how to use these additional backends, please review the backend configuration guide.
.env support
sfs-settings supports .env files! It automatically loads them from the current working directory. If you need to have easy swapping between development, local, testing, cloud, and other configurations then swapping .env files is a great way to do it. Examples of how to use .env files can be found in the environment variables guide.
Build
poetry build
Test
poetry run nox
Build Documentation
poetry run sphinx-build -b html docs/source docs/build/html
License
MIT <LICENSE>
Contributing, bug reports, and support
The jist is that you should use the github issue tracker to report bugs and feature requests. If you’re interested in contributing, please see the CONTRIBUTING.rst file for more information.
All PRs must be signed and maintain 100% test coverage.
Please see the Code of Conduct <CODE_OF_CONDUCT.rst> and the Contributing requirements <CONTRIBUTING.rst> for more information.
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 sfs_settings-0.9.1.tar.gz.
File metadata
- Download URL: sfs_settings-0.9.1.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f2560ba15dd350bc545aaf4c44cd4fb1408501d9a9ece952518767934a6f6cb
|
|
| MD5 |
48299e2ab9d835110fc5f25f976f602c
|
|
| BLAKE2b-256 |
b5cb07ba6530bfef24ad1d75e75a63a77c9d432919fd179ad5d979fd642cc34d
|
Provenance
The following attestation bundles were made for sfs_settings-0.9.1.tar.gz:
Publisher:
pypi_publish.yml on anadon/sfs-settings
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sfs_settings-0.9.1.tar.gz -
Subject digest:
1f2560ba15dd350bc545aaf4c44cd4fb1408501d9a9ece952518767934a6f6cb - Sigstore transparency entry: 200315932
- Sigstore integration time:
-
Permalink:
anadon/sfs-settings@db358a069d38c93a7758f5b4496dabee4af1d211 -
Branch / Tag:
refs/tags/v0.9.2 - Owner: https://github.com/anadon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi_publish.yml@db358a069d38c93a7758f5b4496dabee4af1d211 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sfs_settings-0.9.1-py3-none-any.whl.
File metadata
- Download URL: sfs_settings-0.9.1-py3-none-any.whl
- Upload date:
- Size: 9.7 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 |
fdf0eee5eb1b6a23b8fe2dfa3bd7a85f9a3131e7efcd41bb5c3a6f1c2f4a2439
|
|
| MD5 |
2e45f7a7f5edce703462d80ed48dd9a7
|
|
| BLAKE2b-256 |
bb75be69594cd30154f9189aeca31655f4e412019584b354c1e8f66898c6715d
|
Provenance
The following attestation bundles were made for sfs_settings-0.9.1-py3-none-any.whl:
Publisher:
pypi_publish.yml on anadon/sfs-settings
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sfs_settings-0.9.1-py3-none-any.whl -
Subject digest:
fdf0eee5eb1b6a23b8fe2dfa3bd7a85f9a3131e7efcd41bb5c3a6f1c2f4a2439 - Sigstore transparency entry: 200315934
- Sigstore integration time:
-
Permalink:
anadon/sfs-settings@db358a069d38c93a7758f5b4496dabee4af1d211 -
Branch / Tag:
refs/tags/v0.9.2 - Owner: https://github.com/anadon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi_publish.yml@db358a069d38c93a7758f5b4496dabee4af1d211 -
Trigger Event:
push
-
Statement type: