METADATA 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. Metadata-Version: 2.1
  2. Name: platformdirs
  3. Version: 3.8.1
  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.6.3; python_version < '3.8'
  30. Provides-Extra: docs
  31. Requires-Dist: furo>=2023.5.20; extra == 'docs'
  32. Requires-Dist: proselint>=0.13; extra == 'docs'
  33. Requires-Dist: sphinx-autodoc-typehints!=1.23.4,>=1.23; extra == 'docs'
  34. Requires-Dist: sphinx>=7.0.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.10; extra == 'test'
  40. Requires-Dist: pytest>=7.3.1; 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 runtime dir (``user_runtime_dir``)
  75. And also:
  76. - Is slightly opinionated on the directory names used. Look for "OPINION" in
  77. documentation and code for when an opinion is being applied.
  78. Example output
  79. ==============
  80. On macOS:
  81. .. code-block:: pycon
  82. >>> from platformdirs import *
  83. >>> appname = "SuperApp"
  84. >>> appauthor = "Acme"
  85. >>> user_data_dir(appname, appauthor)
  86. '/Users/trentm/Library/Application Support/SuperApp'
  87. >>> site_data_dir(appname, appauthor)
  88. '/Library/Application Support/SuperApp'
  89. >>> user_cache_dir(appname, appauthor)
  90. '/Users/trentm/Library/Caches/SuperApp'
  91. >>> user_log_dir(appname, appauthor)
  92. '/Users/trentm/Library/Logs/SuperApp'
  93. >>> user_documents_dir()
  94. '/Users/trentm/Documents'
  95. >>> user_downloads_dir()
  96. '/Users/trentm/Downloads'
  97. >>> user_pictures_dir()
  98. '/Users/trentm/Pictures'
  99. >>> user_videos_dir()
  100. '/Users/trentm/Movies'
  101. >>> user_music_dir()
  102. '/Users/trentm/Music'
  103. >>> user_runtime_dir(appname, appauthor)
  104. '/Users/trentm/Library/Caches/TemporaryItems/SuperApp'
  105. On Windows:
  106. .. code-block:: pycon
  107. >>> from platformdirs import *
  108. >>> appname = "SuperApp"
  109. >>> appauthor = "Acme"
  110. >>> user_data_dir(appname, appauthor)
  111. 'C:\\Users\\trentm\\AppData\\Local\\Acme\\SuperApp'
  112. >>> user_data_dir(appname, appauthor, roaming=True)
  113. 'C:\\Users\\trentm\\AppData\\Roaming\\Acme\\SuperApp'
  114. >>> user_cache_dir(appname, appauthor)
  115. 'C:\\Users\\trentm\\AppData\\Local\\Acme\\SuperApp\\Cache'
  116. >>> user_log_dir(appname, appauthor)
  117. 'C:\\Users\\trentm\\AppData\\Local\\Acme\\SuperApp\\Logs'
  118. >>> user_documents_dir()
  119. 'C:\\Users\\trentm\\Documents'
  120. >>> user_downloads_dir()
  121. 'C:\\Users\\trentm\\Downloads'
  122. >>> user_pictures_dir()
  123. 'C:\\Users\\trentm\\Pictures'
  124. >>> user_videos_dir()
  125. 'C:\\Users\\trentm\\Videos'
  126. >>> user_music_dir()
  127. 'C:\\Users\\trentm\\Music'
  128. >>> user_runtime_dir(appname, appauthor)
  129. 'C:\\Users\\trentm\\AppData\\Local\\Temp\\Acme\\SuperApp'
  130. On Linux:
  131. .. code-block:: pycon
  132. >>> from platformdirs import *
  133. >>> appname = "SuperApp"
  134. >>> appauthor = "Acme"
  135. >>> user_data_dir(appname, appauthor)
  136. '/home/trentm/.local/share/SuperApp'
  137. >>> site_data_dir(appname, appauthor)
  138. '/usr/local/share/SuperApp'
  139. >>> site_data_dir(appname, appauthor, multipath=True)
  140. '/usr/local/share/SuperApp:/usr/share/SuperApp'
  141. >>> user_cache_dir(appname, appauthor)
  142. '/home/trentm/.cache/SuperApp'
  143. >>> user_log_dir(appname, appauthor)
  144. '/home/trentm/.cache/SuperApp/log'
  145. >>> user_config_dir(appname)
  146. '/home/trentm/.config/SuperApp'
  147. >>> user_documents_dir()
  148. '/home/trentm/Documents'
  149. >>> user_downloads_dir()
  150. '/home/trentm/Downloads'
  151. >>> user_pictures_dir()
  152. '/home/trentm/Pictures'
  153. >>> user_videos_dir()
  154. '/home/trentm/Videos'
  155. >>> user_music_dir()
  156. '/home/trentm/Music'
  157. >>> user_runtime_dir(appname, appauthor)
  158. '/run/user/{os.getuid()}/SuperApp'
  159. >>> site_config_dir(appname)
  160. '/etc/xdg/SuperApp'
  161. >>> os.environ["XDG_CONFIG_DIRS"] = "/etc:/usr/local/etc"
  162. >>> site_config_dir(appname, multipath=True)
  163. '/etc/SuperApp:/usr/local/etc/SuperApp'
  164. On Android::
  165. >>> from platformdirs import *
  166. >>> appname = "SuperApp"
  167. >>> appauthor = "Acme"
  168. >>> user_data_dir(appname, appauthor)
  169. '/data/data/com.myApp/files/SuperApp'
  170. >>> user_cache_dir(appname, appauthor)
  171. '/data/data/com.myApp/cache/SuperApp'
  172. >>> user_log_dir(appname, appauthor)
  173. '/data/data/com.myApp/cache/SuperApp/log'
  174. >>> user_config_dir(appname)
  175. '/data/data/com.myApp/shared_prefs/SuperApp'
  176. >>> user_documents_dir()
  177. '/storage/emulated/0/Documents'
  178. >>> user_downloads_dir()
  179. '/storage/emulated/0/Downloads'
  180. >>> user_pictures_dir()
  181. '/storage/emulated/0/Pictures'
  182. >>> user_videos_dir()
  183. '/storage/emulated/0/DCIM/Camera'
  184. >>> user_music_dir()
  185. '/storage/emulated/0/Music'
  186. >>> user_runtime_dir(appname, appauthor)
  187. '/data/data/com.myApp/cache/SuperApp/tmp'
  188. Note: Some android apps like Termux and Pydroid are used as shells. These
  189. apps are used by the end user to emulate Linux environment. Presence of
  190. ``SHELL`` environment variable is used by Platformdirs to differentiate
  191. between general android apps and android apps used as shells. Shell android
  192. apps also support ``XDG_*`` environment variables.
  193. ``PlatformDirs`` for convenience
  194. ================================
  195. .. code-block:: pycon
  196. >>> from platformdirs import PlatformDirs
  197. >>> dirs = PlatformDirs("SuperApp", "Acme")
  198. >>> dirs.user_data_dir
  199. '/Users/trentm/Library/Application Support/SuperApp'
  200. >>> dirs.site_data_dir
  201. '/Library/Application Support/SuperApp'
  202. >>> dirs.user_cache_dir
  203. '/Users/trentm/Library/Caches/SuperApp'
  204. >>> dirs.user_log_dir
  205. '/Users/trentm/Library/Logs/SuperApp'
  206. >>> dirs.user_documents_dir
  207. '/Users/trentm/Documents'
  208. >>> dirs.user_downloads_dir
  209. '/Users/trentm/Downloads'
  210. >>> dirs.user_pictures_dir
  211. '/Users/trentm/Pictures'
  212. >>> dirs.user_videos_dir
  213. '/Users/trentm/Movies'
  214. >>> dirs.user_music_dir
  215. '/Users/trentm/Music'
  216. >>> dirs.user_runtime_dir
  217. '/Users/trentm/Library/Caches/TemporaryItems/SuperApp'
  218. Per-version isolation
  219. =====================
  220. If you have multiple versions of your app in use that you want to be
  221. able to run side-by-side, then you may want version-isolation for these
  222. dirs::
  223. >>> from platformdirs import PlatformDirs
  224. >>> dirs = PlatformDirs("SuperApp", "Acme", version="1.0")
  225. >>> dirs.user_data_dir
  226. '/Users/trentm/Library/Application Support/SuperApp/1.0'
  227. >>> dirs.site_data_dir
  228. '/Library/Application Support/SuperApp/1.0'
  229. >>> dirs.user_cache_dir
  230. '/Users/trentm/Library/Caches/SuperApp/1.0'
  231. >>> dirs.user_log_dir
  232. '/Users/trentm/Library/Logs/SuperApp/1.0'
  233. >>> dirs.user_documents_dir
  234. '/Users/trentm/Documents'
  235. >>> dirs.user_downloads_dir
  236. '/Users/trentm/Downloads'
  237. >>> dirs.user_pictures_dir
  238. '/Users/trentm/Pictures'
  239. >>> dirs.user_videos_dir
  240. '/Users/trentm/Movies'
  241. >>> dirs.user_music_dir
  242. '/Users/trentm/Music'
  243. >>> dirs.user_runtime_dir
  244. '/Users/trentm/Library/Caches/TemporaryItems/SuperApp/1.0'
  245. Be wary of using this for configuration files though; you'll need to handle
  246. migrating configuration files manually.
  247. Why this Fork?
  248. ==============
  249. This repository is a friendly fork of the wonderful work started by
  250. `ActiveState <https://github.com/ActiveState/appdirs>`_ who created
  251. ``appdirs``, this package's ancestor.
  252. Maintaining an open source project is no easy task, particularly
  253. from within an organization, and the Python community is indebted
  254. to ``appdirs`` (and to Trent Mick and Jeff Rouse in particular) for
  255. creating an incredibly useful simple module, as evidenced by the wide
  256. number of users it has attracted over the years.
  257. Nonetheless, given the number of long-standing open issues
  258. and pull requests, and no clear path towards `ensuring
  259. that maintenance of the package would continue or grow
  260. <https://github.com/ActiveState/appdirs/issues/79>`_, this fork was
  261. created.
  262. Contributions are most welcome.