METADATA 11 KB

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