PyStow is a Python library that simplifies the process of picking a consistent and predictable location for storing data generated or consumed by your Python code. It helps manage application data directories and ensures their existence, often defaulting to a structured `$HOME/.data/<app_name>` path. The current version is 0.8.3, and it maintains an active development and release cadence, with version 0.8.4-dev also documented.
pip install pystowVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `pystow.join` to get and create application-specific directories, and `pystow.ensure` to download and store a file, ensuring its presence. It also shows the `pystow.module` pattern. A temporary custom `PYSTOW_HOME` is set for isolated testing, which defaults to `$HOME/.data` if not configured.
To control the base directory, set `PYSTOW_HOME` environment variable (e.g., `os.environ['PYSTOW_HOME'] = '/path/to/data'`) or `PYSTOW_USE_APPDIRS='True'` for XDG compliance. Ensure your application explicitly checks or sets these if a specific data location is critical.
There is no direct fix for users within the library. If strict type checking is required for your project, you might need to add `pystow` to `mypy`'s `[mypy-pystow*]` section with `ignore_missing_imports = True` in your `mypy.ini` or similar configuration.
Always explicitly define the `name` argument in `pystow.ensure` if you have a specific filename expectation, especially for URLs that might not have a clean filename component. Review the resulting `Path` object to confirm the filename is as expected.
Add `ignore_missing_imports = True` for `pystow` in your `mypy` configuration (e.g., in `mypy.ini` under `[mypy-pystow*]`) to suppress this error and allow `mypy` to continue checking the rest of your project.
Ensure that `pystow.join()` or `pystow.module()` calls are properly made, which automatically create directories. Verify that the `PYSTOW_HOME` environment variable (if set) points to a valid and writable location. Check application logs for any `pystow`-related path resolution issues.