python-platformdirs
Port variant py311
Summary Finds platform-specific directories (3.11)
Package version 2.6.2
Homepage No known homepage
Keywords python
Maintainer Python Automaton
License Not yet specified
Other variants py310
Ravenports Buildsheet | History
Ravensource Port Directory | History
Last modified 29 DEC 2022, 23:05:21 UTC
Port created 15 JUL 2021, 22:41:18 UTC
Subpackage Descriptions
single The problem =========== When writing desktop application, finding the right location to store user data and configuration varies per platform. Even for single-platform apps, there may by plenty of nuances in figuring out the right location. For example, if running on macOS, you should use:: ~/Library/Application Support/ If on Windows (at least English Win XP) that should be:: C:\Documents and Settings\\Application Data\Local Settings\\ or possibly:: C:\Documents and Settings\\Application Data\\ for [roaming profiles] but that is another story. On Linux (and other Unices), according to the `XDG Basedir Spec`_, it should be:: ~/.local/share/ .. _XDG Basedir Spec: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html platformdirs to the rescue ============================== This kind of thing is what the platformdirs package is for. platformdirs will help you choose an appropriate: - user data dir (user_data_dir) - user config dir (user_config_dir) - user cache dir (user_cache_dir) - site data dir (site_data_dir) - site config dir (site_config_dir) - user log dir (user_log_dir) - user documents dir (user_documents_dir) - user runtime dir (user_runtime_dir) And also: - Is slightly opinionated on the directory names used. Look for "OPINION" in documentation and code for when an opinion is being applied. Example output ============== On macOS: .. code-block:: pycon >>> from platformdirs import * >>> appname = "SuperApp" >>> appauthor = "Acme" >>> user_data_dir(appname, appauthor) '/Users/trentm/Library/Application Support/SuperApp' >>> site_data_dir(appname, appauthor) '/Library/Application Support/SuperApp' >>> user_cache_dir(appname, appauthor) '/Users/trentm/Library/Caches/SuperApp' >>> user_log_dir(appname, appauthor) '/Users/trentm/Library/Logs/SuperApp' >>> user_documents_dir() '/Users/trentm/Documents' >>> user_runtime_dir(appname, appauthor) '/Users/trentm/Library/Caches/TemporaryItems/SuperApp' On Windows 7: .. code-block:: pycon >>> from platformdirs import * >>> appname = "SuperApp" >>> appauthor = "Acme" >>> user_data_dir(appname, appauthor) 'C:\\Users\\trentm\\AppData\\Local\\Acme\\SuperApp' >>> user_data_dir(appname, appauthor, roaming=True) 'C:\\Users\\trentm\\AppData\\Roaming\\Acme\\SuperApp' >>> user_cache_dir(appname, appauthor) 'C:\\Users\\trentm\\AppData\\Local\\Acme\\SuperApp\\Cache' >>> user_log_dir(appname, appauthor) 'C:\\Users\\trentm\\AppData\\Local\\Acme\\SuperApp\\Logs' >>> user_documents_dir() 'C:\\Users\\trentm\\Documents' >>> user_runtime_dir(appname, appauthor) 'C:\\Users\\trentm\\AppData\\Local\\Temp\\Acme\\SuperApp' On Linux: .. code-block:: pycon >>> from platformdirs import *
Configuration Switches (platform-specific settings discarded)
PY310 OFF Build using Python 3.10 PY311 ON Build using Python 3.11
Package Dependencies by Type
Build (only) python-pip:single:py311
autoselect-python:single:standard
Build and Runtime python311:single:standard
Download groups
main mirror://PYPIWHL/c1/c7/9be9d651b93efce682b45142a6267034fc4215972780748618c02e236361
Distribution File Information
83c8f6d04389165de7c9b6f0c682439697887bca0aa2f1c87ef1826be3584490 14392 platformdirs-2.6.2-py3-none-any.whl
Ports that require python-platformdirs:py311
python-black:py311 Uncompromising code formatter (3.11)
python-pylint:py311 Python code static checker (3.11)
python-virtualenv:py311 Virtual Python Environment builder (3.11)