METADATA 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. Metadata-Version: 2.3
  2. Name: platformdirs
  3. Version: 4.3.6
  4. Summary: A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`.
  5. Project-URL: Changelog, https://github.com/tox-dev/platformdirs/releases
  6. Project-URL: Documentation, https://platformdirs.readthedocs.io
  7. Project-URL: Homepage, https://github.com/tox-dev/platformdirs
  8. Project-URL: Source, https://github.com/tox-dev/platformdirs
  9. Project-URL: Tracker, https://github.com/tox-dev/platformdirs/issues
  10. Maintainer-email: Bernát Gábor <gaborjbernat@gmail.com>, Julian Berman <Julian@GrayVines.com>, Ofek Lev <oss@ofek.dev>, Ronny Pfannschmidt <opensource@ronnypfannschmidt.de>
  11. License-Expression: MIT
  12. License-File: LICENSE
  13. Keywords: appdirs,application,cache,directory,log,user
  14. Classifier: Development Status :: 5 - Production/Stable
  15. Classifier: Intended Audience :: Developers
  16. Classifier: License :: OSI Approved :: MIT License
  17. Classifier: Operating System :: OS Independent
  18. Classifier: Programming Language :: Python
  19. Classifier: Programming Language :: Python :: 3 :: Only
  20. Classifier: Programming Language :: Python :: 3.8
  21. Classifier: Programming Language :: Python :: 3.9
  22. Classifier: Programming Language :: Python :: 3.10
  23. Classifier: Programming Language :: Python :: 3.11
  24. Classifier: Programming Language :: Python :: 3.12
  25. Classifier: Programming Language :: Python :: 3.13
  26. Classifier: Programming Language :: Python :: Implementation :: CPython
  27. Classifier: Programming Language :: Python :: Implementation :: PyPy
  28. Classifier: Topic :: Software Development :: Libraries :: Python Modules
  29. Requires-Python: >=3.8
  30. Provides-Extra: docs
  31. Requires-Dist: furo>=2024.8.6; extra == 'docs'
  32. Requires-Dist: proselint>=0.14; extra == 'docs'
  33. Requires-Dist: sphinx-autodoc-typehints>=2.4; extra == 'docs'
  34. Requires-Dist: sphinx>=8.0.2; extra == 'docs'
  35. Provides-Extra: test
  36. Requires-Dist: appdirs==1.4.4; extra == 'test'
  37. Requires-Dist: covdefaults>=2.3; extra == 'test'
  38. Requires-Dist: pytest-cov>=5; extra == 'test'
  39. Requires-Dist: pytest-mock>=3.14; extra == 'test'
  40. Requires-Dist: pytest>=8.3.2; extra == 'test'
  41. Provides-Extra: type
  42. Requires-Dist: mypy>=1.11.2; extra == 'type'
  43. Description-Content-Type: text/x-rst
  44. The problem
  45. ===========
  46. .. image:: https://badge.fury.io/py/platformdirs.svg
  47. :target: https://badge.fury.io/py/platformdirs
  48. .. image:: https://img.shields.io/pypi/pyversions/platformdirs.svg
  49. :target: https://pypi.python.org/pypi/platformdirs/
  50. .. image:: https://github.com/tox-dev/platformdirs/actions/workflows/check.yaml/badge.svg
  51. :target: https://github.com/platformdirs/platformdirs/actions
  52. .. image:: https://static.pepy.tech/badge/platformdirs/month
  53. :target: https://pepy.tech/project/platformdirs
  54. When writing desktop application, finding the right location to store user data
  55. and configuration varies per platform. Even for single-platform apps, there
  56. may by plenty of nuances in figuring out the right location.
  57. For example, if running on macOS, you should use::
  58. ~/Library/Application Support/<AppName>
  59. If on Windows (at least English Win) that should be::
  60. C:\Documents and Settings\<User>\Application Data\Local Settings\<AppAuthor>\<AppName>
  61. or possibly::
  62. C:\Documents and Settings\<User>\Application Data\<AppAuthor>\<AppName>
  63. for `roaming profiles <https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-vista/cc766489(v=ws.10)>`_ but that is another story.
  64. On Linux (and other Unices), according to the `XDG Basedir Spec`_, it should be::
  65. ~/.local/share/<AppName>
  66. .. _XDG Basedir Spec: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
  67. ``platformdirs`` to the rescue
  68. ==============================
  69. This kind of thing is what the ``platformdirs`` package is for.
  70. ``platformdirs`` will help you choose an appropriate:
  71. - user data dir (``user_data_dir``)
  72. - user config dir (``user_config_dir``)
  73. - user cache dir (``user_cache_dir``)
  74. - site data dir (``site_data_dir``)
  75. - site config dir (``site_config_dir``)
  76. - user log dir (``user_log_dir``)
  77. - user documents dir (``user_documents_dir``)
  78. - user downloads dir (``user_downloads_dir``)
  79. - user pictures dir (``user_pictures_dir``)
  80. - user videos dir (``user_videos_dir``)
  81. - user music dir (``user_music_dir``)
  82. - user desktop dir (``user_desktop_dir``)
  83. - user runtime dir (``user_runtime_dir``)
  84. And also:
  85. - Is slightly opinionated on the directory names used. Look for "OPINION" in
  86. documentation and code for when an opinion is being applied.
  87. Example output
  88. ==============
  89. On macOS:
  90. .. code-block:: pycon
  91. >>> from platformdirs import *
  92. >>> appname = "SuperApp"
  93. >>> appauthor = "Acme"
  94. >>> user_data_dir(appname, appauthor)
  95. '/Users/trentm/Library/Application Support/SuperApp'
  96. >>> site_data_dir(appname, appauthor)
  97. '/Library/Application Support/SuperApp'
  98. >>> user_cache_dir(appname, appauthor)
  99. '/Users/trentm/Library/Caches/SuperApp'
  100. >>> user_log_dir(appname, appauthor)
  101. '/Users/trentm/Library/Logs/SuperApp'
  102. >>> user_documents_dir()
  103. '/Users/trentm/Documents'
  104. >>> user_downloads_dir()
  105. '/Users/trentm/Downloads'
  106. >>> user_pictures_dir()
  107. '/Users/trentm/Pictures'
  108. >>> user_videos_dir()
  109. '/Users/trentm/Movies'
  110. >>> user_music_dir()
  111. '/Users/trentm/Music'
  112. >>> user_desktop_dir()
  113. '/Users/trentm/Desktop'
  114. >>> user_runtime_dir(appname, appauthor)
  115. '/Users/trentm/Library/Caches/TemporaryItems/SuperApp'
  116. On Windows:
  117. .. code-block:: pycon
  118. >>> from platformdirs import *
  119. >>> appname = "SuperApp"
  120. >>> appauthor = "Acme"
  121. >>> user_data_dir(appname, appauthor)
  122. 'C:\\Users\\trentm\\AppData\\Local\\Acme\\SuperApp'
  123. >>> user_data_dir(appname, appauthor, roaming=True)
  124. 'C:\\Users\\trentm\\AppData\\Roaming\\Acme\\SuperApp'
  125. >>> user_cache_dir(appname, appauthor)
  126. 'C:\\Users\\trentm\\AppData\\Local\\Acme\\SuperApp\\Cache'
  127. >>> user_log_dir(appname, appauthor)
  128. 'C:\\Users\\trentm\\AppData\\Local\\Acme\\SuperApp\\Logs'
  129. >>> user_documents_dir()
  130. 'C:\\Users\\trentm\\Documents'
  131. >>> user_downloads_dir()
  132. 'C:\\Users\\trentm\\Downloads'
  133. >>> user_pictures_dir()
  134. 'C:\\Users\\trentm\\Pictures'
  135. >>> user_videos_dir()
  136. 'C:\\Users\\trentm\\Videos'
  137. >>> user_music_dir()
  138. 'C:\\Users\\trentm\\Music'
  139. >>> user_desktop_dir()
  140. 'C:\\Users\\trentm\\Desktop'
  141. >>> user_runtime_dir(appname, appauthor)
  142. 'C:\\Users\\trentm\\AppData\\Local\\Temp\\Acme\\SuperApp'
  143. On Linux:
  144. .. code-block:: pycon
  145. >>> from platformdirs import *
  146. >>> appname = "SuperApp"
  147. >>> appauthor = "Acme"
  148. >>> user_data_dir(appname, appauthor)
  149. '/home/trentm/.local/share/SuperApp'
  150. >>> site_data_dir(appname, appauthor)
  151. '/usr/local/share/SuperApp'
  152. >>> site_data_dir(appname, appauthor, multipath=True)
  153. '/usr/local/share/SuperApp:/usr/share/SuperApp'
  154. >>> user_cache_dir(appname, appauthor)
  155. '/home/trentm/.cache/SuperApp'
  156. >>> user_log_dir(appname, appauthor)
  157. '/home/trentm/.local/state/SuperApp/log'
  158. >>> user_config_dir(appname)
  159. '/home/trentm/.config/SuperApp'
  160. >>> user_documents_dir()
  161. '/home/trentm/Documents'
  162. >>> user_downloads_dir()
  163. '/home/trentm/Downloads'
  164. >>> user_pictures_dir()
  165. '/home/trentm/Pictures'
  166. >>> user_videos_dir()
  167. '/home/trentm/Videos'
  168. >>> user_music_dir()
  169. '/home/trentm/Music'
  170. >>> user_desktop_dir()
  171. '/home/trentm/Desktop'
  172. >>> user_runtime_dir(appname, appauthor)
  173. '/run/user/{os.getuid()}/SuperApp'
  174. >>> site_config_dir(appname)
  175. '/etc/xdg/SuperApp'
  176. >>> os.environ["XDG_CONFIG_DIRS"] = "/etc:/usr/local/etc"
  177. >>> site_config_dir(appname, multipath=True)
  178. '/etc/SuperApp:/usr/local/etc/SuperApp'
  179. On Android::
  180. >>> from platformdirs import *
  181. >>> appname = "SuperApp"
  182. >>> appauthor = "Acme"
  183. >>> user_data_dir(appname, appauthor)
  184. '/data/data/com.myApp/files/SuperApp'
  185. >>> user_cache_dir(appname, appauthor)
  186. '/data/data/com.myApp/cache/SuperApp'
  187. >>> user_log_dir(appname, appauthor)
  188. '/data/data/com.myApp/cache/SuperApp/log'
  189. >>> user_config_dir(appname)
  190. '/data/data/com.myApp/shared_prefs/SuperApp'
  191. >>> user_documents_dir()
  192. '/storage/emulated/0/Documents'
  193. >>> user_downloads_dir()
  194. '/storage/emulated/0/Downloads'
  195. >>> user_pictures_dir()
  196. '/storage/emulated/0/Pictures'
  197. >>> user_videos_dir()
  198. '/storage/emulated/0/DCIM/Camera'
  199. >>> user_music_dir()
  200. '/storage/emulated/0/Music'
  201. >>> user_desktop_dir()
  202. '/storage/emulated/0/Desktop'
  203. >>> user_runtime_dir(appname, appauthor)
  204. '/data/data/com.myApp/cache/SuperApp/tmp'
  205. Note: Some android apps like Termux and Pydroid are used as shells. These
  206. apps are used by the end user to emulate Linux environment. Presence of
  207. ``SHELL`` environment variable is used by Platformdirs to differentiate
  208. between general android apps and android apps used as shells. Shell android
  209. apps also support ``XDG_*`` environment variables.
  210. ``PlatformDirs`` for convenience
  211. ================================
  212. .. code-block:: pycon
  213. >>> from platformdirs import PlatformDirs
  214. >>> dirs = PlatformDirs("SuperApp", "Acme")
  215. >>> dirs.user_data_dir
  216. '/Users/trentm/Library/Application Support/SuperApp'
  217. >>> dirs.site_data_dir
  218. '/Library/Application Support/SuperApp'
  219. >>> dirs.user_cache_dir
  220. '/Users/trentm/Library/Caches/SuperApp'
  221. >>> dirs.user_log_dir
  222. '/Users/trentm/Library/Logs/SuperApp'
  223. >>> dirs.user_documents_dir
  224. '/Users/trentm/Documents'
  225. >>> dirs.user_downloads_dir
  226. '/Users/trentm/Downloads'
  227. >>> dirs.user_pictures_dir
  228. '/Users/trentm/Pictures'
  229. >>> dirs.user_videos_dir
  230. '/Users/trentm/Movies'
  231. >>> dirs.user_music_dir
  232. '/Users/trentm/Music'
  233. >>> dirs.user_desktop_dir
  234. '/Users/trentm/Desktop'
  235. >>> dirs.user_runtime_dir
  236. '/Users/trentm/Library/Caches/TemporaryItems/SuperApp'
  237. Per-version isolation
  238. =====================
  239. If you have multiple versions of your app in use that you want to be
  240. able to run side-by-side, then you may want version-isolation for these
  241. dirs::
  242. >>> from platformdirs import PlatformDirs
  243. >>> dirs = PlatformDirs("SuperApp", "Acme", version="1.0")
  244. >>> dirs.user_data_dir
  245. '/Users/trentm/Library/Application Support/SuperApp/1.0'
  246. >>> dirs.site_data_dir
  247. '/Library/Application Support/SuperApp/1.0'
  248. >>> dirs.user_cache_dir
  249. '/Users/trentm/Library/Caches/SuperApp/1.0'
  250. >>> dirs.user_log_dir
  251. '/Users/trentm/Library/Logs/SuperApp/1.0'
  252. >>> dirs.user_documents_dir
  253. '/Users/trentm/Documents'
  254. >>> dirs.user_downloads_dir
  255. '/Users/trentm/Downloads'
  256. >>> dirs.user_pictures_dir
  257. '/Users/trentm/Pictures'
  258. >>> dirs.user_videos_dir
  259. '/Users/trentm/Movies'
  260. >>> dirs.user_music_dir
  261. '/Users/trentm/Music'
  262. >>> dirs.user_desktop_dir
  263. '/Users/trentm/Desktop'
  264. >>> dirs.user_runtime_dir
  265. '/Users/trentm/Library/Caches/TemporaryItems/SuperApp/1.0'
  266. Be wary of using this for configuration files though; you'll need to handle
  267. migrating configuration files manually.
  268. Why this Fork?
  269. ==============
  270. This repository is a friendly fork of the wonderful work started by
  271. `ActiveState <https://github.com/ActiveState/appdirs>`_ who created
  272. ``appdirs``, this package's ancestor.
  273. Maintaining an open source project is no easy task, particularly
  274. from within an organization, and the Python community is indebted
  275. to ``appdirs`` (and to Trent Mick and Jeff Rouse in particular) for
  276. creating an incredibly useful simple module, as evidenced by the wide
  277. number of users it has attracted over the years.
  278. Nonetheless, given the number of long-standing open issues
  279. and pull requests, and no clear path towards `ensuring
  280. that maintenance of the package would continue or grow
  281. <https://github.com/ActiveState/appdirs/issues/79>`_, this fork was
  282. created.
  283. Contributions are most welcome.