CoolFace
Apppublic

Aluode/PerceptionLabPortable

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
1Metadata-Version: 2.42Name: platformdirs3Version: 4.5.14Summary: A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`.5Project-URL: Changelog, https://github.com/tox-dev/platformdirs/releases6Project-URL: Documentation, https://platformdirs.readthedocs.io7Project-URL: Homepage, https://github.com/tox-dev/platformdirs8Project-URL: Source, https://github.com/tox-dev/platformdirs9Project-URL: Tracker, https://github.com/tox-dev/platformdirs/issues10Maintainer-email: Bernát Gábor <gaborjbernat@gmail.com>, Julian Berman <Julian@GrayVines.com>, Ofek Lev <oss@ofek.dev>, Ronny Pfannschmidt <opensource@ronnypfannschmidt.de>11License-Expression: MIT12License-File: LICENSE13Keywords: appdirs,application,cache,directory,log,user14Classifier: Development Status :: 5 - Production/Stable15Classifier: Intended Audience :: Developers16Classifier: License :: OSI Approved :: MIT License17Classifier: Operating System :: OS Independent18Classifier: Programming Language :: Python19Classifier: Programming Language :: Python :: 3 :: Only20Classifier: Programming Language :: Python :: 3.1021Classifier: Programming Language :: Python :: 3.1122Classifier: Programming Language :: Python :: 3.1223Classifier: Programming Language :: Python :: 3.1324Classifier: Programming Language :: Python :: 3.1425Classifier: Programming Language :: Python :: Implementation :: CPython26Classifier: Programming Language :: Python :: Implementation :: PyPy27Classifier: Topic :: Software Development :: Libraries :: Python Modules28Requires-Python: >=3.1029Provides-Extra: docs30Requires-Dist: furo>=2025.9.25; extra == 'docs'31Requires-Dist: proselint>=0.14; extra == 'docs'32Requires-Dist: sphinx-autodoc-typehints>=3.2; extra == 'docs'33Requires-Dist: sphinx>=8.2.3; extra == 'docs'34Provides-Extra: test35Requires-Dist: appdirs==1.4.4; extra == 'test'36Requires-Dist: covdefaults>=2.3; extra == 'test'37Requires-Dist: pytest-cov>=7; extra == 'test'38Requires-Dist: pytest-mock>=3.15.1; extra == 'test'39Requires-Dist: pytest>=8.4.2; extra == 'test'40Provides-Extra: type41Requires-Dist: mypy>=1.18.2; extra == 'type'42Description-Content-Type: text/x-rst43 44The problem45===========46 47.. image:: https://badge.fury.io/py/platformdirs.svg48   :target: https://badge.fury.io/py/platformdirs49.. image:: https://img.shields.io/pypi/pyversions/platformdirs.svg50   :target: https://pypi.python.org/pypi/platformdirs/51.. image:: https://github.com/tox-dev/platformdirs/actions/workflows/check.yaml/badge.svg52   :target: https://github.com/platformdirs/platformdirs/actions53.. image:: https://static.pepy.tech/badge/platformdirs/month54   :target: https://pepy.tech/project/platformdirs55 56When writing desktop application, finding the right location to store user data57and configuration varies per platform. Even for single-platform apps, there58may by plenty of nuances in figuring out the right location.59 60For example, if running on macOS, you should use::61 62    ~/Library/Application Support/<AppName>63 64If on Windows (at least English Win) that should be::65 66    C:\Users\<User>\Application Data\Local Settings\<AppAuthor>\<AppName>67 68or possibly::69 70    C:\Users\<User>\Application Data\<AppAuthor>\<AppName>71 72for `roaming profiles <https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-vista/cc766489(v=ws.10)>`_ but that is another story.73 74On Linux (and other Unices), according to the `XDG Basedir Spec`_, it should be::75 76    ~/.local/share/<AppName>77 78.. _XDG Basedir Spec: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html79 80``platformdirs`` to the rescue81==============================82 83This kind of thing is what the ``platformdirs`` package is for.84``platformdirs`` will help you choose an appropriate:85 86- user data dir (``user_data_dir``)87- user config dir (``user_config_dir``)88- user cache dir (``user_cache_dir``)89- site data dir (``site_data_dir``)90- site config dir (``site_config_dir``)91- user log dir (``user_log_dir``)92- user documents dir (``user_documents_dir``)93- user downloads dir (``user_downloads_dir``)94- user pictures dir (``user_pictures_dir``)95- user videos dir (``user_videos_dir``)96- user music dir (``user_music_dir``)97- user desktop dir (``user_desktop_dir``)98- user runtime dir (``user_runtime_dir``)99 100And also:101 102- Is slightly opinionated on the directory names used. Look for "OPINION" in103  documentation and code for when an opinion is being applied.104 105Example output106==============107 108On macOS:109 110.. code-block:: pycon111 112    >>> from platformdirs import *113    >>> appname = "SuperApp"114    >>> appauthor = "Acme"115    >>> user_data_dir(appname, appauthor)116    '/Users/trentm/Library/Application Support/SuperApp'117    >>> user_config_dir(appname, appauthor)118    '/Users/trentm/Library/Application Support/SuperApp'119    >>> user_cache_dir(appname, appauthor)120    '/Users/trentm/Library/Caches/SuperApp'121    >>> site_data_dir(appname, appauthor)122    '/Library/Application Support/SuperApp'123    >>> site_config_dir(appname, appauthor)124    '/Library/Application Support/SuperApp'125    >>> user_log_dir(appname, appauthor)126    '/Users/trentm/Library/Logs/SuperApp'127    >>> user_documents_dir()128    '/Users/trentm/Documents'129    >>> user_downloads_dir()130    '/Users/trentm/Downloads'131    >>> user_pictures_dir()132    '/Users/trentm/Pictures'133    >>> user_videos_dir()134    '/Users/trentm/Movies'135    >>> user_music_dir()136    '/Users/trentm/Music'137    >>> user_desktop_dir()138    '/Users/trentm/Desktop'139    >>> user_runtime_dir(appname, appauthor)140    '/Users/trentm/Library/Caches/TemporaryItems/SuperApp'141 142On Windows:143 144.. code-block:: pycon145 146    >>> from platformdirs import *147    >>> appname = "SuperApp"148    >>> appauthor = "Acme"149    >>> user_data_dir(appname, appauthor)150    'C:\\Users\\trentm\\AppData\\Local\\Acme\\SuperApp'151    >>> user_data_dir(appname, appauthor, roaming=True)152    'C:\\Users\\trentm\\AppData\\Roaming\\Acme\\SuperApp'153    >>> user_config_dir(appname, appauthor)154    'C:\\Users\\trentm\\AppData\\Local\\Acme\\SuperApp'155    >>> user_cache_dir(appname, appauthor)156    'C:\\Users\\trentm\\AppData\\Local\\Acme\\SuperApp\\Cache'157    >>> site_data_dir(appname, appauthor)158    'C:\\ProgramData\\Acme\\SuperApp'159    >>> site_config_dir(appname, appauthor)160    'C:\\ProgramData\\Acme\\SuperApp'161    >>> user_log_dir(appname, appauthor)162    'C:\\Users\\trentm\\AppData\\Local\\Acme\\SuperApp\\Logs'163    >>> user_documents_dir()164    'C:\\Users\\trentm\\Documents'165    >>> user_downloads_dir()166    'C:\\Users\\trentm\\Downloads'167    >>> user_pictures_dir()168    'C:\\Users\\trentm\\Pictures'169    >>> user_videos_dir()170    'C:\\Users\\trentm\\Videos'171    >>> user_music_dir()172    'C:\\Users\\trentm\\Music'173    >>> user_desktop_dir()174    'C:\\Users\\trentm\\Desktop'175    >>> user_runtime_dir(appname, appauthor)176    'C:\\Users\\trentm\\AppData\\Local\\Temp\\Acme\\SuperApp'177 178On Linux:179 180.. code-block:: pycon181 182    >>> from platformdirs import *183    >>> appname = "SuperApp"184    >>> appauthor = "Acme"185    >>> user_data_dir(appname, appauthor)186    '/home/trentm/.local/share/SuperApp'187    >>> user_config_dir(appname)188    '/home/trentm/.config/SuperApp'189    >>> user_cache_dir(appname, appauthor)190    '/home/trentm/.cache/SuperApp'191    >>> site_data_dir(appname, appauthor)192    '/usr/local/share/SuperApp'193    >>> site_data_dir(appname, appauthor, multipath=True)194    '/usr/local/share/SuperApp:/usr/share/SuperApp'195    >>> site_config_dir(appname)196    '/etc/xdg/SuperApp'197    >>> os.environ["XDG_CONFIG_DIRS"] = "/etc:/usr/local/etc"198    >>> site_config_dir(appname, multipath=True)199    '/etc/SuperApp:/usr/local/etc/SuperApp'200    >>> user_log_dir(appname, appauthor)201    '/home/trentm/.local/state/SuperApp/log'202    >>> user_documents_dir()203    '/home/trentm/Documents'204    >>> user_downloads_dir()205    '/home/trentm/Downloads'206    >>> user_pictures_dir()207    '/home/trentm/Pictures'208    >>> user_videos_dir()209    '/home/trentm/Videos'210    >>> user_music_dir()211    '/home/trentm/Music'212    >>> user_desktop_dir()213    '/home/trentm/Desktop'214    >>> user_runtime_dir(appname, appauthor)215    '/run/user/{os.getuid()}/SuperApp'216 217On Android::218 219    >>> from platformdirs import *220    >>> appname = "SuperApp"221    >>> appauthor = "Acme"222    >>> user_data_dir(appname, appauthor)223    '/data/data/com.myApp/files/SuperApp'224    >>> user_config_dir(appname)225    '/data/data/com.myApp/shared_prefs/SuperApp'226    >>> user_cache_dir(appname, appauthor)227    '/data/data/com.myApp/cache/SuperApp'228    >>> site_data_dir(appname, appauthor)229    '/data/data/com.myApp/files/SuperApp'230    >>> site_config_dir(appname)231    '/data/data/com.myApp/shared_prefs/SuperApp'232    >>> user_log_dir(appname, appauthor)233    '/data/data/com.myApp/cache/SuperApp/log'234    >>> user_documents_dir()235    '/storage/emulated/0/Documents'236    >>> user_downloads_dir()237    '/storage/emulated/0/Downloads'238    >>> user_pictures_dir()239    '/storage/emulated/0/Pictures'240    >>> user_videos_dir()241    '/storage/emulated/0/DCIM/Camera'242    >>> user_music_dir()243    '/storage/emulated/0/Music'244    >>> user_desktop_dir()245    '/storage/emulated/0/Desktop'246    >>> user_runtime_dir(appname, appauthor)247    '/data/data/com.myApp/cache/SuperApp/tmp'248 249Note: Some android apps like Termux and Pydroid are used as shells. These250apps are used by the end user to emulate Linux environment. Presence of251``SHELL`` environment variable is used by Platformdirs to differentiate252between general android apps and android apps used as shells. Shell android253apps also support ``XDG_*`` environment variables.254 255 256``PlatformDirs`` for convenience257================================258 259.. code-block:: pycon260 261    >>> from platformdirs import PlatformDirs262    >>> dirs = PlatformDirs("SuperApp", "Acme")263    >>> dirs.user_data_dir264    '/Users/trentm/Library/Application Support/SuperApp'265    >>> dirs.user_config_dir266    '/Users/trentm/Library/Application Support/SuperApp'267    >>> dirs.user_cache_dir268    '/Users/trentm/Library/Caches/SuperApp'269    >>> dirs.site_data_dir270    '/Library/Application Support/SuperApp'271    >>> dirs.site_config_dir272    '/Library/Application Support/SuperApp'273    >>> dirs.user_cache_dir274    '/Users/trentm/Library/Caches/SuperApp'275    >>> dirs.user_log_dir276    '/Users/trentm/Library/Logs/SuperApp'277    >>> dirs.user_documents_dir278    '/Users/trentm/Documents'279    >>> dirs.user_downloads_dir280    '/Users/trentm/Downloads'281    >>> dirs.user_pictures_dir282    '/Users/trentm/Pictures'283    >>> dirs.user_videos_dir284    '/Users/trentm/Movies'285    >>> dirs.user_music_dir286    '/Users/trentm/Music'287    >>> dirs.user_desktop_dir288    '/Users/trentm/Desktop'289    >>> dirs.user_runtime_dir290    '/Users/trentm/Library/Caches/TemporaryItems/SuperApp'291 292Per-version isolation293=====================294 295If you have multiple versions of your app in use that you want to be296able to run side-by-side, then you may want version-isolation for these297dirs::298 299    >>> from platformdirs import PlatformDirs300    >>> dirs = PlatformDirs("SuperApp", "Acme", version="1.0")301    >>> dirs.user_data_dir302    '/Users/trentm/Library/Application Support/SuperApp/1.0'303    >>> dirs.user_config_dir304    '/Users/trentm/Library/Application Support/SuperApp/1.0'305    >>> dirs.user_cache_dir306    '/Users/trentm/Library/Caches/SuperApp/1.0'307    >>> dirs.site_data_dir308    '/Library/Application Support/SuperApp/1.0'309    >>> dirs.site_config_dir310    '/Library/Application Support/SuperApp/1.0'311    >>> dirs.user_log_dir312    '/Users/trentm/Library/Logs/SuperApp/1.0'313    >>> dirs.user_documents_dir314    '/Users/trentm/Documents'315    >>> dirs.user_downloads_dir316    '/Users/trentm/Downloads'317    >>> dirs.user_pictures_dir318    '/Users/trentm/Pictures'319    >>> dirs.user_videos_dir320    '/Users/trentm/Movies'321    >>> dirs.user_music_dir322    '/Users/trentm/Music'323    >>> dirs.user_desktop_dir324    '/Users/trentm/Desktop'325    >>> dirs.user_runtime_dir326    '/Users/trentm/Library/Caches/TemporaryItems/SuperApp/1.0'327 328Be wary of using this for configuration files though; you'll need to handle329migrating configuration files manually.330 331Why this Fork?332==============333 334This repository is a friendly fork of the wonderful work started by335`ActiveState <https://github.com/ActiveState/appdirs>`_ who created336``appdirs``, this package's ancestor.337 338Maintaining an open source project is no easy task, particularly339from within an organization, and the Python community is indebted340to ``appdirs`` (and to Trent Mick and Jeff Rouse in particular) for341creating an incredibly useful simple module, as evidenced by the wide342number of users it has attracted over the years.343 344Nonetheless, given the number of long-standing open issues345and pull requests, and no clear path towards `ensuring346that maintenance of the package would continue or grow347<https://github.com/ActiveState/appdirs/issues/79>`_, this fork was348created.349 350Contributions are most welcome.351 
Aluode/PerceptionLabPortable · CoolFace