acres is a Python library designed to simplify access to package resources, offering a consistent API for reading, filesystem access, and cached filesystem access. It addresses common pitfalls associated with `importlib.resources` by clearly delineating resource scopes and capabilities. The current version is 0.5.0, with releases occurring periodically, typically every few months, for new features, improvements, and bug fixes.
pip install acresVerified import paths — ran on the pinned version, not inferred.
The quickstart demonstrates how to use `acres.Loader` to access package resources. It shows how to read text content, get a temporary file path using `as_path` (useful for operations requiring a real filesystem path), and retrieve a cached path that persists for the interpreter's lifetime. The example uses a simulated package structure.
Update `Loader(__package__)` to `Loader(__spec__.name)` when instantiating `Loader`.
Upgrade to Python 3.9 or newer.
Remove `importlib_resources` from your project's dependencies if it was only included for `acres`.
If you relied on automatic listing of top-level package contents, you must now explicitly set `list_contents=True` when initializing the `Loader`.
Always use `Loader.as_path()` within a `with` statement for operations requiring a temporary, guaranteed-to-exist `pathlib.Path`. Use `Loader.cached()` when a longer-lived `pathlib.Path` is needed. For simple reads, `Loader.readable().read_text()` or `.read_bytes()` are sufficient without needing a disk path.
Install the 'acres' library using pip: 'pip install acres'.
Ensure the correct import statement: 'from acres import Loader'. Verify that the installed version of 'acres' supports 'Loader'.
Use the 'Loader' class to access resources: 'loader = Loader(somepkg); res_text = loader.readable('data/some_resource.txt').read_text()'.Check the return values of 'acres' methods and ensure they are used correctly. Refer to the 'acres' documentation for proper usage.
Verify that the resource path provided to 'acres' methods is correct and that the resource exists within the package.
No dependency data recorded yet.