org.slashlib.py.configloader
A lightweight, JSON-based configuration manager for Python projects. It automatically locates your project root, resolves nested placeholders, injects environment variables, and manages system paths.
Features
- Root Discovery: Automatically finds the project root based on a marker file (default:
pyproject.json). - Placeholder Resolution: Supports recursive interpolation of settings using the
{path.to.key}syntax. - Environment Injection: Automatically sets environment variables defined in the configuration.
- Path Management: Dynamically updates the system
PATHand registers DLL directories (Windows). - Asset Helper: Built-in utility to read mandatory file assets defined in your config.
- [[docs|Developer Documentation]]
Installation
Install the package (maybe in editable mode: -e) within your project directory. This will automatically resolve and install the required dependencies:
pip install .
Configuration Example (pyproject.json)
{
"env": {
"path": [
"./bin",
"./tools/external"
],
"dllpath": [
"./libs/native"
],
"vars": {
"DATABASE_URL": "postgres://user:pass@localhost/db",
"LOG_LEVEL": "DEBUG"
}
},
"paths": {
"data_dir": "{ROOT}/data",
"raw_files": "{paths.data_dir}/raw"
},
"assets": {
"schema": "./assets/schema.sql"
}
}
Usage
The ConfigLoader follows a "setup-and-forget" philosophy. Upon import, the library automatically creates a singleton instance that handles root discovery, placeholder resolution, and environment injection.
import logging
import org.slashlib.py.configloader
# 1. Automatic Initialization
# The 'configloader' is already initialized and has processed your 'pyproject.json'.
# Environment variables and PATH/DLL paths are already updated.
# 2. Optional: Setup Logging
# Uses the 'assets.logging' path from your JSON to initialize colorlog/logging.
# Defaults to "assets.logging" if no path is provided.
org.slashlib.py.configloader.setup_logging()
# 3. Access the processed configuration
# Placeholders like {ROOT} or {paths.data_dir} can be resolved.
data_dir = org.slashlib.py.configloader.config['paths']['data_dir']
# 4. Use the Resolve Helper (Recommended)
# Safely access nested nodes with dot-notation and optional default values.
db_port = org.slashlib.py.configloader.resolve("env.vars.DATABASE_PORT", default=5432)
# 5. Use the Asset Helper
# Conveniently read file contents using keys defined in your 'assets' section.
schema_content = org.slashlib.py.configloader.read_asset("schema")
# 6. Native Integration
# Environment variables are already accessible via the standard 'os' module.
import os
print(f"Database URL: {os.environ.get('DATABASE_URL')}")
# 7. Logging is ready to use
logger = logging.getLogger(__name__)
logger.info("Application started successfully.")
Requirements
- Python 3.8+
- Dependencies:
colorlog: Used for optional colored console output insetup_logging().
Documentation & Obsidian
The project root is pre-configured as an Obsidian Vault. If you open this folder directly in Obsidian, all settings and documentation links will be available immediately via the included .obsidian directory.
The following community plugins are pre-configured in the vault to enhance the documentation experience:
- File Include: Embed code files directly into your markdown documentation.
- Folder Notes: Add descriptions at the folder level.
- Front Matter Title: Use metadata for descriptive file titles.
- Hide Folders: Keeps the structure clean by hiding internal directories.
- Iconic & Icons: Improved visual navigation.
License
This project is licensed under the MIT License - see the LICENSE file for details.
© 2026 org.slashlib
Metadata
Release files for org.slashlib.py.configloader 0.1.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 | |
|---|---|---|---|
| org_slashlib_py_configloader-0.1.0.tar.gz | 11.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| org_slashlib_py_configloader-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.8 kB
Release files / org_slashlib_py_configloader-0.1.0.tar.gz
| Download URL | org_slashlib_py_configloader-0.1.0.tar.gz |
|---|---|
| Size | 11.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9bb0aca53f2d10cdea721220264d9700812d5c3af4735dde2304226ca91ca93a
|
|
BLAKE2b-256 checksum How to use checksums |
49c3c1f244c02805f1ae3311cbb8fe659cb58359583e7c5b80a4df5415851dab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.6
|
Release files / org_slashlib_py_configloader-0.1.0-py3-none-any.whl
| Download URL | org_slashlib_py_configloader-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f2ed2e300394a60b2090f8b51644a957f09dc4088bb535724f2fa98c5a54813f
|
|
BLAKE2b-256 checksum How to use checksums |
610bb7346b802c927822fb6a2e0659a9ad5be052f477b0501d75089b058a8d0a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.6
|