METADATA 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. Metadata-Version: 2.1
  2. Name: platformdirs
  3. Version: 2.4.1
  4. Summary: A small Python module for determining appropriate platform-specific dirs, e.g. a "user data dir".
  5. Home-page: https://github.com/platformdirs/platformdirs
  6. Maintainer: Bernát Gábor, Julian Berman, Ofek Lev, Ronny Pfannschmidt
  7. Maintainer-email: gaborjbernat@gmail.com, Julian@GrayVines.com, oss@ofek.dev, opensource@ronnypfannschmidt.de
  8. License: MIT
  9. Project-URL: Source, https://github.com/platformdirs/platformdirs
  10. Project-URL: Tracker, https://github.com/platformdirs/platformdirs/issues
  11. Project-URL: Documentation, https://platformdirs.readthedocs.io/
  12. Keywords: application directory log cache user
  13. Platform: UNKNOWN
  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
  20. Classifier: Programming Language :: Python :: 3 :: Only
  21. Classifier: Programming Language :: Python :: 3.7
  22. Classifier: Programming Language :: Python :: 3.8
  23. Classifier: Programming Language :: Python :: 3.9
  24. Classifier: Programming Language :: Python :: 3.10
  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. Description-Content-Type: text/x-rst
  30. License-File: LICENSE.txt
  31. Provides-Extra: docs
  32. Requires-Dist: Sphinx (>=4) ; extra == 'docs'
  33. Requires-Dist: furo (>=2021.7.5b38) ; extra == 'docs'
  34. Requires-Dist: proselint (>=0.10.2) ; extra == 'docs'
  35. Requires-Dist: sphinx-autodoc-typehints (>=1.12) ; extra == 'docs'
  36. Provides-Extra: test
  37. Requires-Dist: appdirs (==1.4.4) ; extra == 'test'
  38. Requires-Dist: pytest (>=6) ; extra == 'test'
  39. Requires-Dist: pytest-cov (>=2.7) ; extra == 'test'
  40. Requires-Dist: pytest-mock (>=3.6) ; extra == 'test'
  41. The problem
  42. ===========
  43. .. image:: https://github.com/platformdirs/platformdirs/workflows/Test/badge.svg
  44. :target: https://github.com/platformdirs/platformdirs/actions?query=workflow%3ATest
  45. When writing desktop application, finding the right location to store user data
  46. and configuration varies per platform. Even for single-platform apps, there
  47. may by plenty of nuances in figuring out the right location.
  48. For example, if running on macOS, you should use::
  49. ~/Library/Application Support/<AppName>
  50. If on Windows (at least English Win XP) that should be::
  51. C:\Documents and Settings\<User>\Application Data\Local Settings\<AppAuthor>\<AppName>
  52. or possibly::
  53. C:\Documents and Settings\<User>\Application Data\<AppAuthor>\<AppName>
  54. 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.
  55. On Linux (and other Unices), according to the `XDG Basedir Spec`_, it should be::
  56. ~/.local/share/<AppName>
  57. .. _XDG Basedir Spec: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
  58. ``platformdirs`` to the rescue
  59. ==============================
  60. This kind of thing is what the ``platformdirs`` module is for.
  61. ``platformdirs`` will help you choose an appropriate:
  62. - user data dir (``user_data_dir``)
  63. - user config dir (``user_config_dir``)
  64. - user cache dir (``user_cache_dir``)
  65. - site data dir (``site_data_dir``)
  66. - site config dir (``site_config_dir``)
  67. - user log dir (``user_log_dir``)
  68. - user documents dir (``user_documents_dir``)
  69. - user runtime dir (``user_runtime_dir``)
  70. And also:
  71. - Is a single module so other Python packages can vendor their own private copy.
  72. - Is slightly opinionated on the directory names used. Look for "OPINION" in
  73. documentation and code for when an opinion is being applied.
  74. Example output
  75. ==============
  76. On macOS:
  77. .. code-block:: pycon
  78. >>> from platformdirs import *
  79. >>> appname = "SuperApp"
  80. >>> appauthor = "Acme"
  81. >>> user_data_dir(appname, appauthor)
  82. '/Users/trentm/Library/Application Support/SuperApp'
  83. >>> site_data_dir(appname, appauthor)
  84. '/Library/Application Support/SuperApp'
  85. >>> user_cache_dir(appname, appauthor)
  86. '/Users/trentm/Library/Caches/SuperApp'
  87. >>> user_log_dir(appname, appauthor)
  88. '/Users/trentm/Library/Logs/SuperApp'
  89. >>> user_documents_dir()
  90. '/Users/trentm/Documents'
  91. >>> user_runtime_dir(appname, appauthor)
  92. '/Users/trentm/Library/Caches/TemporaryItems/SuperApp'
  93. On Windows 7:
  94. .. code-block:: pycon
  95. >>> from platformdirs import *
  96. >>> appname = "SuperApp"
  97. >>> appauthor = "Acme"
  98. >>> user_data_dir(appname, appauthor)
  99. 'C:\\Users\\trentm\\AppData\\Local\\Acme\\SuperApp'
  100. >>> user_data_dir(appname, appauthor, roaming=True)
  101. 'C:\\Users\\trentm\\AppData\\Roaming\\Acme\\SuperApp'
  102. >>> user_cache_dir(appname, appauthor)
  103. 'C:\\Users\\trentm\\AppData\\Local\\Acme\\SuperApp\\Cache'
  104. >>> user_log_dir(appname, appauthor)
  105. 'C:\\Users\\trentm\\AppData\\Local\\Acme\\SuperApp\\Logs'
  106. >>> user_documents_dir()
  107. 'C:\\Users\\trentm\\Documents'
  108. >>> user_runtime_dir(appname, appauthor)
  109. 'C:\\Users\\trentm\\AppData\\Local\\Temp\\Acme\\SuperApp'
  110. On Linux:
  111. .. code-block:: pycon
  112. >>> from platformdirs import *
  113. >>> appname = "SuperApp"
  114. >>> appauthor = "Acme"
  115. >>> user_data_dir(appname, appauthor)
  116. '/home/trentm/.local/share/SuperApp
  117. >>> site_data_dir(appname, appauthor)
  118. '/usr/local/share/SuperApp'
  119. >>> site_data_dir(appname, appauthor, multipath=True)
  120. '/usr/local/share/SuperApp:/usr/share/SuperApp'
  121. >>> user_cache_dir(appname, appauthor)
  122. '/home/trentm/.cache/SuperApp'
  123. >>> user_log_dir(appname, appauthor)
  124. '/home/trentm/.cache/SuperApp/log'
  125. >>> user_config_dir(appname)
  126. '/home/trentm/.config/SuperApp'
  127. >>> user_documents_dir()
  128. '/home/trentm/Documents'
  129. >>> user_runtime_dir(appname, appauthor)
  130. '/run/user/{os.getuid()}/SuperApp'
  131. >>> site_config_dir(appname)
  132. '/etc/xdg/SuperApp'
  133. >>> os.environ["XDG_CONFIG_DIRS"] = "/etc:/usr/local/etc"
  134. >>> site_config_dir(appname, multipath=True)
  135. '/etc/SuperApp:/usr/local/etc/SuperApp'
  136. On Android::
  137. >>> from platformdirs import *
  138. >>> appname = "SuperApp"
  139. >>> appauthor = "Acme"
  140. >>> user_data_dir(appname, appauthor)
  141. '/data/data/com.termux/files/SuperApp'
  142. >>> user_cache_dir(appname, appauthor)
  143. '/data/data/com.termux/cache/SuperApp'
  144. >>> user_log_dir(appname, appauthor)
  145. '/data/data/com.termux/cache/SuperApp/log'
  146. >>> user_config_dir(appname)
  147. '/data/data/com.termux/shared_prefs/SuperApp'
  148. >>> user_documents_dir()
  149. '/storage/emulated/0/Documents'
  150. >>> user_runtime_dir(appname, appauthor)
  151. '/data/data/com.termux/cache/SuperApp/tmp'
  152. ``PlatformDirs`` for convenience
  153. ================================
  154. .. code-block:: pycon
  155. >>> from platformdirs import PlatformDirs
  156. >>> dirs = PlatformDirs("SuperApp", "Acme")
  157. >>> dirs.user_data_dir
  158. '/Users/trentm/Library/Application Support/SuperApp'
  159. >>> dirs.site_data_dir
  160. '/Library/Application Support/SuperApp'
  161. >>> dirs.user_cache_dir
  162. '/Users/trentm/Library/Caches/SuperApp'
  163. >>> dirs.user_log_dir
  164. '/Users/trentm/Library/Logs/SuperApp'
  165. >>> dirs.user_documents_dir
  166. '/Users/trentm/Documents'
  167. >>> dirs.user_runtime_dir
  168. '/Users/trentm/Library/Caches/TemporaryItems/SuperApp'
  169. Per-version isolation
  170. =====================
  171. If you have multiple versions of your app in use that you want to be
  172. able to run side-by-side, then you may want version-isolation for these
  173. dirs::
  174. >>> from platformdirs import PlatformDirs
  175. >>> dirs = PlatformDirs("SuperApp", "Acme", version="1.0")
  176. >>> dirs.user_data_dir
  177. '/Users/trentm/Library/Application Support/SuperApp/1.0'
  178. >>> dirs.site_data_dir
  179. '/Library/Application Support/SuperApp/1.0'
  180. >>> dirs.user_cache_dir
  181. '/Users/trentm/Library/Caches/SuperApp/1.0'
  182. >>> dirs.user_log_dir
  183. '/Users/trentm/Library/Logs/SuperApp/1.0'
  184. >>> dirs.user_documents_dir
  185. '/Users/trentm/Documents'
  186. >>> dirs.user_runtime_dir
  187. '/Users/trentm/Library/Caches/TemporaryItems/SuperApp/1.0'
  188. Be wary of using this for configuration files though; you'll need to handle
  189. migrating configuration files manually.
  190. Why this Fork?
  191. ==============
  192. This repository is a friendly fork of the wonderful work started by
  193. `ActiveState <https://github.com/ActiveState/appdirs>`_ who created
  194. ``appdirs``, this package's ancestor.
  195. Maintaining an open source project is no easy task, particularly
  196. from within an organization, and the Python community is indebted
  197. to ``appdirs`` (and to Trent Mick and Jeff Rouse in particular) for
  198. creating an incredibly useful simple module, as evidenced by the wide
  199. number of users it has attracted over the years.
  200. Nonetheless, given the number of long-standing open issues
  201. and pull requests, and no clear path towards `ensuring
  202. that maintenance of the package would continue or grow
  203. <https://github.com/ActiveState/appdirs/issues/79>`_, this fork was
  204. created.
  205. Contributions are most welcome.