Common application configuration management.
Project description
🏗️ A Python library package which provides application foundation components - streamlined async initialization, configuration management, platform directories, logging setup, and environment handling for Python applications.
Key Features ⭐
🚀 Async Application Initialization: Single prepare() function that sets up your entire application foundation with sensible defaults.
📁 Platform Directory Management: Automatic discovery and creation of platform-specific directories for configuration, data, and cache.
⚙️ TOML Configuration System: Hierarchical configuration loading with includes, template variables, and overrides. Can bring your own configuration system too.
🎯 Distribution Detection: Automatic detection of development vs production deployment modes with package introspection.
📝 Logging Configuration: Logging setup with plain and rich modes and environment variable overrides.
🔄 Resource Management: Integration with AsyncExitStack for proper cleanup of async resources.
🏷️ Safety: Full type annotations with immutable data structures for thread safety.
Installation 📦
Method: Install Python Package
Install via uv pip command:
uv pip install emcd-appcore
Or, install via pip:
pip install emcd-appcore
Examples 💡
Quick Start 🚀
The simplest way to initialize your application:
>>> import asyncio
>>> import contextlib
>>> import appcore
>>> async def main( ):
... async with contextlib.AsyncExitStack( ) as exits:
... auxdata = await appcore.prepare( exits )
... print( f"App: {auxdata.application.name}" )
... return auxdata.configuration
>>> # asyncio.run( main( ) ) # Returns configuration dictionary
Platform Directories 📁
Access platform-specific directories for your application:
>>> async def display_directories( ):
... async with contextlib.AsyncExitStack( ) as exits:
... application = appcore.ApplicationInformation(
... name = 'my-app', publisher = 'MyCompany' )
... auxdata = await appcore.prepare( exits, application = application )
... dirs = auxdata.directories
... print( f"Config: {dirs.user_config_path}" )
... print( f"Data: {dirs.user_data_path}" )
... print( f"Cache: {dirs.user_cache_path}" )
>>> # asyncio.run( display_directories( ) )
Building CLI Applications 🔧
Build command-line applications using the appcore.cli module:
>>> import asyncio
>>> from appcore import cli, state
>>> class HelloCommand( cli.Command ):
... async def execute( self, auxdata: state.Globals ) -> None:
... print( f"Hello from {auxdata.application.name}!" )
>>> class MyApplication( cli.Application ):
... async def execute( self, auxdata: state.Globals ) -> None:
... command = HelloCommand( )
... await command( auxdata )
>>> # asyncio.run( MyApplication( )( ) )
The appcore CLI tool demonstrates these capabilities in action - inspect configuration, environment variables, and platform directories:
$ python -m appcore configuration --display.presentation json $ python -m appcore environment $ python -m appcore directories --display.target-file dirs.txt
For a comprehensive implementation example, see sources/appcore/introspection.py which shows advanced patterns including subcommands, display options, and presentation formats.
Dependencies & Architecture 🏛️
Appcore is built on a foundation of proven, lightweight dependencies:
Configuration: Uses standard library tomli for TOML parsing with accretive data structures that can grow but never shrink.
Platform Integration: Leverages platformdirs for cross-platform directory discovery and aiofiles for async file operations.
Logging Enhancement: Optional integration with Rich for enhanced console output with graceful fallbacks.
Distribution Management: Uses importlib-metadata and importlib-resources for package introspection and resource handling.
The architecture emphasizes:
Immutability: All configuration and state objects are immutable after creation, preventing accidental modifications.
Async-First: Built from the ground up for async/await patterns with proper resource management.
Dependency Injection: Configurable components that can be replaced or extended without modifying core functionality.
Type Safety: Comprehensive type annotations for excellent IDE support and static analysis.
Contribution 🤝
Contribution to this project is welcome! However, it must follow the code of conduct for the project.
Please file bug reports and feature requests in the issue tracker or submit pull requests to improve the source code or documentation.
For development guidance and standards, please see the development guide.
Additional Indicia
Project details
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 emcd_appcore-1.5.tar.gz.
File metadata
- Download URL: emcd_appcore-1.5.tar.gz
- Upload date:
- Size: 27.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0ff5ec591b0fc55358fa4f8ff6fe9b5ba9012fd7ebf02d117bf2538c2334785
|
|
| MD5 |
de6ec1bafe4ea377a6feca5916623f8a
|
|
| BLAKE2b-256 |
f9f7cdcaa3b37f63d7988237ba83406a18342dfb174e3ca69375cccf015ce3c3
|
Provenance
The following attestation bundles were made for emcd_appcore-1.5.tar.gz:
Publisher:
releaser.yaml on emcd/python-appcore
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
emcd_appcore-1.5.tar.gz -
Subject digest:
e0ff5ec591b0fc55358fa4f8ff6fe9b5ba9012fd7ebf02d117bf2538c2334785 - Sigstore transparency entry: 564084320
- Sigstore integration time:
-
Permalink:
emcd/python-appcore@e5f291b347c9fef4a5de88813ae0854912f9049f -
Branch / Tag:
refs/tags/v1.5 - Owner: https://github.com/emcd
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
releaser.yaml@e5f291b347c9fef4a5de88813ae0854912f9049f -
Trigger Event:
push
-
Statement type:
File details
Details for the file emcd_appcore-1.5-py3-none-any.whl.
File metadata
- Download URL: emcd_appcore-1.5-py3-none-any.whl
- Upload date:
- Size: 38.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5448ce7355f013dadbb9518f74abf0a5da2e8820431db4208d0608bbeedf20db
|
|
| MD5 |
46fb016bd61837a06c5326bd1e914ff0
|
|
| BLAKE2b-256 |
52e4464472f1f5d9a45c6e16ca4bf021bf0e2c92a3d6f666fbbd4d16116d491e
|
Provenance
The following attestation bundles were made for emcd_appcore-1.5-py3-none-any.whl:
Publisher:
releaser.yaml on emcd/python-appcore
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
emcd_appcore-1.5-py3-none-any.whl -
Subject digest:
5448ce7355f013dadbb9518f74abf0a5da2e8820431db4208d0608bbeedf20db - Sigstore transparency entry: 564084344
- Sigstore integration time:
-
Permalink:
emcd/python-appcore@e5f291b347c9fef4a5de88813ae0854912f9049f -
Branch / Tag:
refs/tags/v1.5 - Owner: https://github.com/emcd
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
releaser.yaml@e5f291b347c9fef4a5de88813ae0854912f9049f -
Trigger Event:
push
-
Statement type: