Registry / serialization / pyconfigurator

pyconfigurator

JSON →
library0.4.19pypypi✓ verified 87d ago

pyconfigurator is a Python library designed for easy and flexible configuration management, supporting INI files, environment variables, command-line arguments, and directories. It provides a simple attribute-based access API to configuration values. The current version is 0.4.19, with a release cadence that is infrequent, focusing on compatibility and minor fixes.

pip install pyconfigurator
INSTALL
IMPORT
SIG · PYCONFIGURATOR
P
pyconfigurator
serializationpythonv0.4.19
Install
1.8s avg
Import
68ms
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.4.19 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.071s · 21.8MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.8s · import 0.065s · 22MB
20MB installed
● package 20MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Configurator
from configurator import Configurator
from pyconfigurator import Configurator
The package is named 'pyconfigurator' for PyPI, but the primary module is 'configurator'.

This quickstart demonstrates how to initialize `Configurator` with an INI file and environment variables, then access configuration settings using attribute-style access. It highlights environment variable substitution and default values.

import os from configurator import Configurator # 1. Create a dummy configuration file config_file_path = 'my_app_config.ini' with open(config_file_path, 'w') as f: f.write('[default] app_name=MyApplication data_path=/var/data log_level=${LOG_LEVEL_ENV:INFO} [database] host=localhost port=5432 user=admin password=${DB_PASSWORD_ENV:secret}') # 2. Set environment variables (optional, for demonstration) os.environ['LOG_LEVEL_ENV'] = 'DEBUG' # os.environ['DB_PASSWORD_ENV'] = 'super_secret' # 3. Initialize the Configurator # It loads files, then environment variables, then CLI args (if any) config = Configurator( files=[config_file_path], environ=os.environ, # Pass os.environ to enable env var substitution # cli_args=['--database-user', 'cli_user'] # Example for CLI overrides ) # 4. Access configuration values print(f"Application Name: {config.default.app_name}") print(f"Data Path: {config.default.data_path}") print(f"Log Level: {config.default.log_level}") print(f"Database Host: {config.database.host}") print(f"Database User: {config.database.user}") print(f"Database Password: {config.database.password}") # Clean up the dummy file os.remove(config_file_path)
pyconfigurator --version
Debug
Known issues
gotchaThe package name is `pyconfigurator` but the import path for the main class is `from configurator import Configurator`. Importing `from pyconfigurator import Configurator` will result in a `ModuleNotFoundError`.
fix
Always use `from configurator import Configurator`.
affects: All versions
gotchaOrder of precedence for configuration sources matters. `pyconfigurator` loads files first, then applies environment variable substitutions/overrides, and finally command-line argument overrides. Be aware that later sources can overwrite values from earlier ones.
fix
Understand the loading order: files -> environment variables -> command-line arguments. Structure your configuration accordingly to ensure the correct values are applied.
affects: All versions
gotchaStarting with v0.4.19, `pyconfigurator` switched its internal parser implementation away from `SafeConfigParser`. While the public API (`Configurator`) remains stable, any code that directly interacted with or relied on specific internal behaviors of `SafeConfigParser` through private attributes might encounter issues.
fix
Avoid relying on `pyconfigurator`'s internal implementation details. Only interact with the documented public API of the `Configurator` object.
affects: >=0.4.19
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'configurator'
Attempting to import `Configurator` from `pyconfigurator` instead of `configurator`.
fix
Change your import statement from `from pyconfigurator import Configurator` to `from configurator import Configurator`.
AttributeError: 'Configurator' object has no attribute 'some_missing_key'
Attempting to access a configuration key that does not exist in any loaded configuration source.
fix
Ensure the key exists in your configuration files, environment variables, or CLI arguments. You can check for existence using `if 'some_key' in config.section:` or provide default values during access if the library supports it (though direct attribute access usually doesn't).
FileNotFoundError: [Errno 2] No such file or directory: 'non_existent.ini'
One of the files specified in the `files` argument to `Configurator` does not exist at the given path.
fix
Verify that all file paths provided to `Configurator(files=...)` are correct and the files actually exist. Use absolute paths or ensure your relative paths are correct from the execution directory.
Upgrade
Version history
0.4.19latest on PyPI · released May 6, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
pyconfigurator — pip install pyconfigurator · libregistry