METADATA 13 KB

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