This release is a pre-release and may not be stable for production use.
Aperol Config
Aperol is a featherweight framework for configuration of Python objects based on dependency injection.
Usage
Requires Python >= 3.10.
Install Aperol from PyPI:
$ pip install aperol
Define a basic configuration file dummy.yaml:
imports:
- random
a: -1
b.type: math.pi
c.type: uniform
d:
type: uniform()
a: 10
b: 11
Python objects are specified by the type keyword.
In the example above, uniform is resolved to the random module specified in the imports section.
On the other hand, pi is explicitly imported
from the math module.
Load the config file using Aperol and use the configured objects:
>>> import random
>>> random.seed(0) # seed set for reproducibility
>>> import aperol
>>> configured = aperol.parse_config("dummy.yaml")
>>> configured["a"]
-1
>>> configured["b"]
3.141592653589793
>>> configured["c"]
_DelayedConstructor(factory=<bound method Random.uniform of <random.Random object at ...>>, init=False, kwargs={'a': -1, 'b': 3.141592653589793})
>>> configured["d"]
10.844421851525048
>>> uniform = configured["c"]
>>> uniform()
2.1391383869735945
>>> uniform()
0.7418361694776736
Package imports can be specified in one of three ways:
- Within the config
importssection, - passing
search_pkgstoaperol.parse_config, or - registering imports globally with
aperol.register_imports
In all three cases, each import must either be a string module name "X.Y" corresponding to import X.Y, or a tuple ("X.Y", "Z") corresponding to import X.Y as Z.
Configuration file locations can be registered using aperol.register_config_path.
Syntax
TODO (and TBC).
Related
Aperol is inspired by Gin Config. In comparison to Gin, Aperol allows configuration to be define using YAML (or any format which can be parsed to a nested dict tree). Thus it does not require learning a completely new syntax. Aperol is also simpler and does not provide all of the functionality of Gin; however, it is powerful enough to configure any Python object enabling flexible configuration.
Metadata
Release files for aperol 0.0.0a0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aperol-0.0.0a0.tar.gz | 10.0 kB | Without provenance | Details for aperol-0.0.0a0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aperol-0.0.0a0-py3-none-any.whl | Python 3 | none | any | Details for aperol-0.0.0a0-py3-none-any.whl |
Total release size: 20.5 kB
Release files / aperol-0.0.0a0.tar.gz
| Download URL | aperol-0.0.0a0.tar.gz |
|---|---|
| Size | 10.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aa2989252b7b1640941d3dcd388cf41b6d2aa90ceb0e6367b65d97d16ea3223e
|
|
BLAKE2b-256 checksum How to use checksums |
e413ead5e1a2f32e6065b33922875c6a276e57cf2c93d259301ba295e4e3f1f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.9
|
Release files / aperol-0.0.0a0-py3-none-any.whl
| Download URL | aperol-0.0.0a0-py3-none-any.whl |
|---|---|
| Size | 10.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bd44a34bde22c6a0ff68eb6734689d46602bb22bd8aa81b254cd2b555cec71c6
|
|
BLAKE2b-256 checksum How to use checksums |
9a0d434a80d560494a9fd16dfe7400c61d0f37152307c7a96825a0125bc2f808
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.9
|
Security for aperol 0.0.0a0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.