Install & Compatibility
Where this runs
tested against v2.2.1 · 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
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.9MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 1.6s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
AppDataPaths
✓ from appdata import AppDataPaths
✗ from appdata import AppData
This quickstart demonstrates how to initialize `AppData` for your application and access the common user data, configuration, and cache directories. It highlights that the library returns `pathlib.Path` objects, which are flexible for path manipulation and can be converted to strings when necessary.
import os
from appdata import AppData
# Replace 'MyAwesomeApp' and 'MyCompany' with your actual app/company names
APP_NAME = os.environ.get('APPDATA_APP_NAME', 'MyTestApp')
APP_AUTHOR = os.environ.get('APPDATA_APP_AUTHOR', 'MyTestCompany')
# Initialize AppData for your application
app_data = AppData(APP_NAME, APP_AUTHOR)
# Access common application directories
user_data_dir = app_data.user_data_dir
user_config_dir = app_data.user_config_dir
user_cache_dir = app_data.user_cache_dir
print(f"User Data Directory: {user_data_dir} (Type: {type(user_data_dir)})")
print(f"User Config Directory: {user_config_dir} (Type: {type(user_config_dir)})")
print(f"User Cache Directory: {user_cache_dir} (Type: {type(user_cache_dir)})")
# You can create subdirectories and files easily with pathlib.Path
some_file_path = user_data_dir / "settings.json"
print(f"Example file path using pathlib: {some_file_path}")
# To convert to string for older APIs if needed:
print(f"User data as string: {str(user_data_dir)}")
Debug
Known issues
breakingThe `AppdataPaths` class was completely removed in version 2.0.0. Its functionality was merged into the `AppData` class.fixMigrate your code to use the `AppData` class. For example, replace `from appdata.appdata_paths import AppdataPaths` with `from appdata import AppData` and create an instance of `AppData`.
affects: >=2.0.0
breakingIn version 2.0.0, the methods `user_data_dir`, `user_config_dir`, `user_cache_dir`, `site_data_dir`, and `site_config_dir` (and their equivalents) now return `pathlib.Path` objects instead of strings.fixUpdate code that expects string results. `pathlib.Path` objects can be used directly for path manipulation (e.g., `path / 'filename.txt'`) or converted to strings using `str(path_object)` when interacting with APIs that require string paths.
affects: >=2.0.0
gotchaAttempting to concatenate a `pathlib.Path` object directly with a string using `+` will result in a `TypeError`.fixUse the `/` operator for concatenating `pathlib.Path` objects with strings or other `Path` objects, or explicitly convert the `Path` object to a string first using `str(path_object)` if string concatenation is absolutely necessary.
affects: All versions returning `pathlib.Path`
Upgrade
Version history
2.2.1latest on PyPI · released Dec 26, 2023
Audit
Dependencies
No dependency data recorded yet.