@scrypted/server 0.0.137 → 0.0.141

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of @scrypted/server might be problematic. Click here for more details.

Files changed (771) hide show
  1. package/.venv/bin/Activate.ps1 +241 -0
  2. package/.venv/bin/activate +66 -0
  3. package/.venv/bin/activate.csh +25 -0
  4. package/.venv/bin/activate.fish +64 -0
  5. package/.venv/bin/pip +8 -0
  6. package/.venv/bin/pip3 +8 -0
  7. package/.venv/bin/pip3.9 +8 -0
  8. package/.venv/lib/python3.9/site-packages/_distutils_hack/__init__.py +198 -0
  9. package/.venv/lib/python3.9/site-packages/_distutils_hack/override.py +1 -0
  10. package/.venv/lib/python3.9/site-packages/distutils-precedence.pth +1 -0
  11. package/.venv/lib/python3.9/site-packages/pgi/__init__.py +62 -0
  12. package/.venv/lib/python3.9/site-packages/pgi/_compat.py +74 -0
  13. package/.venv/lib/python3.9/site-packages/pgi/callback.py +15 -0
  14. package/.venv/lib/python3.9/site-packages/pgi/cffilib/__init__.py +12 -0
  15. package/.venv/lib/python3.9/site-packages/pgi/cffilib/_compat.py +25 -0
  16. package/.venv/lib/python3.9/site-packages/pgi/cffilib/_utils.py +119 -0
  17. package/.venv/lib/python3.9/site-packages/pgi/cffilib/gir/__init__.py +60 -0
  18. package/.venv/lib/python3.9/site-packages/pgi/cffilib/gir/_cdef.py +574 -0
  19. package/.venv/lib/python3.9/site-packages/pgi/cffilib/gir/_ffi.py +25 -0
  20. package/.venv/lib/python3.9/site-packages/pgi/cffilib/gir/error.py +13 -0
  21. package/.venv/lib/python3.9/site-packages/pgi/cffilib/gir/giarginfo.py +73 -0
  22. package/.venv/lib/python3.9/site-packages/pgi/cffilib/gir/giargument.py +36 -0
  23. package/.venv/lib/python3.9/site-packages/pgi/cffilib/gir/gibaseinfo.py +113 -0
  24. package/.venv/lib/python3.9/site-packages/pgi/cffilib/gir/gicallableinfo.py +75 -0
  25. package/.venv/lib/python3.9/site-packages/pgi/cffilib/gir/giconstantinfo.py +22 -0
  26. package/.venv/lib/python3.9/site-packages/pgi/cffilib/gir/gienuminfo.py +59 -0
  27. package/.venv/lib/python3.9/site-packages/pgi/cffilib/gir/gifieldinfo.py +40 -0
  28. package/.venv/lib/python3.9/site-packages/pgi/cffilib/gir/gifunctioninfo.py +64 -0
  29. package/.venv/lib/python3.9/site-packages/pgi/cffilib/gir/giinterfaceinfo.py +93 -0
  30. package/.venv/lib/python3.9/site-packages/pgi/cffilib/gir/giobjectinfo.py +143 -0
  31. package/.venv/lib/python3.9/site-packages/pgi/cffilib/gir/gipropertyinfo.py +28 -0
  32. package/.venv/lib/python3.9/site-packages/pgi/cffilib/gir/giregisteredtypeinfo.py +27 -0
  33. package/.venv/lib/python3.9/site-packages/pgi/cffilib/gir/girepository.py +143 -0
  34. package/.venv/lib/python3.9/site-packages/pgi/cffilib/gir/gisignalinfo.py +55 -0
  35. package/.venv/lib/python3.9/site-packages/pgi/cffilib/gir/gistructinfo.py +55 -0
  36. package/.venv/lib/python3.9/site-packages/pgi/cffilib/gir/gitypeinfo.py +66 -0
  37. package/.venv/lib/python3.9/site-packages/pgi/cffilib/gir/gitypelib.py +40 -0
  38. package/.venv/lib/python3.9/site-packages/pgi/cffilib/gir/giunioninfo.py +66 -0
  39. package/.venv/lib/python3.9/site-packages/pgi/cffilib/glib/__init__.py +8 -0
  40. package/.venv/lib/python3.9/site-packages/pgi/cffilib/glib/_cdef.py +101 -0
  41. package/.venv/lib/python3.9/site-packages/pgi/cffilib/glib/glib.py +260 -0
  42. package/.venv/lib/python3.9/site-packages/pgi/cffilib/gobject/__init__.py +15 -0
  43. package/.venv/lib/python3.9/site-packages/pgi/cffilib/gobject/_cdef.py +45 -0
  44. package/.venv/lib/python3.9/site-packages/pgi/cffilib/gobject/_ffi.py +26 -0
  45. package/.venv/lib/python3.9/site-packages/pgi/cffilib/gobject/gobject.py +27 -0
  46. package/.venv/lib/python3.9/site-packages/pgi/clib/__init__.py +11 -0
  47. package/.venv/lib/python3.9/site-packages/pgi/clib/_compat.py +20 -0
  48. package/.venv/lib/python3.9/site-packages/pgi/clib/_utils.py +213 -0
  49. package/.venv/lib/python3.9/site-packages/pgi/clib/gir/__init__.py +71 -0
  50. package/.venv/lib/python3.9/site-packages/pgi/clib/gir/error.py +13 -0
  51. package/.venv/lib/python3.9/site-packages/pgi/clib/gir/giarginfo.py +65 -0
  52. package/.venv/lib/python3.9/site-packages/pgi/clib/gir/giargument.py +58 -0
  53. package/.venv/lib/python3.9/site-packages/pgi/clib/gir/gibaseinfo.py +152 -0
  54. package/.venv/lib/python3.9/site-packages/pgi/clib/gir/gicallableinfo.py +203 -0
  55. package/.venv/lib/python3.9/site-packages/pgi/clib/gir/giconstantinfo.py +35 -0
  56. package/.venv/lib/python3.9/site-packages/pgi/clib/gir/gienuminfo.py +64 -0
  57. package/.venv/lib/python3.9/site-packages/pgi/clib/gir/gifieldinfo.py +46 -0
  58. package/.venv/lib/python3.9/site-packages/pgi/clib/gir/giinterfaceinfo.py +83 -0
  59. package/.venv/lib/python3.9/site-packages/pgi/clib/gir/giobjectinfo.py +134 -0
  60. package/.venv/lib/python3.9/site-packages/pgi/clib/gir/gipropertyinfo.py +36 -0
  61. package/.venv/lib/python3.9/site-packages/pgi/clib/gir/giregisteredtypeinfo.py +34 -0
  62. package/.venv/lib/python3.9/site-packages/pgi/clib/gir/girepository.py +200 -0
  63. package/.venv/lib/python3.9/site-packages/pgi/clib/gir/gistructinfo.py +55 -0
  64. package/.venv/lib/python3.9/site-packages/pgi/clib/gir/gitypeinfo.py +97 -0
  65. package/.venv/lib/python3.9/site-packages/pgi/clib/gir/gitypelib.py +56 -0
  66. package/.venv/lib/python3.9/site-packages/pgi/clib/gir/giunioninfo.py +60 -0
  67. package/.venv/lib/python3.9/site-packages/pgi/clib/glib.py +336 -0
  68. package/.venv/lib/python3.9/site-packages/pgi/clib/gobject.py +405 -0
  69. package/.venv/lib/python3.9/site-packages/pgi/codegen/__init__.py +28 -0
  70. package/.venv/lib/python3.9/site-packages/pgi/codegen/arguments.py +640 -0
  71. package/.venv/lib/python3.9/site-packages/pgi/codegen/backend.py +95 -0
  72. package/.venv/lib/python3.9/site-packages/pgi/codegen/cbargs.py +152 -0
  73. package/.venv/lib/python3.9/site-packages/pgi/codegen/cbreturn.py +77 -0
  74. package/.venv/lib/python3.9/site-packages/pgi/codegen/cffi_backend.py +424 -0
  75. package/.venv/lib/python3.9/site-packages/pgi/codegen/construct.py +222 -0
  76. package/.venv/lib/python3.9/site-packages/pgi/codegen/ctypes_backend/__init__.py +11 -0
  77. package/.venv/lib/python3.9/site-packages/pgi/codegen/ctypes_backend/main.py +184 -0
  78. package/.venv/lib/python3.9/site-packages/pgi/codegen/ctypes_backend/types_basic.py +705 -0
  79. package/.venv/lib/python3.9/site-packages/pgi/codegen/ctypes_backend/types_container.py +236 -0
  80. package/.venv/lib/python3.9/site-packages/pgi/codegen/ctypes_backend/types_interface.py +402 -0
  81. package/.venv/lib/python3.9/site-packages/pgi/codegen/ctypes_backend/types_other.py +93 -0
  82. package/.venv/lib/python3.9/site-packages/pgi/codegen/ctypes_backend/utils.py +168 -0
  83. package/.venv/lib/python3.9/site-packages/pgi/codegen/fieldgen.py +114 -0
  84. package/.venv/lib/python3.9/site-packages/pgi/codegen/fields.py +244 -0
  85. package/.venv/lib/python3.9/site-packages/pgi/codegen/funcgen.py +376 -0
  86. package/.venv/lib/python3.9/site-packages/pgi/codegen/null_backend.py +110 -0
  87. package/.venv/lib/python3.9/site-packages/pgi/codegen/returnvalues.py +443 -0
  88. package/.venv/lib/python3.9/site-packages/pgi/codegen/siggen.py +157 -0
  89. package/.venv/lib/python3.9/site-packages/pgi/codegen/utils.py +248 -0
  90. package/.venv/lib/python3.9/site-packages/pgi/const.py +9 -0
  91. package/.venv/lib/python3.9/site-packages/pgi/constant.py +32 -0
  92. package/.venv/lib/python3.9/site-packages/pgi/debug.py +31 -0
  93. package/.venv/lib/python3.9/site-packages/pgi/enum.py +244 -0
  94. package/.venv/lib/python3.9/site-packages/pgi/field.py +58 -0
  95. package/.venv/lib/python3.9/site-packages/pgi/finalizer.py +3 -0
  96. package/.venv/lib/python3.9/site-packages/pgi/foreign/__init__.py +71 -0
  97. package/.venv/lib/python3.9/site-packages/pgi/foreign/_base.py +43 -0
  98. package/.venv/lib/python3.9/site-packages/pgi/foreign/cairo.py +41 -0
  99. package/.venv/lib/python3.9/site-packages/pgi/function.py +12 -0
  100. package/.venv/lib/python3.9/site-packages/pgi/gerror.py +58 -0
  101. package/.venv/lib/python3.9/site-packages/pgi/gtype.py +168 -0
  102. package/.venv/lib/python3.9/site-packages/pgi/importer.py +189 -0
  103. package/.venv/lib/python3.9/site-packages/pgi/module.py +141 -0
  104. package/.venv/lib/python3.9/site-packages/pgi/obj.py +519 -0
  105. package/.venv/lib/python3.9/site-packages/pgi/overrides/GLib.py +1013 -0
  106. package/.venv/lib/python3.9/site-packages/pgi/overrides/GObject.py +583 -0
  107. package/.venv/lib/python3.9/site-packages/pgi/overrides/Gdk.py +454 -0
  108. package/.venv/lib/python3.9/site-packages/pgi/overrides/Gio.py +237 -0
  109. package/.venv/lib/python3.9/site-packages/pgi/overrides/Gtk.py +2412 -0
  110. package/.venv/lib/python3.9/site-packages/pgi/overrides/Pango.py +53 -0
  111. package/.venv/lib/python3.9/site-packages/pgi/overrides/Poppler.py +61 -0
  112. package/.venv/lib/python3.9/site-packages/pgi/overrides/__init__.py +327 -0
  113. package/.venv/lib/python3.9/site-packages/pgi/overrides/keysyms.py +54 -0
  114. package/.venv/lib/python3.9/site-packages/pgi/properties.py +313 -0
  115. package/.venv/lib/python3.9/site-packages/pgi/propertyhelper.py +12 -0
  116. package/.venv/lib/python3.9/site-packages/pgi/repository/__init__.py +10 -0
  117. package/.venv/lib/python3.9/site-packages/pgi/signalhelper.py +18 -0
  118. package/.venv/lib/python3.9/site-packages/pgi/signals.py +122 -0
  119. package/.venv/lib/python3.9/site-packages/pgi/static.py +189 -0
  120. package/.venv/lib/python3.9/site-packages/pgi/structure.py +131 -0
  121. package/.venv/lib/python3.9/site-packages/pgi/util.py +342 -0
  122. package/.venv/lib/python3.9/site-packages/pgi-0.0.11.2.dist-info/COPYING +502 -0
  123. package/.venv/lib/python3.9/site-packages/pgi-0.0.11.2.dist-info/INSTALLER +1 -0
  124. package/.venv/lib/python3.9/site-packages/pgi-0.0.11.2.dist-info/METADATA +22 -0
  125. package/.venv/lib/python3.9/site-packages/pgi-0.0.11.2.dist-info/RECORD +229 -0
  126. package/.venv/lib/python3.9/site-packages/pgi-0.0.11.2.dist-info/REQUESTED +0 -0
  127. package/.venv/lib/python3.9/site-packages/pgi-0.0.11.2.dist-info/WHEEL +5 -0
  128. package/.venv/lib/python3.9/site-packages/pgi-0.0.11.2.dist-info/top_level.txt +1 -0
  129. package/.venv/lib/python3.9/site-packages/pip/__init__.py +13 -0
  130. package/.venv/lib/python3.9/site-packages/pip/__main__.py +31 -0
  131. package/.venv/lib/python3.9/site-packages/pip/_internal/__init__.py +19 -0
  132. package/.venv/lib/python3.9/site-packages/pip/_internal/build_env.py +293 -0
  133. package/.venv/lib/python3.9/site-packages/pip/_internal/cache.py +264 -0
  134. package/.venv/lib/python3.9/site-packages/pip/_internal/cli/__init__.py +4 -0
  135. package/.venv/lib/python3.9/site-packages/pip/_internal/cli/autocompletion.py +163 -0
  136. package/.venv/lib/python3.9/site-packages/pip/_internal/cli/base_command.py +214 -0
  137. package/.venv/lib/python3.9/site-packages/pip/_internal/cli/cmdoptions.py +1010 -0
  138. package/.venv/lib/python3.9/site-packages/pip/_internal/cli/command_context.py +27 -0
  139. package/.venv/lib/python3.9/site-packages/pip/_internal/cli/main.py +70 -0
  140. package/.venv/lib/python3.9/site-packages/pip/_internal/cli/main_parser.py +87 -0
  141. package/.venv/lib/python3.9/site-packages/pip/_internal/cli/parser.py +292 -0
  142. package/.venv/lib/python3.9/site-packages/pip/_internal/cli/progress_bars.py +250 -0
  143. package/.venv/lib/python3.9/site-packages/pip/_internal/cli/req_command.py +469 -0
  144. package/.venv/lib/python3.9/site-packages/pip/_internal/cli/spinners.py +157 -0
  145. package/.venv/lib/python3.9/site-packages/pip/_internal/cli/status_codes.py +6 -0
  146. package/.venv/lib/python3.9/site-packages/pip/_internal/commands/__init__.py +127 -0
  147. package/.venv/lib/python3.9/site-packages/pip/_internal/commands/cache.py +223 -0
  148. package/.venv/lib/python3.9/site-packages/pip/_internal/commands/check.py +53 -0
  149. package/.venv/lib/python3.9/site-packages/pip/_internal/commands/completion.py +96 -0
  150. package/.venv/lib/python3.9/site-packages/pip/_internal/commands/configuration.py +266 -0
  151. package/.venv/lib/python3.9/site-packages/pip/_internal/commands/debug.py +202 -0
  152. package/.venv/lib/python3.9/site-packages/pip/_internal/commands/download.py +139 -0
  153. package/.venv/lib/python3.9/site-packages/pip/_internal/commands/freeze.py +97 -0
  154. package/.venv/lib/python3.9/site-packages/pip/_internal/commands/hash.py +59 -0
  155. package/.venv/lib/python3.9/site-packages/pip/_internal/commands/help.py +41 -0
  156. package/.venv/lib/python3.9/site-packages/pip/_internal/commands/index.py +138 -0
  157. package/.venv/lib/python3.9/site-packages/pip/_internal/commands/install.py +770 -0
  158. package/.venv/lib/python3.9/site-packages/pip/_internal/commands/list.py +361 -0
  159. package/.venv/lib/python3.9/site-packages/pip/_internal/commands/search.py +174 -0
  160. package/.venv/lib/python3.9/site-packages/pip/_internal/commands/show.py +235 -0
  161. package/.venv/lib/python3.9/site-packages/pip/_internal/commands/uninstall.py +105 -0
  162. package/.venv/lib/python3.9/site-packages/pip/_internal/commands/wheel.py +177 -0
  163. package/.venv/lib/python3.9/site-packages/pip/_internal/configuration.py +367 -0
  164. package/.venv/lib/python3.9/site-packages/pip/_internal/distributions/__init__.py +21 -0
  165. package/.venv/lib/python3.9/site-packages/pip/_internal/distributions/base.py +36 -0
  166. package/.venv/lib/python3.9/site-packages/pip/_internal/distributions/installed.py +22 -0
  167. package/.venv/lib/python3.9/site-packages/pip/_internal/distributions/sdist.py +129 -0
  168. package/.venv/lib/python3.9/site-packages/pip/_internal/distributions/wheel.py +31 -0
  169. package/.venv/lib/python3.9/site-packages/pip/_internal/exceptions.py +402 -0
  170. package/.venv/lib/python3.9/site-packages/pip/_internal/index/__init__.py +2 -0
  171. package/.venv/lib/python3.9/site-packages/pip/_internal/index/collector.py +536 -0
  172. package/.venv/lib/python3.9/site-packages/pip/_internal/index/package_finder.py +993 -0
  173. package/.venv/lib/python3.9/site-packages/pip/_internal/index/sources.py +224 -0
  174. package/.venv/lib/python3.9/site-packages/pip/_internal/locations/__init__.py +446 -0
  175. package/.venv/lib/python3.9/site-packages/pip/_internal/locations/_distutils.py +169 -0
  176. package/.venv/lib/python3.9/site-packages/pip/_internal/locations/_sysconfig.py +219 -0
  177. package/.venv/lib/python3.9/site-packages/pip/_internal/locations/base.py +52 -0
  178. package/.venv/lib/python3.9/site-packages/pip/_internal/main.py +12 -0
  179. package/.venv/lib/python3.9/site-packages/pip/_internal/metadata/__init__.py +51 -0
  180. package/.venv/lib/python3.9/site-packages/pip/_internal/metadata/base.py +330 -0
  181. package/.venv/lib/python3.9/site-packages/pip/_internal/metadata/pkg_resources.py +146 -0
  182. package/.venv/lib/python3.9/site-packages/pip/_internal/models/__init__.py +2 -0
  183. package/.venv/lib/python3.9/site-packages/pip/_internal/models/candidate.py +34 -0
  184. package/.venv/lib/python3.9/site-packages/pip/_internal/models/direct_url.py +220 -0
  185. package/.venv/lib/python3.9/site-packages/pip/_internal/models/format_control.py +80 -0
  186. package/.venv/lib/python3.9/site-packages/pip/_internal/models/index.py +28 -0
  187. package/.venv/lib/python3.9/site-packages/pip/_internal/models/link.py +288 -0
  188. package/.venv/lib/python3.9/site-packages/pip/_internal/models/scheme.py +31 -0
  189. package/.venv/lib/python3.9/site-packages/pip/_internal/models/search_scope.py +129 -0
  190. package/.venv/lib/python3.9/site-packages/pip/_internal/models/selection_prefs.py +51 -0
  191. package/.venv/lib/python3.9/site-packages/pip/_internal/models/target_python.py +110 -0
  192. package/.venv/lib/python3.9/site-packages/pip/_internal/models/wheel.py +89 -0
  193. package/.venv/lib/python3.9/site-packages/pip/_internal/network/__init__.py +2 -0
  194. package/.venv/lib/python3.9/site-packages/pip/_internal/network/auth.py +323 -0
  195. package/.venv/lib/python3.9/site-packages/pip/_internal/network/cache.py +69 -0
  196. package/.venv/lib/python3.9/site-packages/pip/_internal/network/download.py +184 -0
  197. package/.venv/lib/python3.9/site-packages/pip/_internal/network/lazy_wheel.py +210 -0
  198. package/.venv/lib/python3.9/site-packages/pip/_internal/network/session.py +454 -0
  199. package/.venv/lib/python3.9/site-packages/pip/_internal/network/utils.py +96 -0
  200. package/.venv/lib/python3.9/site-packages/pip/_internal/network/xmlrpc.py +60 -0
  201. package/.venv/lib/python3.9/site-packages/pip/_internal/operations/__init__.py +0 -0
  202. package/.venv/lib/python3.9/site-packages/pip/_internal/operations/build/__init__.py +0 -0
  203. package/.venv/lib/python3.9/site-packages/pip/_internal/operations/build/metadata.py +30 -0
  204. package/.venv/lib/python3.9/site-packages/pip/_internal/operations/build/metadata_editable.py +34 -0
  205. package/.venv/lib/python3.9/site-packages/pip/_internal/operations/build/metadata_legacy.py +67 -0
  206. package/.venv/lib/python3.9/site-packages/pip/_internal/operations/build/wheel.py +37 -0
  207. package/.venv/lib/python3.9/site-packages/pip/_internal/operations/build/wheel_editable.py +46 -0
  208. package/.venv/lib/python3.9/site-packages/pip/_internal/operations/build/wheel_legacy.py +105 -0
  209. package/.venv/lib/python3.9/site-packages/pip/_internal/operations/check.py +149 -0
  210. package/.venv/lib/python3.9/site-packages/pip/_internal/operations/freeze.py +254 -0
  211. package/.venv/lib/python3.9/site-packages/pip/_internal/operations/install/__init__.py +2 -0
  212. package/.venv/lib/python3.9/site-packages/pip/_internal/operations/install/editable_legacy.py +46 -0
  213. package/.venv/lib/python3.9/site-packages/pip/_internal/operations/install/legacy.py +125 -0
  214. package/.venv/lib/python3.9/site-packages/pip/_internal/operations/install/wheel.py +738 -0
  215. package/.venv/lib/python3.9/site-packages/pip/_internal/operations/prepare.py +632 -0
  216. package/.venv/lib/python3.9/site-packages/pip/_internal/pyproject.py +183 -0
  217. package/.venv/lib/python3.9/site-packages/pip/_internal/req/__init__.py +94 -0
  218. package/.venv/lib/python3.9/site-packages/pip/_internal/req/constructors.py +466 -0
  219. package/.venv/lib/python3.9/site-packages/pip/_internal/req/req_file.py +536 -0
  220. package/.venv/lib/python3.9/site-packages/pip/_internal/req/req_install.py +891 -0
  221. package/.venv/lib/python3.9/site-packages/pip/_internal/req/req_set.py +189 -0
  222. package/.venv/lib/python3.9/site-packages/pip/_internal/req/req_tracker.py +124 -0
  223. package/.venv/lib/python3.9/site-packages/pip/_internal/req/req_uninstall.py +633 -0
  224. package/.venv/lib/python3.9/site-packages/pip/_internal/resolution/__init__.py +0 -0
  225. package/.venv/lib/python3.9/site-packages/pip/_internal/resolution/base.py +20 -0
  226. package/.venv/lib/python3.9/site-packages/pip/_internal/resolution/legacy/__init__.py +0 -0
  227. package/.venv/lib/python3.9/site-packages/pip/_internal/resolution/legacy/resolver.py +467 -0
  228. package/.venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/__init__.py +0 -0
  229. package/.venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/base.py +141 -0
  230. package/.venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py +540 -0
  231. package/.venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/factory.py +701 -0
  232. package/.venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py +155 -0
  233. package/.venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/provider.py +215 -0
  234. package/.venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/reporter.py +68 -0
  235. package/.venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/requirements.py +166 -0
  236. package/.venv/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/resolver.py +251 -0
  237. package/.venv/lib/python3.9/site-packages/pip/_internal/self_outdated_check.py +182 -0
  238. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/__init__.py +0 -0
  239. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/_log.py +38 -0
  240. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/appdirs.py +52 -0
  241. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/compat.py +63 -0
  242. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/compatibility_tags.py +165 -0
  243. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/datetime.py +11 -0
  244. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/deprecation.py +120 -0
  245. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/direct_url_helpers.py +87 -0
  246. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/distutils_args.py +42 -0
  247. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/egg_link.py +75 -0
  248. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/encoding.py +36 -0
  249. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/entrypoints.py +27 -0
  250. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/filesystem.py +182 -0
  251. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/filetypes.py +27 -0
  252. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/glibc.py +88 -0
  253. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/hashes.py +144 -0
  254. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/inject_securetransport.py +35 -0
  255. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/logging.py +358 -0
  256. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/misc.py +689 -0
  257. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/models.py +39 -0
  258. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/packaging.py +84 -0
  259. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/parallel.py +103 -0
  260. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/pkg_resources.py +33 -0
  261. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/setuptools_build.py +167 -0
  262. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/subprocess.py +289 -0
  263. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/temp_dir.py +246 -0
  264. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/unpacking.py +258 -0
  265. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/urls.py +62 -0
  266. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/virtualenv.py +104 -0
  267. package/.venv/lib/python3.9/site-packages/pip/_internal/utils/wheel.py +182 -0
  268. package/.venv/lib/python3.9/site-packages/pip/_internal/vcs/__init__.py +15 -0
  269. package/.venv/lib/python3.9/site-packages/pip/_internal/vcs/bazaar.py +93 -0
  270. package/.venv/lib/python3.9/site-packages/pip/_internal/vcs/git.py +513 -0
  271. package/.venv/lib/python3.9/site-packages/pip/_internal/vcs/mercurial.py +153 -0
  272. package/.venv/lib/python3.9/site-packages/pip/_internal/vcs/subversion.py +318 -0
  273. package/.venv/lib/python3.9/site-packages/pip/_internal/vcs/versioncontrol.py +693 -0
  274. package/.venv/lib/python3.9/site-packages/pip/_internal/wheel_builder.py +375 -0
  275. package/.venv/lib/python3.9/site-packages/pip/_vendor/__init__.py +111 -0
  276. package/.venv/lib/python3.9/site-packages/pip/_vendor/cachecontrol/__init__.py +11 -0
  277. package/.venv/lib/python3.9/site-packages/pip/_vendor/cachecontrol/_cmd.py +57 -0
  278. package/.venv/lib/python3.9/site-packages/pip/_vendor/cachecontrol/adapter.py +133 -0
  279. package/.venv/lib/python3.9/site-packages/pip/_vendor/cachecontrol/cache.py +39 -0
  280. package/.venv/lib/python3.9/site-packages/pip/_vendor/cachecontrol/caches/__init__.py +2 -0
  281. package/.venv/lib/python3.9/site-packages/pip/_vendor/cachecontrol/caches/file_cache.py +146 -0
  282. package/.venv/lib/python3.9/site-packages/pip/_vendor/cachecontrol/caches/redis_cache.py +33 -0
  283. package/.venv/lib/python3.9/site-packages/pip/_vendor/cachecontrol/compat.py +29 -0
  284. package/.venv/lib/python3.9/site-packages/pip/_vendor/cachecontrol/controller.py +376 -0
  285. package/.venv/lib/python3.9/site-packages/pip/_vendor/cachecontrol/filewrapper.py +80 -0
  286. package/.venv/lib/python3.9/site-packages/pip/_vendor/cachecontrol/heuristics.py +135 -0
  287. package/.venv/lib/python3.9/site-packages/pip/_vendor/cachecontrol/serialize.py +188 -0
  288. package/.venv/lib/python3.9/site-packages/pip/_vendor/cachecontrol/wrapper.py +29 -0
  289. package/.venv/lib/python3.9/site-packages/pip/_vendor/certifi/__init__.py +3 -0
  290. package/.venv/lib/python3.9/site-packages/pip/_vendor/certifi/__main__.py +12 -0
  291. package/.venv/lib/python3.9/site-packages/pip/_vendor/certifi/cacert.pem +4257 -0
  292. package/.venv/lib/python3.9/site-packages/pip/_vendor/certifi/core.py +76 -0
  293. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/__init__.py +83 -0
  294. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/big5freq.py +386 -0
  295. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/big5prober.py +47 -0
  296. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/chardistribution.py +233 -0
  297. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/charsetgroupprober.py +107 -0
  298. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/charsetprober.py +145 -0
  299. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/cli/__init__.py +1 -0
  300. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/cli/chardetect.py +84 -0
  301. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/codingstatemachine.py +88 -0
  302. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/compat.py +36 -0
  303. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/cp949prober.py +49 -0
  304. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/enums.py +76 -0
  305. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/escprober.py +101 -0
  306. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/escsm.py +246 -0
  307. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/eucjpprober.py +92 -0
  308. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/euckrfreq.py +195 -0
  309. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/euckrprober.py +47 -0
  310. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/euctwfreq.py +387 -0
  311. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/euctwprober.py +46 -0
  312. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/gb2312freq.py +283 -0
  313. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/gb2312prober.py +46 -0
  314. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/hebrewprober.py +292 -0
  315. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/jisfreq.py +325 -0
  316. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/jpcntx.py +233 -0
  317. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/langbulgarianmodel.py +4650 -0
  318. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/langgreekmodel.py +4398 -0
  319. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/langhebrewmodel.py +4383 -0
  320. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/langhungarianmodel.py +4650 -0
  321. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/langrussianmodel.py +5718 -0
  322. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/langthaimodel.py +4383 -0
  323. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/langturkishmodel.py +4383 -0
  324. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/latin1prober.py +145 -0
  325. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/mbcharsetprober.py +91 -0
  326. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/mbcsgroupprober.py +54 -0
  327. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/mbcssm.py +572 -0
  328. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/metadata/__init__.py +0 -0
  329. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/metadata/languages.py +310 -0
  330. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/sbcharsetprober.py +145 -0
  331. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/sbcsgroupprober.py +83 -0
  332. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/sjisprober.py +92 -0
  333. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/universaldetector.py +286 -0
  334. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/utf8prober.py +82 -0
  335. package/.venv/lib/python3.9/site-packages/pip/_vendor/chardet/version.py +9 -0
  336. package/.venv/lib/python3.9/site-packages/pip/_vendor/colorama/__init__.py +6 -0
  337. package/.venv/lib/python3.9/site-packages/pip/_vendor/colorama/ansi.py +102 -0
  338. package/.venv/lib/python3.9/site-packages/pip/_vendor/colorama/ansitowin32.py +258 -0
  339. package/.venv/lib/python3.9/site-packages/pip/_vendor/colorama/initialise.py +80 -0
  340. package/.venv/lib/python3.9/site-packages/pip/_vendor/colorama/win32.py +152 -0
  341. package/.venv/lib/python3.9/site-packages/pip/_vendor/colorama/winterm.py +169 -0
  342. package/.venv/lib/python3.9/site-packages/pip/_vendor/distlib/__init__.py +23 -0
  343. package/.venv/lib/python3.9/site-packages/pip/_vendor/distlib/_backport/__init__.py +6 -0
  344. package/.venv/lib/python3.9/site-packages/pip/_vendor/distlib/_backport/misc.py +41 -0
  345. package/.venv/lib/python3.9/site-packages/pip/_vendor/distlib/_backport/shutil.py +764 -0
  346. package/.venv/lib/python3.9/site-packages/pip/_vendor/distlib/_backport/sysconfig.cfg +84 -0
  347. package/.venv/lib/python3.9/site-packages/pip/_vendor/distlib/_backport/sysconfig.py +786 -0
  348. package/.venv/lib/python3.9/site-packages/pip/_vendor/distlib/_backport/tarfile.py +2607 -0
  349. package/.venv/lib/python3.9/site-packages/pip/_vendor/distlib/compat.py +1122 -0
  350. package/.venv/lib/python3.9/site-packages/pip/_vendor/distlib/database.py +1339 -0
  351. package/.venv/lib/python3.9/site-packages/pip/_vendor/distlib/index.py +509 -0
  352. package/.venv/lib/python3.9/site-packages/pip/_vendor/distlib/locators.py +1300 -0
  353. package/.venv/lib/python3.9/site-packages/pip/_vendor/distlib/manifest.py +393 -0
  354. package/.venv/lib/python3.9/site-packages/pip/_vendor/distlib/markers.py +147 -0
  355. package/.venv/lib/python3.9/site-packages/pip/_vendor/distlib/metadata.py +1058 -0
  356. package/.venv/lib/python3.9/site-packages/pip/_vendor/distlib/resources.py +358 -0
  357. package/.venv/lib/python3.9/site-packages/pip/_vendor/distlib/scripts.py +429 -0
  358. package/.venv/lib/python3.9/site-packages/pip/_vendor/distlib/t32.exe +0 -0
  359. package/.venv/lib/python3.9/site-packages/pip/_vendor/distlib/t64-arm.exe +0 -0
  360. package/.venv/lib/python3.9/site-packages/pip/_vendor/distlib/t64.exe +0 -0
  361. package/.venv/lib/python3.9/site-packages/pip/_vendor/distlib/util.py +1969 -0
  362. package/.venv/lib/python3.9/site-packages/pip/_vendor/distlib/version.py +739 -0
  363. package/.venv/lib/python3.9/site-packages/pip/_vendor/distlib/w32.exe +0 -0
  364. package/.venv/lib/python3.9/site-packages/pip/_vendor/distlib/w64-arm.exe +0 -0
  365. package/.venv/lib/python3.9/site-packages/pip/_vendor/distlib/w64.exe +0 -0
  366. package/.venv/lib/python3.9/site-packages/pip/_vendor/distlib/wheel.py +1053 -0
  367. package/.venv/lib/python3.9/site-packages/pip/_vendor/distro.py +1386 -0
  368. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/__init__.py +35 -0
  369. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/_ihatexml.py +289 -0
  370. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/_inputstream.py +918 -0
  371. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/_tokenizer.py +1735 -0
  372. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/_trie/__init__.py +5 -0
  373. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/_trie/_base.py +40 -0
  374. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/_trie/py.py +67 -0
  375. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/_utils.py +159 -0
  376. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/constants.py +2946 -0
  377. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/filters/__init__.py +0 -0
  378. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/filters/alphabeticalattributes.py +29 -0
  379. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/filters/base.py +12 -0
  380. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/filters/inject_meta_charset.py +73 -0
  381. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/filters/lint.py +93 -0
  382. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/filters/optionaltags.py +207 -0
  383. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/filters/sanitizer.py +916 -0
  384. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/filters/whitespace.py +38 -0
  385. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/html5parser.py +2795 -0
  386. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/serializer.py +409 -0
  387. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/treeadapters/__init__.py +30 -0
  388. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/treeadapters/genshi.py +54 -0
  389. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/treeadapters/sax.py +50 -0
  390. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/treebuilders/__init__.py +88 -0
  391. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/treebuilders/base.py +417 -0
  392. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/treebuilders/dom.py +239 -0
  393. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/treebuilders/etree.py +343 -0
  394. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/treebuilders/etree_lxml.py +392 -0
  395. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/treewalkers/__init__.py +154 -0
  396. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/treewalkers/base.py +252 -0
  397. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/treewalkers/dom.py +43 -0
  398. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/treewalkers/etree.py +131 -0
  399. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/treewalkers/etree_lxml.py +215 -0
  400. package/.venv/lib/python3.9/site-packages/pip/_vendor/html5lib/treewalkers/genshi.py +69 -0
  401. package/.venv/lib/python3.9/site-packages/pip/_vendor/idna/__init__.py +44 -0
  402. package/.venv/lib/python3.9/site-packages/pip/_vendor/idna/codec.py +117 -0
  403. package/.venv/lib/python3.9/site-packages/pip/_vendor/idna/compat.py +16 -0
  404. package/.venv/lib/python3.9/site-packages/pip/_vendor/idna/core.py +409 -0
  405. package/.venv/lib/python3.9/site-packages/pip/_vendor/idna/idnadata.py +2050 -0
  406. package/.venv/lib/python3.9/site-packages/pip/_vendor/idna/intranges.py +58 -0
  407. package/.venv/lib/python3.9/site-packages/pip/_vendor/idna/package_data.py +2 -0
  408. package/.venv/lib/python3.9/site-packages/pip/_vendor/idna/uts46data.py +8438 -0
  409. package/.venv/lib/python3.9/site-packages/pip/_vendor/msgpack/__init__.py +54 -0
  410. package/.venv/lib/python3.9/site-packages/pip/_vendor/msgpack/_version.py +1 -0
  411. package/.venv/lib/python3.9/site-packages/pip/_vendor/msgpack/exceptions.py +48 -0
  412. package/.venv/lib/python3.9/site-packages/pip/_vendor/msgpack/ext.py +193 -0
  413. package/.venv/lib/python3.9/site-packages/pip/_vendor/msgpack/fallback.py +1087 -0
  414. package/.venv/lib/python3.9/site-packages/pip/_vendor/packaging/__about__.py +26 -0
  415. package/.venv/lib/python3.9/site-packages/pip/_vendor/packaging/__init__.py +25 -0
  416. package/.venv/lib/python3.9/site-packages/pip/_vendor/packaging/_manylinux.py +301 -0
  417. package/.venv/lib/python3.9/site-packages/pip/_vendor/packaging/_musllinux.py +136 -0
  418. package/.venv/lib/python3.9/site-packages/pip/_vendor/packaging/_structures.py +67 -0
  419. package/.venv/lib/python3.9/site-packages/pip/_vendor/packaging/markers.py +304 -0
  420. package/.venv/lib/python3.9/site-packages/pip/_vendor/packaging/requirements.py +146 -0
  421. package/.venv/lib/python3.9/site-packages/pip/_vendor/packaging/specifiers.py +828 -0
  422. package/.venv/lib/python3.9/site-packages/pip/_vendor/packaging/tags.py +484 -0
  423. package/.venv/lib/python3.9/site-packages/pip/_vendor/packaging/utils.py +136 -0
  424. package/.venv/lib/python3.9/site-packages/pip/_vendor/packaging/version.py +504 -0
  425. package/.venv/lib/python3.9/site-packages/pip/_vendor/pep517/__init__.py +6 -0
  426. package/.venv/lib/python3.9/site-packages/pip/_vendor/pep517/build.py +127 -0
  427. package/.venv/lib/python3.9/site-packages/pip/_vendor/pep517/check.py +207 -0
  428. package/.venv/lib/python3.9/site-packages/pip/_vendor/pep517/colorlog.py +115 -0
  429. package/.venv/lib/python3.9/site-packages/pip/_vendor/pep517/compat.py +51 -0
  430. package/.venv/lib/python3.9/site-packages/pip/_vendor/pep517/dirtools.py +44 -0
  431. package/.venv/lib/python3.9/site-packages/pip/_vendor/pep517/envbuild.py +171 -0
  432. package/.venv/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/__init__.py +17 -0
  433. package/.venv/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py +363 -0
  434. package/.venv/lib/python3.9/site-packages/pip/_vendor/pep517/meta.py +92 -0
  435. package/.venv/lib/python3.9/site-packages/pip/_vendor/pep517/wrappers.py +375 -0
  436. package/.venv/lib/python3.9/site-packages/pip/_vendor/pkg_resources/__init__.py +3296 -0
  437. package/.venv/lib/python3.9/site-packages/pip/_vendor/pkg_resources/py31compat.py +23 -0
  438. package/.venv/lib/python3.9/site-packages/pip/_vendor/platformdirs/__init__.py +329 -0
  439. package/.venv/lib/python3.9/site-packages/pip/_vendor/platformdirs/__main__.py +44 -0
  440. package/.venv/lib/python3.9/site-packages/pip/_vendor/platformdirs/android.py +117 -0
  441. package/.venv/lib/python3.9/site-packages/pip/_vendor/platformdirs/api.py +155 -0
  442. package/.venv/lib/python3.9/site-packages/pip/_vendor/platformdirs/macos.py +62 -0
  443. package/.venv/lib/python3.9/site-packages/pip/_vendor/platformdirs/unix.py +180 -0
  444. package/.venv/lib/python3.9/site-packages/pip/_vendor/platformdirs/version.py +4 -0
  445. package/.venv/lib/python3.9/site-packages/pip/_vendor/platformdirs/windows.py +180 -0
  446. package/.venv/lib/python3.9/site-packages/pip/_vendor/progress/__init__.py +189 -0
  447. package/.venv/lib/python3.9/site-packages/pip/_vendor/progress/bar.py +93 -0
  448. package/.venv/lib/python3.9/site-packages/pip/_vendor/progress/colors.py +79 -0
  449. package/.venv/lib/python3.9/site-packages/pip/_vendor/progress/counter.py +47 -0
  450. package/.venv/lib/python3.9/site-packages/pip/_vendor/progress/spinner.py +45 -0
  451. package/.venv/lib/python3.9/site-packages/pip/_vendor/pyparsing.py +7107 -0
  452. package/.venv/lib/python3.9/site-packages/pip/_vendor/requests/__init__.py +154 -0
  453. package/.venv/lib/python3.9/site-packages/pip/_vendor/requests/__version__.py +14 -0
  454. package/.venv/lib/python3.9/site-packages/pip/_vendor/requests/_internal_utils.py +42 -0
  455. package/.venv/lib/python3.9/site-packages/pip/_vendor/requests/adapters.py +533 -0
  456. package/.venv/lib/python3.9/site-packages/pip/_vendor/requests/api.py +159 -0
  457. package/.venv/lib/python3.9/site-packages/pip/_vendor/requests/auth.py +305 -0
  458. package/.venv/lib/python3.9/site-packages/pip/_vendor/requests/certs.py +18 -0
  459. package/.venv/lib/python3.9/site-packages/pip/_vendor/requests/compat.py +76 -0
  460. package/.venv/lib/python3.9/site-packages/pip/_vendor/requests/cookies.py +549 -0
  461. package/.venv/lib/python3.9/site-packages/pip/_vendor/requests/exceptions.py +127 -0
  462. package/.venv/lib/python3.9/site-packages/pip/_vendor/requests/help.py +132 -0
  463. package/.venv/lib/python3.9/site-packages/pip/_vendor/requests/hooks.py +34 -0
  464. package/.venv/lib/python3.9/site-packages/pip/_vendor/requests/models.py +966 -0
  465. package/.venv/lib/python3.9/site-packages/pip/_vendor/requests/packages.py +16 -0
  466. package/.venv/lib/python3.9/site-packages/pip/_vendor/requests/sessions.py +781 -0
  467. package/.venv/lib/python3.9/site-packages/pip/_vendor/requests/status_codes.py +123 -0
  468. package/.venv/lib/python3.9/site-packages/pip/_vendor/requests/structures.py +105 -0
  469. package/.venv/lib/python3.9/site-packages/pip/_vendor/requests/utils.py +1013 -0
  470. package/.venv/lib/python3.9/site-packages/pip/_vendor/resolvelib/__init__.py +26 -0
  471. package/.venv/lib/python3.9/site-packages/pip/_vendor/resolvelib/compat/__init__.py +0 -0
  472. package/.venv/lib/python3.9/site-packages/pip/_vendor/resolvelib/compat/collections_abc.py +6 -0
  473. package/.venv/lib/python3.9/site-packages/pip/_vendor/resolvelib/providers.py +133 -0
  474. package/.venv/lib/python3.9/site-packages/pip/_vendor/resolvelib/reporters.py +37 -0
  475. package/.venv/lib/python3.9/site-packages/pip/_vendor/resolvelib/resolvers.py +483 -0
  476. package/.venv/lib/python3.9/site-packages/pip/_vendor/resolvelib/structs.py +165 -0
  477. package/.venv/lib/python3.9/site-packages/pip/_vendor/six.py +998 -0
  478. package/.venv/lib/python3.9/site-packages/pip/_vendor/tenacity/__init__.py +517 -0
  479. package/.venv/lib/python3.9/site-packages/pip/_vendor/tenacity/_asyncio.py +92 -0
  480. package/.venv/lib/python3.9/site-packages/pip/_vendor/tenacity/_utils.py +68 -0
  481. package/.venv/lib/python3.9/site-packages/pip/_vendor/tenacity/after.py +46 -0
  482. package/.venv/lib/python3.9/site-packages/pip/_vendor/tenacity/before.py +41 -0
  483. package/.venv/lib/python3.9/site-packages/pip/_vendor/tenacity/before_sleep.py +58 -0
  484. package/.venv/lib/python3.9/site-packages/pip/_vendor/tenacity/nap.py +43 -0
  485. package/.venv/lib/python3.9/site-packages/pip/_vendor/tenacity/retry.py +213 -0
  486. package/.venv/lib/python3.9/site-packages/pip/_vendor/tenacity/stop.py +96 -0
  487. package/.venv/lib/python3.9/site-packages/pip/_vendor/tenacity/tornadoweb.py +59 -0
  488. package/.venv/lib/python3.9/site-packages/pip/_vendor/tenacity/wait.py +191 -0
  489. package/.venv/lib/python3.9/site-packages/pip/_vendor/tomli/__init__.py +6 -0
  490. package/.venv/lib/python3.9/site-packages/pip/_vendor/tomli/_parser.py +703 -0
  491. package/.venv/lib/python3.9/site-packages/pip/_vendor/tomli/_re.py +83 -0
  492. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/__init__.py +85 -0
  493. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/_collections.py +337 -0
  494. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/_version.py +2 -0
  495. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/connection.py +569 -0
  496. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/connectionpool.py +1078 -0
  497. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/contrib/__init__.py +0 -0
  498. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/contrib/_appengine_environ.py +36 -0
  499. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/contrib/_securetransport/__init__.py +0 -0
  500. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/contrib/_securetransport/bindings.py +519 -0
  501. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/contrib/_securetransport/low_level.py +397 -0
  502. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/contrib/appengine.py +314 -0
  503. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/contrib/ntlmpool.py +130 -0
  504. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py +511 -0
  505. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/contrib/securetransport.py +922 -0
  506. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/contrib/socks.py +216 -0
  507. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/exceptions.py +323 -0
  508. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/fields.py +274 -0
  509. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/filepost.py +98 -0
  510. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/packages/__init__.py +5 -0
  511. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/packages/backports/__init__.py +0 -0
  512. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/packages/backports/makefile.py +51 -0
  513. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/packages/six.py +1077 -0
  514. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/packages/ssl_match_hostname/__init__.py +24 -0
  515. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/packages/ssl_match_hostname/_implementation.py +160 -0
  516. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/poolmanager.py +536 -0
  517. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/request.py +170 -0
  518. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/response.py +821 -0
  519. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/util/__init__.py +49 -0
  520. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/util/connection.py +150 -0
  521. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/util/proxy.py +57 -0
  522. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/util/queue.py +22 -0
  523. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/util/request.py +143 -0
  524. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/util/response.py +107 -0
  525. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/util/retry.py +602 -0
  526. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/util/ssl_.py +495 -0
  527. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/util/ssltransport.py +221 -0
  528. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/util/timeout.py +268 -0
  529. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/util/url.py +432 -0
  530. package/.venv/lib/python3.9/site-packages/pip/_vendor/urllib3/util/wait.py +153 -0
  531. package/.venv/lib/python3.9/site-packages/pip/_vendor/vendor.txt +22 -0
  532. package/.venv/lib/python3.9/site-packages/pip/_vendor/webencodings/__init__.py +342 -0
  533. package/.venv/lib/python3.9/site-packages/pip/_vendor/webencodings/labels.py +231 -0
  534. package/.venv/lib/python3.9/site-packages/pip/_vendor/webencodings/mklabels.py +59 -0
  535. package/.venv/lib/python3.9/site-packages/pip/_vendor/webencodings/tests.py +153 -0
  536. package/.venv/lib/python3.9/site-packages/pip/_vendor/webencodings/x_user_defined.py +325 -0
  537. package/.venv/lib/python3.9/site-packages/pip/py.typed +4 -0
  538. package/.venv/lib/python3.9/site-packages/pip-21.3.1.dist-info/INSTALLER +1 -0
  539. package/.venv/lib/python3.9/site-packages/pip-21.3.1.dist-info/LICENSE.txt +20 -0
  540. package/.venv/lib/python3.9/site-packages/pip-21.3.1.dist-info/METADATA +93 -0
  541. package/.venv/lib/python3.9/site-packages/pip-21.3.1.dist-info/RECORD +819 -0
  542. package/.venv/lib/python3.9/site-packages/pip-21.3.1.dist-info/REQUESTED +0 -0
  543. package/.venv/lib/python3.9/site-packages/pip-21.3.1.dist-info/WHEEL +5 -0
  544. package/.venv/lib/python3.9/site-packages/pip-21.3.1.dist-info/entry_points.txt +5 -0
  545. package/.venv/lib/python3.9/site-packages/pip-21.3.1.dist-info/top_level.txt +1 -0
  546. package/.venv/lib/python3.9/site-packages/pkg_resources/__init__.py +3303 -0
  547. package/.venv/lib/python3.9/site-packages/pkg_resources/_vendor/__init__.py +0 -0
  548. package/.venv/lib/python3.9/site-packages/pkg_resources/_vendor/appdirs.py +608 -0
  549. package/.venv/lib/python3.9/site-packages/pkg_resources/_vendor/packaging/__about__.py +26 -0
  550. package/.venv/lib/python3.9/site-packages/pkg_resources/_vendor/packaging/__init__.py +25 -0
  551. package/.venv/lib/python3.9/site-packages/pkg_resources/_vendor/packaging/_manylinux.py +301 -0
  552. package/.venv/lib/python3.9/site-packages/pkg_resources/_vendor/packaging/_musllinux.py +136 -0
  553. package/.venv/lib/python3.9/site-packages/pkg_resources/_vendor/packaging/_structures.py +67 -0
  554. package/.venv/lib/python3.9/site-packages/pkg_resources/_vendor/packaging/markers.py +304 -0
  555. package/.venv/lib/python3.9/site-packages/pkg_resources/_vendor/packaging/requirements.py +146 -0
  556. package/.venv/lib/python3.9/site-packages/pkg_resources/_vendor/packaging/specifiers.py +828 -0
  557. package/.venv/lib/python3.9/site-packages/pkg_resources/_vendor/packaging/tags.py +484 -0
  558. package/.venv/lib/python3.9/site-packages/pkg_resources/_vendor/packaging/utils.py +136 -0
  559. package/.venv/lib/python3.9/site-packages/pkg_resources/_vendor/packaging/version.py +504 -0
  560. package/.venv/lib/python3.9/site-packages/pkg_resources/_vendor/pyparsing.py +5742 -0
  561. package/.venv/lib/python3.9/site-packages/pkg_resources/extern/__init__.py +73 -0
  562. package/.venv/lib/python3.9/site-packages/pkg_resources/tests/data/my-test-package-source/setup.py +6 -0
  563. package/.venv/lib/python3.9/site-packages/setuptools/__init__.py +244 -0
  564. package/.venv/lib/python3.9/site-packages/setuptools/_deprecation_warning.py +7 -0
  565. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/__init__.py +24 -0
  566. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/_collections.py +56 -0
  567. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/_msvccompiler.py +561 -0
  568. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/archive_util.py +256 -0
  569. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/bcppcompiler.py +393 -0
  570. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/ccompiler.py +1123 -0
  571. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/cmd.py +403 -0
  572. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/command/__init__.py +31 -0
  573. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/command/bdist.py +143 -0
  574. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/command/bdist_dumb.py +123 -0
  575. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/command/bdist_msi.py +749 -0
  576. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/command/bdist_rpm.py +579 -0
  577. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/command/bdist_wininst.py +377 -0
  578. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/command/build.py +157 -0
  579. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/command/build_clib.py +209 -0
  580. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py +755 -0
  581. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/command/build_py.py +392 -0
  582. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/command/build_scripts.py +152 -0
  583. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/command/check.py +148 -0
  584. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/command/clean.py +76 -0
  585. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/command/config.py +344 -0
  586. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/command/install.py +775 -0
  587. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/command/install_data.py +79 -0
  588. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/command/install_egg_info.py +84 -0
  589. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/command/install_headers.py +47 -0
  590. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/command/install_lib.py +217 -0
  591. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/command/install_scripts.py +60 -0
  592. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/command/py37compat.py +30 -0
  593. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/command/register.py +304 -0
  594. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/command/sdist.py +494 -0
  595. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/command/upload.py +214 -0
  596. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/config.py +130 -0
  597. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/core.py +249 -0
  598. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/cygwinccompiler.py +362 -0
  599. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/debug.py +5 -0
  600. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/dep_util.py +92 -0
  601. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/dir_util.py +210 -0
  602. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/dist.py +1257 -0
  603. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/errors.py +97 -0
  604. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/extension.py +240 -0
  605. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/fancy_getopt.py +457 -0
  606. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/file_util.py +238 -0
  607. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/filelist.py +355 -0
  608. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/log.py +81 -0
  609. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/msvc9compiler.py +788 -0
  610. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/msvccompiler.py +643 -0
  611. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/py35compat.py +19 -0
  612. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/py38compat.py +7 -0
  613. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/spawn.py +106 -0
  614. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/sysconfig.py +567 -0
  615. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/text_file.py +286 -0
  616. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/unixccompiler.py +325 -0
  617. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/util.py +548 -0
  618. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/version.py +363 -0
  619. package/.venv/lib/python3.9/site-packages/setuptools/_distutils/versionpredicate.py +169 -0
  620. package/.venv/lib/python3.9/site-packages/setuptools/_imp.py +82 -0
  621. package/.venv/lib/python3.9/site-packages/setuptools/_vendor/__init__.py +0 -0
  622. package/.venv/lib/python3.9/site-packages/setuptools/_vendor/more_itertools/__init__.py +4 -0
  623. package/.venv/lib/python3.9/site-packages/setuptools/_vendor/more_itertools/more.py +3825 -0
  624. package/.venv/lib/python3.9/site-packages/setuptools/_vendor/more_itertools/recipes.py +620 -0
  625. package/.venv/lib/python3.9/site-packages/setuptools/_vendor/ordered_set.py +488 -0
  626. package/.venv/lib/python3.9/site-packages/setuptools/_vendor/packaging/__about__.py +26 -0
  627. package/.venv/lib/python3.9/site-packages/setuptools/_vendor/packaging/__init__.py +25 -0
  628. package/.venv/lib/python3.9/site-packages/setuptools/_vendor/packaging/_manylinux.py +301 -0
  629. package/.venv/lib/python3.9/site-packages/setuptools/_vendor/packaging/_musllinux.py +136 -0
  630. package/.venv/lib/python3.9/site-packages/setuptools/_vendor/packaging/_structures.py +67 -0
  631. package/.venv/lib/python3.9/site-packages/setuptools/_vendor/packaging/markers.py +304 -0
  632. package/.venv/lib/python3.9/site-packages/setuptools/_vendor/packaging/requirements.py +146 -0
  633. package/.venv/lib/python3.9/site-packages/setuptools/_vendor/packaging/specifiers.py +828 -0
  634. package/.venv/lib/python3.9/site-packages/setuptools/_vendor/packaging/tags.py +484 -0
  635. package/.venv/lib/python3.9/site-packages/setuptools/_vendor/packaging/utils.py +136 -0
  636. package/.venv/lib/python3.9/site-packages/setuptools/_vendor/packaging/version.py +504 -0
  637. package/.venv/lib/python3.9/site-packages/setuptools/_vendor/pyparsing.py +5742 -0
  638. package/.venv/lib/python3.9/site-packages/setuptools/archive_util.py +205 -0
  639. package/.venv/lib/python3.9/site-packages/setuptools/build_meta.py +290 -0
  640. package/.venv/lib/python3.9/site-packages/setuptools/cli-32.exe +0 -0
  641. package/.venv/lib/python3.9/site-packages/setuptools/cli-64.exe +0 -0
  642. package/.venv/lib/python3.9/site-packages/setuptools/cli-arm64.exe +0 -0
  643. package/.venv/lib/python3.9/site-packages/setuptools/cli.exe +0 -0
  644. package/.venv/lib/python3.9/site-packages/setuptools/command/__init__.py +8 -0
  645. package/.venv/lib/python3.9/site-packages/setuptools/command/alias.py +78 -0
  646. package/.venv/lib/python3.9/site-packages/setuptools/command/bdist_egg.py +456 -0
  647. package/.venv/lib/python3.9/site-packages/setuptools/command/bdist_rpm.py +40 -0
  648. package/.venv/lib/python3.9/site-packages/setuptools/command/build_clib.py +101 -0
  649. package/.venv/lib/python3.9/site-packages/setuptools/command/build_ext.py +328 -0
  650. package/.venv/lib/python3.9/site-packages/setuptools/command/build_py.py +242 -0
  651. package/.venv/lib/python3.9/site-packages/setuptools/command/develop.py +193 -0
  652. package/.venv/lib/python3.9/site-packages/setuptools/command/dist_info.py +36 -0
  653. package/.venv/lib/python3.9/site-packages/setuptools/command/easy_install.py +2304 -0
  654. package/.venv/lib/python3.9/site-packages/setuptools/command/egg_info.py +755 -0
  655. package/.venv/lib/python3.9/site-packages/setuptools/command/install.py +132 -0
  656. package/.venv/lib/python3.9/site-packages/setuptools/command/install_egg_info.py +62 -0
  657. package/.venv/lib/python3.9/site-packages/setuptools/command/install_lib.py +122 -0
  658. package/.venv/lib/python3.9/site-packages/setuptools/command/install_scripts.py +69 -0
  659. package/.venv/lib/python3.9/site-packages/setuptools/command/launcher manifest.xml +15 -0
  660. package/.venv/lib/python3.9/site-packages/setuptools/command/py36compat.py +134 -0
  661. package/.venv/lib/python3.9/site-packages/setuptools/command/register.py +18 -0
  662. package/.venv/lib/python3.9/site-packages/setuptools/command/rotate.py +64 -0
  663. package/.venv/lib/python3.9/site-packages/setuptools/command/saveopts.py +22 -0
  664. package/.venv/lib/python3.9/site-packages/setuptools/command/sdist.py +196 -0
  665. package/.venv/lib/python3.9/site-packages/setuptools/command/setopt.py +149 -0
  666. package/.venv/lib/python3.9/site-packages/setuptools/command/test.py +252 -0
  667. package/.venv/lib/python3.9/site-packages/setuptools/command/upload.py +17 -0
  668. package/.venv/lib/python3.9/site-packages/setuptools/command/upload_docs.py +202 -0
  669. package/.venv/lib/python3.9/site-packages/setuptools/config.py +751 -0
  670. package/.venv/lib/python3.9/site-packages/setuptools/dep_util.py +25 -0
  671. package/.venv/lib/python3.9/site-packages/setuptools/depends.py +176 -0
  672. package/.venv/lib/python3.9/site-packages/setuptools/dist.py +1156 -0
  673. package/.venv/lib/python3.9/site-packages/setuptools/errors.py +40 -0
  674. package/.venv/lib/python3.9/site-packages/setuptools/extension.py +55 -0
  675. package/.venv/lib/python3.9/site-packages/setuptools/extern/__init__.py +73 -0
  676. package/.venv/lib/python3.9/site-packages/setuptools/glob.py +167 -0
  677. package/.venv/lib/python3.9/site-packages/setuptools/gui-32.exe +0 -0
  678. package/.venv/lib/python3.9/site-packages/setuptools/gui-64.exe +0 -0
  679. package/.venv/lib/python3.9/site-packages/setuptools/gui-arm64.exe +0 -0
  680. package/.venv/lib/python3.9/site-packages/setuptools/gui.exe +0 -0
  681. package/.venv/lib/python3.9/site-packages/setuptools/installer.py +104 -0
  682. package/.venv/lib/python3.9/site-packages/setuptools/launch.py +36 -0
  683. package/.venv/lib/python3.9/site-packages/setuptools/logging.py +30 -0
  684. package/.venv/lib/python3.9/site-packages/setuptools/monkey.py +177 -0
  685. package/.venv/lib/python3.9/site-packages/setuptools/msvc.py +1805 -0
  686. package/.venv/lib/python3.9/site-packages/setuptools/namespaces.py +107 -0
  687. package/.venv/lib/python3.9/site-packages/setuptools/package_index.py +1127 -0
  688. package/.venv/lib/python3.9/site-packages/setuptools/py34compat.py +13 -0
  689. package/.venv/lib/python3.9/site-packages/setuptools/sandbox.py +530 -0
  690. package/.venv/lib/python3.9/site-packages/setuptools/script (dev).tmpl +6 -0
  691. package/.venv/lib/python3.9/site-packages/setuptools/script.tmpl +3 -0
  692. package/.venv/lib/python3.9/site-packages/setuptools/tests/integration/__init__.py +0 -0
  693. package/.venv/lib/python3.9/site-packages/setuptools/tests/integration/helpers.py +61 -0
  694. package/.venv/lib/python3.9/site-packages/setuptools/tests/integration/test_pip_install_sdist.py +218 -0
  695. package/.venv/lib/python3.9/site-packages/setuptools/unicode_utils.py +42 -0
  696. package/.venv/lib/python3.9/site-packages/setuptools/version.py +6 -0
  697. package/.venv/lib/python3.9/site-packages/setuptools/wheel.py +213 -0
  698. package/.venv/lib/python3.9/site-packages/setuptools/windows_support.py +29 -0
  699. package/.venv/lib/python3.9/site-packages/setuptools-60.5.0.dist-info/INSTALLER +1 -0
  700. package/.venv/lib/python3.9/site-packages/setuptools-60.5.0.dist-info/LICENSE +19 -0
  701. package/.venv/lib/python3.9/site-packages/setuptools-60.5.0.dist-info/METADATA +142 -0
  702. package/.venv/lib/python3.9/site-packages/setuptools-60.5.0.dist-info/RECORD +308 -0
  703. package/.venv/lib/python3.9/site-packages/setuptools-60.5.0.dist-info/REQUESTED +0 -0
  704. package/.venv/lib/python3.9/site-packages/setuptools-60.5.0.dist-info/WHEEL +5 -0
  705. package/.venv/lib/python3.9/site-packages/setuptools-60.5.0.dist-info/entry_points.txt +56 -0
  706. package/.venv/lib/python3.9/site-packages/setuptools-60.5.0.dist-info/top_level.txt +3 -0
  707. package/.venv/pyvenv.cfg +3 -0
  708. package/dist/http-interfaces.js +8 -4
  709. package/dist/http-interfaces.js.map +1 -1
  710. package/dist/plugin/media.js +29 -14
  711. package/dist/plugin/media.js.map +1 -1
  712. package/dist/plugin/plugin-console.js +13 -3
  713. package/dist/plugin/plugin-console.js.map +1 -1
  714. package/dist/plugin/plugin-device.js +1 -1
  715. package/dist/plugin/plugin-device.js.map +1 -1
  716. package/dist/plugin/plugin-host-api.js +1 -1
  717. package/dist/plugin/plugin-host-api.js.map +1 -1
  718. package/dist/plugin/plugin-host.js +36 -127
  719. package/dist/plugin/plugin-host.js.map +1 -1
  720. package/dist/plugin/plugin-remote-worker.js +5 -42
  721. package/dist/plugin/plugin-remote-worker.js.map +1 -1
  722. package/dist/plugin/plugin-remote.js +3 -3
  723. package/dist/plugin/plugin-remote.js.map +1 -1
  724. package/dist/plugin/runtime/child-process-worker.js +42 -0
  725. package/dist/plugin/runtime/child-process-worker.js.map +1 -0
  726. package/dist/plugin/runtime/node-fork-worker.js +51 -0
  727. package/dist/plugin/runtime/node-fork-worker.js.map +1 -0
  728. package/dist/plugin/runtime/node-thread-worker.js +73 -0
  729. package/dist/plugin/runtime/node-thread-worker.js.map +1 -0
  730. package/dist/plugin/runtime/python-worker.js +54 -0
  731. package/dist/plugin/runtime/python-worker.js.map +1 -0
  732. package/dist/plugin/runtime/runtime-worker.js +3 -0
  733. package/dist/plugin/runtime/runtime-worker.js.map +1 -0
  734. package/dist/plugin/system.js +3 -3
  735. package/dist/plugin/system.js.map +1 -1
  736. package/dist/rpc.js +79 -55
  737. package/dist/rpc.js.map +1 -1
  738. package/dist/runtime.js +1 -6
  739. package/dist/runtime.js.map +1 -1
  740. package/dist/scrypted-main.js +14 -7
  741. package/dist/scrypted-main.js.map +1 -1
  742. package/dist/scrypted-plugin-main.js +31 -4
  743. package/dist/scrypted-plugin-main.js.map +1 -1
  744. package/dist/scrypted-server-main.js +1 -1
  745. package/dist/scrypted-server-main.js.map +1 -1
  746. package/dist/threading.js +99 -0
  747. package/dist/threading.js.map +1 -0
  748. package/package.json +5 -3
  749. package/python/plugin-remote.py +31 -2
  750. package/python/rpc.py +6 -0
  751. package/src/http-interfaces.ts +10 -5
  752. package/src/plugin/media.ts +34 -16
  753. package/src/plugin/plugin-console.ts +15 -6
  754. package/src/plugin/plugin-device.ts +2 -2
  755. package/src/plugin/plugin-host-api.ts +2 -2
  756. package/src/plugin/plugin-host.ts +42 -146
  757. package/src/plugin/plugin-remote-websocket.ts +1 -1
  758. package/src/plugin/plugin-remote-worker.ts +7 -44
  759. package/src/plugin/plugin-remote.ts +5 -5
  760. package/src/plugin/runtime/child-process-worker.ts +49 -0
  761. package/src/plugin/runtime/node-fork-worker.ts +54 -0
  762. package/src/plugin/runtime/node-thread-worker.ts +76 -0
  763. package/src/plugin/runtime/python-worker.ts +67 -0
  764. package/src/plugin/runtime/runtime-worker.ts +28 -0
  765. package/src/plugin/system.ts +4 -4
  766. package/src/rpc.ts +92 -66
  767. package/src/runtime.ts +1 -8
  768. package/src/scrypted-main.ts +15 -7
  769. package/src/scrypted-plugin-main.ts +31 -5
  770. package/src/scrypted-server-main.ts +1 -1
  771. package/src/threading.ts +108 -0
@@ -0,0 +1,3303 @@
1
+ """
2
+ Package resource API
3
+ --------------------
4
+
5
+ A resource is a logical file contained within a package, or a logical
6
+ subdirectory thereof. The package resource API expects resource names
7
+ to have their path parts separated with ``/``, *not* whatever the local
8
+ path separator is. Do not use os.path operations to manipulate resource
9
+ names being passed into the API.
10
+
11
+ The package resource API is designed to work with normal filesystem packages,
12
+ .egg files, and unpacked .egg files. It can also work in a limited way with
13
+ .zip files and with custom PEP 302 loaders that support the ``get_data()``
14
+ method.
15
+ """
16
+
17
+ import sys
18
+ import os
19
+ import io
20
+ import time
21
+ import re
22
+ import types
23
+ import zipfile
24
+ import zipimport
25
+ import warnings
26
+ import stat
27
+ import functools
28
+ import pkgutil
29
+ import operator
30
+ import platform
31
+ import collections
32
+ import plistlib
33
+ import email.parser
34
+ import errno
35
+ import tempfile
36
+ import textwrap
37
+ import itertools
38
+ import inspect
39
+ import ntpath
40
+ import posixpath
41
+ import importlib
42
+ from pkgutil import get_importer
43
+
44
+ try:
45
+ import _imp
46
+ except ImportError:
47
+ # Python 3.2 compatibility
48
+ import imp as _imp
49
+
50
+ try:
51
+ FileExistsError
52
+ except NameError:
53
+ FileExistsError = OSError
54
+
55
+ # capture these to bypass sandboxing
56
+ from os import utime
57
+ try:
58
+ from os import mkdir, rename, unlink
59
+ WRITE_SUPPORT = True
60
+ except ImportError:
61
+ # no write support, probably under GAE
62
+ WRITE_SUPPORT = False
63
+
64
+ from os import open as os_open
65
+ from os.path import isdir, split
66
+
67
+ try:
68
+ import importlib.machinery as importlib_machinery
69
+ # access attribute to force import under delayed import mechanisms.
70
+ importlib_machinery.__name__
71
+ except ImportError:
72
+ importlib_machinery = None
73
+
74
+ from pkg_resources.extern import appdirs
75
+ from pkg_resources.extern import packaging
76
+ __import__('pkg_resources.extern.packaging.version')
77
+ __import__('pkg_resources.extern.packaging.specifiers')
78
+ __import__('pkg_resources.extern.packaging.requirements')
79
+ __import__('pkg_resources.extern.packaging.markers')
80
+
81
+ if sys.version_info < (3, 5):
82
+ raise RuntimeError("Python 3.5 or later is required")
83
+
84
+ # declare some globals that will be defined later to
85
+ # satisfy the linters.
86
+ require = None
87
+ working_set = None
88
+ add_activation_listener = None
89
+ resources_stream = None
90
+ cleanup_resources = None
91
+ resource_dir = None
92
+ resource_stream = None
93
+ set_extraction_path = None
94
+ resource_isdir = None
95
+ resource_string = None
96
+ iter_entry_points = None
97
+ resource_listdir = None
98
+ resource_filename = None
99
+ resource_exists = None
100
+ _distribution_finders = None
101
+ _namespace_handlers = None
102
+ _namespace_packages = None
103
+
104
+
105
+ class PEP440Warning(RuntimeWarning):
106
+ """
107
+ Used when there is an issue with a version or specifier not complying with
108
+ PEP 440.
109
+ """
110
+
111
+
112
+ def parse_version(v):
113
+ try:
114
+ return packaging.version.Version(v)
115
+ except packaging.version.InvalidVersion:
116
+ warnings.warn(
117
+ f"{v} is an invalid version and will not be supported in "
118
+ "a future release",
119
+ PkgResourcesDeprecationWarning,
120
+ )
121
+ return packaging.version.LegacyVersion(v)
122
+
123
+
124
+ _state_vars = {}
125
+
126
+
127
+ def _declare_state(vartype, **kw):
128
+ globals().update(kw)
129
+ _state_vars.update(dict.fromkeys(kw, vartype))
130
+
131
+
132
+ def __getstate__():
133
+ state = {}
134
+ g = globals()
135
+ for k, v in _state_vars.items():
136
+ state[k] = g['_sget_' + v](g[k])
137
+ return state
138
+
139
+
140
+ def __setstate__(state):
141
+ g = globals()
142
+ for k, v in state.items():
143
+ g['_sset_' + _state_vars[k]](k, g[k], v)
144
+ return state
145
+
146
+
147
+ def _sget_dict(val):
148
+ return val.copy()
149
+
150
+
151
+ def _sset_dict(key, ob, state):
152
+ ob.clear()
153
+ ob.update(state)
154
+
155
+
156
+ def _sget_object(val):
157
+ return val.__getstate__()
158
+
159
+
160
+ def _sset_object(key, ob, state):
161
+ ob.__setstate__(state)
162
+
163
+
164
+ _sget_none = _sset_none = lambda *args: None
165
+
166
+
167
+ def get_supported_platform():
168
+ """Return this platform's maximum compatible version.
169
+
170
+ distutils.util.get_platform() normally reports the minimum version
171
+ of macOS that would be required to *use* extensions produced by
172
+ distutils. But what we want when checking compatibility is to know the
173
+ version of macOS that we are *running*. To allow usage of packages that
174
+ explicitly require a newer version of macOS, we must also know the
175
+ current version of the OS.
176
+
177
+ If this condition occurs for any other platform with a version in its
178
+ platform strings, this function should be extended accordingly.
179
+ """
180
+ plat = get_build_platform()
181
+ m = macosVersionString.match(plat)
182
+ if m is not None and sys.platform == "darwin":
183
+ try:
184
+ plat = 'macosx-%s-%s' % ('.'.join(_macos_vers()[:2]), m.group(3))
185
+ except ValueError:
186
+ # not macOS
187
+ pass
188
+ return plat
189
+
190
+
191
+ __all__ = [
192
+ # Basic resource access and distribution/entry point discovery
193
+ 'require', 'run_script', 'get_provider', 'get_distribution',
194
+ 'load_entry_point', 'get_entry_map', 'get_entry_info',
195
+ 'iter_entry_points',
196
+ 'resource_string', 'resource_stream', 'resource_filename',
197
+ 'resource_listdir', 'resource_exists', 'resource_isdir',
198
+
199
+ # Environmental control
200
+ 'declare_namespace', 'working_set', 'add_activation_listener',
201
+ 'find_distributions', 'set_extraction_path', 'cleanup_resources',
202
+ 'get_default_cache',
203
+
204
+ # Primary implementation classes
205
+ 'Environment', 'WorkingSet', 'ResourceManager',
206
+ 'Distribution', 'Requirement', 'EntryPoint',
207
+
208
+ # Exceptions
209
+ 'ResolutionError', 'VersionConflict', 'DistributionNotFound',
210
+ 'UnknownExtra', 'ExtractionError',
211
+
212
+ # Warnings
213
+ 'PEP440Warning',
214
+
215
+ # Parsing functions and string utilities
216
+ 'parse_requirements', 'parse_version', 'safe_name', 'safe_version',
217
+ 'get_platform', 'compatible_platforms', 'yield_lines', 'split_sections',
218
+ 'safe_extra', 'to_filename', 'invalid_marker', 'evaluate_marker',
219
+
220
+ # filesystem utilities
221
+ 'ensure_directory', 'normalize_path',
222
+
223
+ # Distribution "precedence" constants
224
+ 'EGG_DIST', 'BINARY_DIST', 'SOURCE_DIST', 'CHECKOUT_DIST', 'DEVELOP_DIST',
225
+
226
+ # "Provider" interfaces, implementations, and registration/lookup APIs
227
+ 'IMetadataProvider', 'IResourceProvider', 'FileMetadata',
228
+ 'PathMetadata', 'EggMetadata', 'EmptyProvider', 'empty_provider',
229
+ 'NullProvider', 'EggProvider', 'DefaultProvider', 'ZipProvider',
230
+ 'register_finder', 'register_namespace_handler', 'register_loader_type',
231
+ 'fixup_namespace_packages', 'get_importer',
232
+
233
+ # Warnings
234
+ 'PkgResourcesDeprecationWarning',
235
+
236
+ # Deprecated/backward compatibility only
237
+ 'run_main', 'AvailableDistributions',
238
+ ]
239
+
240
+
241
+ class ResolutionError(Exception):
242
+ """Abstract base for dependency resolution errors"""
243
+
244
+ def __repr__(self):
245
+ return self.__class__.__name__ + repr(self.args)
246
+
247
+
248
+ class VersionConflict(ResolutionError):
249
+ """
250
+ An already-installed version conflicts with the requested version.
251
+
252
+ Should be initialized with the installed Distribution and the requested
253
+ Requirement.
254
+ """
255
+
256
+ _template = "{self.dist} is installed but {self.req} is required"
257
+
258
+ @property
259
+ def dist(self):
260
+ return self.args[0]
261
+
262
+ @property
263
+ def req(self):
264
+ return self.args[1]
265
+
266
+ def report(self):
267
+ return self._template.format(**locals())
268
+
269
+ def with_context(self, required_by):
270
+ """
271
+ If required_by is non-empty, return a version of self that is a
272
+ ContextualVersionConflict.
273
+ """
274
+ if not required_by:
275
+ return self
276
+ args = self.args + (required_by,)
277
+ return ContextualVersionConflict(*args)
278
+
279
+
280
+ class ContextualVersionConflict(VersionConflict):
281
+ """
282
+ A VersionConflict that accepts a third parameter, the set of the
283
+ requirements that required the installed Distribution.
284
+ """
285
+
286
+ _template = VersionConflict._template + ' by {self.required_by}'
287
+
288
+ @property
289
+ def required_by(self):
290
+ return self.args[2]
291
+
292
+
293
+ class DistributionNotFound(ResolutionError):
294
+ """A requested distribution was not found"""
295
+
296
+ _template = ("The '{self.req}' distribution was not found "
297
+ "and is required by {self.requirers_str}")
298
+
299
+ @property
300
+ def req(self):
301
+ return self.args[0]
302
+
303
+ @property
304
+ def requirers(self):
305
+ return self.args[1]
306
+
307
+ @property
308
+ def requirers_str(self):
309
+ if not self.requirers:
310
+ return 'the application'
311
+ return ', '.join(self.requirers)
312
+
313
+ def report(self):
314
+ return self._template.format(**locals())
315
+
316
+ def __str__(self):
317
+ return self.report()
318
+
319
+
320
+ class UnknownExtra(ResolutionError):
321
+ """Distribution doesn't have an "extra feature" of the given name"""
322
+
323
+
324
+ _provider_factories = {}
325
+
326
+ PY_MAJOR = '{}.{}'.format(*sys.version_info)
327
+ EGG_DIST = 3
328
+ BINARY_DIST = 2
329
+ SOURCE_DIST = 1
330
+ CHECKOUT_DIST = 0
331
+ DEVELOP_DIST = -1
332
+
333
+
334
+ def register_loader_type(loader_type, provider_factory):
335
+ """Register `provider_factory` to make providers for `loader_type`
336
+
337
+ `loader_type` is the type or class of a PEP 302 ``module.__loader__``,
338
+ and `provider_factory` is a function that, passed a *module* object,
339
+ returns an ``IResourceProvider`` for that module.
340
+ """
341
+ _provider_factories[loader_type] = provider_factory
342
+
343
+
344
+ def get_provider(moduleOrReq):
345
+ """Return an IResourceProvider for the named module or requirement"""
346
+ if isinstance(moduleOrReq, Requirement):
347
+ return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
348
+ try:
349
+ module = sys.modules[moduleOrReq]
350
+ except KeyError:
351
+ __import__(moduleOrReq)
352
+ module = sys.modules[moduleOrReq]
353
+ loader = getattr(module, '__loader__', None)
354
+ return _find_adapter(_provider_factories, loader)(module)
355
+
356
+
357
+ def _macos_vers(_cache=[]):
358
+ if not _cache:
359
+ version = platform.mac_ver()[0]
360
+ # fallback for MacPorts
361
+ if version == '':
362
+ plist = '/System/Library/CoreServices/SystemVersion.plist'
363
+ if os.path.exists(plist):
364
+ if hasattr(plistlib, 'readPlist'):
365
+ plist_content = plistlib.readPlist(plist)
366
+ if 'ProductVersion' in plist_content:
367
+ version = plist_content['ProductVersion']
368
+
369
+ _cache.append(version.split('.'))
370
+ return _cache[0]
371
+
372
+
373
+ def _macos_arch(machine):
374
+ return {'PowerPC': 'ppc', 'Power_Macintosh': 'ppc'}.get(machine, machine)
375
+
376
+
377
+ def get_build_platform():
378
+ """Return this platform's string for platform-specific distributions
379
+
380
+ XXX Currently this is the same as ``distutils.util.get_platform()``, but it
381
+ needs some hacks for Linux and macOS.
382
+ """
383
+ from sysconfig import get_platform
384
+
385
+ plat = get_platform()
386
+ if sys.platform == "darwin" and not plat.startswith('macosx-'):
387
+ try:
388
+ version = _macos_vers()
389
+ machine = os.uname()[4].replace(" ", "_")
390
+ return "macosx-%d.%d-%s" % (
391
+ int(version[0]), int(version[1]),
392
+ _macos_arch(machine),
393
+ )
394
+ except ValueError:
395
+ # if someone is running a non-Mac darwin system, this will fall
396
+ # through to the default implementation
397
+ pass
398
+ return plat
399
+
400
+
401
+ macosVersionString = re.compile(r"macosx-(\d+)\.(\d+)-(.*)")
402
+ darwinVersionString = re.compile(r"darwin-(\d+)\.(\d+)\.(\d+)-(.*)")
403
+ # XXX backward compat
404
+ get_platform = get_build_platform
405
+
406
+
407
+ def compatible_platforms(provided, required):
408
+ """Can code for the `provided` platform run on the `required` platform?
409
+
410
+ Returns true if either platform is ``None``, or the platforms are equal.
411
+
412
+ XXX Needs compatibility checks for Linux and other unixy OSes.
413
+ """
414
+ if provided is None or required is None or provided == required:
415
+ # easy case
416
+ return True
417
+
418
+ # macOS special cases
419
+ reqMac = macosVersionString.match(required)
420
+ if reqMac:
421
+ provMac = macosVersionString.match(provided)
422
+
423
+ # is this a Mac package?
424
+ if not provMac:
425
+ # this is backwards compatibility for packages built before
426
+ # setuptools 0.6. All packages built after this point will
427
+ # use the new macOS designation.
428
+ provDarwin = darwinVersionString.match(provided)
429
+ if provDarwin:
430
+ dversion = int(provDarwin.group(1))
431
+ macosversion = "%s.%s" % (reqMac.group(1), reqMac.group(2))
432
+ if dversion == 7 and macosversion >= "10.3" or \
433
+ dversion == 8 and macosversion >= "10.4":
434
+ return True
435
+ # egg isn't macOS or legacy darwin
436
+ return False
437
+
438
+ # are they the same major version and machine type?
439
+ if provMac.group(1) != reqMac.group(1) or \
440
+ provMac.group(3) != reqMac.group(3):
441
+ return False
442
+
443
+ # is the required OS major update >= the provided one?
444
+ if int(provMac.group(2)) > int(reqMac.group(2)):
445
+ return False
446
+
447
+ return True
448
+
449
+ # XXX Linux and other platforms' special cases should go here
450
+ return False
451
+
452
+
453
+ def run_script(dist_spec, script_name):
454
+ """Locate distribution `dist_spec` and run its `script_name` script"""
455
+ ns = sys._getframe(1).f_globals
456
+ name = ns['__name__']
457
+ ns.clear()
458
+ ns['__name__'] = name
459
+ require(dist_spec)[0].run_script(script_name, ns)
460
+
461
+
462
+ # backward compatibility
463
+ run_main = run_script
464
+
465
+
466
+ def get_distribution(dist):
467
+ """Return a current distribution object for a Requirement or string"""
468
+ if isinstance(dist, str):
469
+ dist = Requirement.parse(dist)
470
+ if isinstance(dist, Requirement):
471
+ dist = get_provider(dist)
472
+ if not isinstance(dist, Distribution):
473
+ raise TypeError("Expected string, Requirement, or Distribution", dist)
474
+ return dist
475
+
476
+
477
+ def load_entry_point(dist, group, name):
478
+ """Return `name` entry point of `group` for `dist` or raise ImportError"""
479
+ return get_distribution(dist).load_entry_point(group, name)
480
+
481
+
482
+ def get_entry_map(dist, group=None):
483
+ """Return the entry point map for `group`, or the full entry map"""
484
+ return get_distribution(dist).get_entry_map(group)
485
+
486
+
487
+ def get_entry_info(dist, group, name):
488
+ """Return the EntryPoint object for `group`+`name`, or ``None``"""
489
+ return get_distribution(dist).get_entry_info(group, name)
490
+
491
+
492
+ class IMetadataProvider:
493
+ def has_metadata(name):
494
+ """Does the package's distribution contain the named metadata?"""
495
+
496
+ def get_metadata(name):
497
+ """The named metadata resource as a string"""
498
+
499
+ def get_metadata_lines(name):
500
+ """Yield named metadata resource as list of non-blank non-comment lines
501
+
502
+ Leading and trailing whitespace is stripped from each line, and lines
503
+ with ``#`` as the first non-blank character are omitted."""
504
+
505
+ def metadata_isdir(name):
506
+ """Is the named metadata a directory? (like ``os.path.isdir()``)"""
507
+
508
+ def metadata_listdir(name):
509
+ """List of metadata names in the directory (like ``os.listdir()``)"""
510
+
511
+ def run_script(script_name, namespace):
512
+ """Execute the named script in the supplied namespace dictionary"""
513
+
514
+
515
+ class IResourceProvider(IMetadataProvider):
516
+ """An object that provides access to package resources"""
517
+
518
+ def get_resource_filename(manager, resource_name):
519
+ """Return a true filesystem path for `resource_name`
520
+
521
+ `manager` must be an ``IResourceManager``"""
522
+
523
+ def get_resource_stream(manager, resource_name):
524
+ """Return a readable file-like object for `resource_name`
525
+
526
+ `manager` must be an ``IResourceManager``"""
527
+
528
+ def get_resource_string(manager, resource_name):
529
+ """Return a string containing the contents of `resource_name`
530
+
531
+ `manager` must be an ``IResourceManager``"""
532
+
533
+ def has_resource(resource_name):
534
+ """Does the package contain the named resource?"""
535
+
536
+ def resource_isdir(resource_name):
537
+ """Is the named resource a directory? (like ``os.path.isdir()``)"""
538
+
539
+ def resource_listdir(resource_name):
540
+ """List of resource names in the directory (like ``os.listdir()``)"""
541
+
542
+
543
+ class WorkingSet:
544
+ """A collection of active distributions on sys.path (or a similar list)"""
545
+
546
+ def __init__(self, entries=None):
547
+ """Create working set from list of path entries (default=sys.path)"""
548
+ self.entries = []
549
+ self.entry_keys = {}
550
+ self.by_key = {}
551
+ self.callbacks = []
552
+
553
+ if entries is None:
554
+ entries = sys.path
555
+
556
+ for entry in entries:
557
+ self.add_entry(entry)
558
+
559
+ @classmethod
560
+ def _build_master(cls):
561
+ """
562
+ Prepare the master working set.
563
+ """
564
+ ws = cls()
565
+ try:
566
+ from __main__ import __requires__
567
+ except ImportError:
568
+ # The main program does not list any requirements
569
+ return ws
570
+
571
+ # ensure the requirements are met
572
+ try:
573
+ ws.require(__requires__)
574
+ except VersionConflict:
575
+ return cls._build_from_requirements(__requires__)
576
+
577
+ return ws
578
+
579
+ @classmethod
580
+ def _build_from_requirements(cls, req_spec):
581
+ """
582
+ Build a working set from a requirement spec. Rewrites sys.path.
583
+ """
584
+ # try it without defaults already on sys.path
585
+ # by starting with an empty path
586
+ ws = cls([])
587
+ reqs = parse_requirements(req_spec)
588
+ dists = ws.resolve(reqs, Environment())
589
+ for dist in dists:
590
+ ws.add(dist)
591
+
592
+ # add any missing entries from sys.path
593
+ for entry in sys.path:
594
+ if entry not in ws.entries:
595
+ ws.add_entry(entry)
596
+
597
+ # then copy back to sys.path
598
+ sys.path[:] = ws.entries
599
+ return ws
600
+
601
+ def add_entry(self, entry):
602
+ """Add a path item to ``.entries``, finding any distributions on it
603
+
604
+ ``find_distributions(entry, True)`` is used to find distributions
605
+ corresponding to the path entry, and they are added. `entry` is
606
+ always appended to ``.entries``, even if it is already present.
607
+ (This is because ``sys.path`` can contain the same value more than
608
+ once, and the ``.entries`` of the ``sys.path`` WorkingSet should always
609
+ equal ``sys.path``.)
610
+ """
611
+ self.entry_keys.setdefault(entry, [])
612
+ self.entries.append(entry)
613
+ for dist in find_distributions(entry, True):
614
+ self.add(dist, entry, False)
615
+
616
+ def __contains__(self, dist):
617
+ """True if `dist` is the active distribution for its project"""
618
+ return self.by_key.get(dist.key) == dist
619
+
620
+ def find(self, req):
621
+ """Find a distribution matching requirement `req`
622
+
623
+ If there is an active distribution for the requested project, this
624
+ returns it as long as it meets the version requirement specified by
625
+ `req`. But, if there is an active distribution for the project and it
626
+ does *not* meet the `req` requirement, ``VersionConflict`` is raised.
627
+ If there is no active distribution for the requested project, ``None``
628
+ is returned.
629
+ """
630
+ dist = self.by_key.get(req.key)
631
+ if dist is not None and dist not in req:
632
+ # XXX add more info
633
+ raise VersionConflict(dist, req)
634
+ return dist
635
+
636
+ def iter_entry_points(self, group, name=None):
637
+ """Yield entry point objects from `group` matching `name`
638
+
639
+ If `name` is None, yields all entry points in `group` from all
640
+ distributions in the working set, otherwise only ones matching
641
+ both `group` and `name` are yielded (in distribution order).
642
+ """
643
+ return (
644
+ entry
645
+ for dist in self
646
+ for entry in dist.get_entry_map(group).values()
647
+ if name is None or name == entry.name
648
+ )
649
+
650
+ def run_script(self, requires, script_name):
651
+ """Locate distribution for `requires` and run `script_name` script"""
652
+ ns = sys._getframe(1).f_globals
653
+ name = ns['__name__']
654
+ ns.clear()
655
+ ns['__name__'] = name
656
+ self.require(requires)[0].run_script(script_name, ns)
657
+
658
+ def __iter__(self):
659
+ """Yield distributions for non-duplicate projects in the working set
660
+
661
+ The yield order is the order in which the items' path entries were
662
+ added to the working set.
663
+ """
664
+ seen = {}
665
+ for item in self.entries:
666
+ if item not in self.entry_keys:
667
+ # workaround a cache issue
668
+ continue
669
+
670
+ for key in self.entry_keys[item]:
671
+ if key not in seen:
672
+ seen[key] = 1
673
+ yield self.by_key[key]
674
+
675
+ def add(self, dist, entry=None, insert=True, replace=False):
676
+ """Add `dist` to working set, associated with `entry`
677
+
678
+ If `entry` is unspecified, it defaults to the ``.location`` of `dist`.
679
+ On exit from this routine, `entry` is added to the end of the working
680
+ set's ``.entries`` (if it wasn't already present).
681
+
682
+ `dist` is only added to the working set if it's for a project that
683
+ doesn't already have a distribution in the set, unless `replace=True`.
684
+ If it's added, any callbacks registered with the ``subscribe()`` method
685
+ will be called.
686
+ """
687
+ if insert:
688
+ dist.insert_on(self.entries, entry, replace=replace)
689
+
690
+ if entry is None:
691
+ entry = dist.location
692
+ keys = self.entry_keys.setdefault(entry, [])
693
+ keys2 = self.entry_keys.setdefault(dist.location, [])
694
+ if not replace and dist.key in self.by_key:
695
+ # ignore hidden distros
696
+ return
697
+
698
+ self.by_key[dist.key] = dist
699
+ if dist.key not in keys:
700
+ keys.append(dist.key)
701
+ if dist.key not in keys2:
702
+ keys2.append(dist.key)
703
+ self._added_new(dist)
704
+
705
+ # FIXME: 'WorkingSet.resolve' is too complex (11)
706
+ def resolve(self, requirements, env=None, installer=None, # noqa: C901
707
+ replace_conflicting=False, extras=None):
708
+ """List all distributions needed to (recursively) meet `requirements`
709
+
710
+ `requirements` must be a sequence of ``Requirement`` objects. `env`,
711
+ if supplied, should be an ``Environment`` instance. If
712
+ not supplied, it defaults to all distributions available within any
713
+ entry or distribution in the working set. `installer`, if supplied,
714
+ will be invoked with each requirement that cannot be met by an
715
+ already-installed distribution; it should return a ``Distribution`` or
716
+ ``None``.
717
+
718
+ Unless `replace_conflicting=True`, raises a VersionConflict exception
719
+ if
720
+ any requirements are found on the path that have the correct name but
721
+ the wrong version. Otherwise, if an `installer` is supplied it will be
722
+ invoked to obtain the correct version of the requirement and activate
723
+ it.
724
+
725
+ `extras` is a list of the extras to be used with these requirements.
726
+ This is important because extra requirements may look like `my_req;
727
+ extra = "my_extra"`, which would otherwise be interpreted as a purely
728
+ optional requirement. Instead, we want to be able to assert that these
729
+ requirements are truly required.
730
+ """
731
+
732
+ # set up the stack
733
+ requirements = list(requirements)[::-1]
734
+ # set of processed requirements
735
+ processed = {}
736
+ # key -> dist
737
+ best = {}
738
+ to_activate = []
739
+
740
+ req_extras = _ReqExtras()
741
+
742
+ # Mapping of requirement to set of distributions that required it;
743
+ # useful for reporting info about conflicts.
744
+ required_by = collections.defaultdict(set)
745
+
746
+ while requirements:
747
+ # process dependencies breadth-first
748
+ req = requirements.pop(0)
749
+ if req in processed:
750
+ # Ignore cyclic or redundant dependencies
751
+ continue
752
+
753
+ if not req_extras.markers_pass(req, extras):
754
+ continue
755
+
756
+ dist = best.get(req.key)
757
+ if dist is None:
758
+ # Find the best distribution and add it to the map
759
+ dist = self.by_key.get(req.key)
760
+ if dist is None or (dist not in req and replace_conflicting):
761
+ ws = self
762
+ if env is None:
763
+ if dist is None:
764
+ env = Environment(self.entries)
765
+ else:
766
+ # Use an empty environment and workingset to avoid
767
+ # any further conflicts with the conflicting
768
+ # distribution
769
+ env = Environment([])
770
+ ws = WorkingSet([])
771
+ dist = best[req.key] = env.best_match(
772
+ req, ws, installer,
773
+ replace_conflicting=replace_conflicting
774
+ )
775
+ if dist is None:
776
+ requirers = required_by.get(req, None)
777
+ raise DistributionNotFound(req, requirers)
778
+ to_activate.append(dist)
779
+ if dist not in req:
780
+ # Oops, the "best" so far conflicts with a dependency
781
+ dependent_req = required_by[req]
782
+ raise VersionConflict(dist, req).with_context(dependent_req)
783
+
784
+ # push the new requirements onto the stack
785
+ new_requirements = dist.requires(req.extras)[::-1]
786
+ requirements.extend(new_requirements)
787
+
788
+ # Register the new requirements needed by req
789
+ for new_requirement in new_requirements:
790
+ required_by[new_requirement].add(req.project_name)
791
+ req_extras[new_requirement] = req.extras
792
+
793
+ processed[req] = True
794
+
795
+ # return list of distros to activate
796
+ return to_activate
797
+
798
+ def find_plugins(
799
+ self, plugin_env, full_env=None, installer=None, fallback=True):
800
+ """Find all activatable distributions in `plugin_env`
801
+
802
+ Example usage::
803
+
804
+ distributions, errors = working_set.find_plugins(
805
+ Environment(plugin_dirlist)
806
+ )
807
+ # add plugins+libs to sys.path
808
+ map(working_set.add, distributions)
809
+ # display errors
810
+ print('Could not load', errors)
811
+
812
+ The `plugin_env` should be an ``Environment`` instance that contains
813
+ only distributions that are in the project's "plugin directory" or
814
+ directories. The `full_env`, if supplied, should be an ``Environment``
815
+ contains all currently-available distributions. If `full_env` is not
816
+ supplied, one is created automatically from the ``WorkingSet`` this
817
+ method is called on, which will typically mean that every directory on
818
+ ``sys.path`` will be scanned for distributions.
819
+
820
+ `installer` is a standard installer callback as used by the
821
+ ``resolve()`` method. The `fallback` flag indicates whether we should
822
+ attempt to resolve older versions of a plugin if the newest version
823
+ cannot be resolved.
824
+
825
+ This method returns a 2-tuple: (`distributions`, `error_info`), where
826
+ `distributions` is a list of the distributions found in `plugin_env`
827
+ that were loadable, along with any other distributions that are needed
828
+ to resolve their dependencies. `error_info` is a dictionary mapping
829
+ unloadable plugin distributions to an exception instance describing the
830
+ error that occurred. Usually this will be a ``DistributionNotFound`` or
831
+ ``VersionConflict`` instance.
832
+ """
833
+
834
+ plugin_projects = list(plugin_env)
835
+ # scan project names in alphabetic order
836
+ plugin_projects.sort()
837
+
838
+ error_info = {}
839
+ distributions = {}
840
+
841
+ if full_env is None:
842
+ env = Environment(self.entries)
843
+ env += plugin_env
844
+ else:
845
+ env = full_env + plugin_env
846
+
847
+ shadow_set = self.__class__([])
848
+ # put all our entries in shadow_set
849
+ list(map(shadow_set.add, self))
850
+
851
+ for project_name in plugin_projects:
852
+
853
+ for dist in plugin_env[project_name]:
854
+
855
+ req = [dist.as_requirement()]
856
+
857
+ try:
858
+ resolvees = shadow_set.resolve(req, env, installer)
859
+
860
+ except ResolutionError as v:
861
+ # save error info
862
+ error_info[dist] = v
863
+ if fallback:
864
+ # try the next older version of project
865
+ continue
866
+ else:
867
+ # give up on this project, keep going
868
+ break
869
+
870
+ else:
871
+ list(map(shadow_set.add, resolvees))
872
+ distributions.update(dict.fromkeys(resolvees))
873
+
874
+ # success, no need to try any more versions of this project
875
+ break
876
+
877
+ distributions = list(distributions)
878
+ distributions.sort()
879
+
880
+ return distributions, error_info
881
+
882
+ def require(self, *requirements):
883
+ """Ensure that distributions matching `requirements` are activated
884
+
885
+ `requirements` must be a string or a (possibly-nested) sequence
886
+ thereof, specifying the distributions and versions required. The
887
+ return value is a sequence of the distributions that needed to be
888
+ activated to fulfill the requirements; all relevant distributions are
889
+ included, even if they were already activated in this working set.
890
+ """
891
+ needed = self.resolve(parse_requirements(requirements))
892
+
893
+ for dist in needed:
894
+ self.add(dist)
895
+
896
+ return needed
897
+
898
+ def subscribe(self, callback, existing=True):
899
+ """Invoke `callback` for all distributions
900
+
901
+ If `existing=True` (default),
902
+ call on all existing ones, as well.
903
+ """
904
+ if callback in self.callbacks:
905
+ return
906
+ self.callbacks.append(callback)
907
+ if not existing:
908
+ return
909
+ for dist in self:
910
+ callback(dist)
911
+
912
+ def _added_new(self, dist):
913
+ for callback in self.callbacks:
914
+ callback(dist)
915
+
916
+ def __getstate__(self):
917
+ return (
918
+ self.entries[:], self.entry_keys.copy(), self.by_key.copy(),
919
+ self.callbacks[:]
920
+ )
921
+
922
+ def __setstate__(self, e_k_b_c):
923
+ entries, keys, by_key, callbacks = e_k_b_c
924
+ self.entries = entries[:]
925
+ self.entry_keys = keys.copy()
926
+ self.by_key = by_key.copy()
927
+ self.callbacks = callbacks[:]
928
+
929
+
930
+ class _ReqExtras(dict):
931
+ """
932
+ Map each requirement to the extras that demanded it.
933
+ """
934
+
935
+ def markers_pass(self, req, extras=None):
936
+ """
937
+ Evaluate markers for req against each extra that
938
+ demanded it.
939
+
940
+ Return False if the req has a marker and fails
941
+ evaluation. Otherwise, return True.
942
+ """
943
+ extra_evals = (
944
+ req.marker.evaluate({'extra': extra})
945
+ for extra in self.get(req, ()) + (extras or (None,))
946
+ )
947
+ return not req.marker or any(extra_evals)
948
+
949
+
950
+ class Environment:
951
+ """Searchable snapshot of distributions on a search path"""
952
+
953
+ def __init__(
954
+ self, search_path=None, platform=get_supported_platform(),
955
+ python=PY_MAJOR):
956
+ """Snapshot distributions available on a search path
957
+
958
+ Any distributions found on `search_path` are added to the environment.
959
+ `search_path` should be a sequence of ``sys.path`` items. If not
960
+ supplied, ``sys.path`` is used.
961
+
962
+ `platform` is an optional string specifying the name of the platform
963
+ that platform-specific distributions must be compatible with. If
964
+ unspecified, it defaults to the current platform. `python` is an
965
+ optional string naming the desired version of Python (e.g. ``'3.6'``);
966
+ it defaults to the current version.
967
+
968
+ You may explicitly set `platform` (and/or `python`) to ``None`` if you
969
+ wish to map *all* distributions, not just those compatible with the
970
+ running platform or Python version.
971
+ """
972
+ self._distmap = {}
973
+ self.platform = platform
974
+ self.python = python
975
+ self.scan(search_path)
976
+
977
+ def can_add(self, dist):
978
+ """Is distribution `dist` acceptable for this environment?
979
+
980
+ The distribution must match the platform and python version
981
+ requirements specified when this environment was created, or False
982
+ is returned.
983
+ """
984
+ py_compat = (
985
+ self.python is None
986
+ or dist.py_version is None
987
+ or dist.py_version == self.python
988
+ )
989
+ return py_compat and compatible_platforms(dist.platform, self.platform)
990
+
991
+ def remove(self, dist):
992
+ """Remove `dist` from the environment"""
993
+ self._distmap[dist.key].remove(dist)
994
+
995
+ def scan(self, search_path=None):
996
+ """Scan `search_path` for distributions usable in this environment
997
+
998
+ Any distributions found are added to the environment.
999
+ `search_path` should be a sequence of ``sys.path`` items. If not
1000
+ supplied, ``sys.path`` is used. Only distributions conforming to
1001
+ the platform/python version defined at initialization are added.
1002
+ """
1003
+ if search_path is None:
1004
+ search_path = sys.path
1005
+
1006
+ for item in search_path:
1007
+ for dist in find_distributions(item):
1008
+ self.add(dist)
1009
+
1010
+ def __getitem__(self, project_name):
1011
+ """Return a newest-to-oldest list of distributions for `project_name`
1012
+
1013
+ Uses case-insensitive `project_name` comparison, assuming all the
1014
+ project's distributions use their project's name converted to all
1015
+ lowercase as their key.
1016
+
1017
+ """
1018
+ distribution_key = project_name.lower()
1019
+ return self._distmap.get(distribution_key, [])
1020
+
1021
+ def add(self, dist):
1022
+ """Add `dist` if we ``can_add()`` it and it has not already been added
1023
+ """
1024
+ if self.can_add(dist) and dist.has_version():
1025
+ dists = self._distmap.setdefault(dist.key, [])
1026
+ if dist not in dists:
1027
+ dists.append(dist)
1028
+ dists.sort(key=operator.attrgetter('hashcmp'), reverse=True)
1029
+
1030
+ def best_match(
1031
+ self, req, working_set, installer=None, replace_conflicting=False):
1032
+ """Find distribution best matching `req` and usable on `working_set`
1033
+
1034
+ This calls the ``find(req)`` method of the `working_set` to see if a
1035
+ suitable distribution is already active. (This may raise
1036
+ ``VersionConflict`` if an unsuitable version of the project is already
1037
+ active in the specified `working_set`.) If a suitable distribution
1038
+ isn't active, this method returns the newest distribution in the
1039
+ environment that meets the ``Requirement`` in `req`. If no suitable
1040
+ distribution is found, and `installer` is supplied, then the result of
1041
+ calling the environment's ``obtain(req, installer)`` method will be
1042
+ returned.
1043
+ """
1044
+ try:
1045
+ dist = working_set.find(req)
1046
+ except VersionConflict:
1047
+ if not replace_conflicting:
1048
+ raise
1049
+ dist = None
1050
+ if dist is not None:
1051
+ return dist
1052
+ for dist in self[req.key]:
1053
+ if dist in req:
1054
+ return dist
1055
+ # try to download/install
1056
+ return self.obtain(req, installer)
1057
+
1058
+ def obtain(self, requirement, installer=None):
1059
+ """Obtain a distribution matching `requirement` (e.g. via download)
1060
+
1061
+ Obtain a distro that matches requirement (e.g. via download). In the
1062
+ base ``Environment`` class, this routine just returns
1063
+ ``installer(requirement)``, unless `installer` is None, in which case
1064
+ None is returned instead. This method is a hook that allows subclasses
1065
+ to attempt other ways of obtaining a distribution before falling back
1066
+ to the `installer` argument."""
1067
+ if installer is not None:
1068
+ return installer(requirement)
1069
+
1070
+ def __iter__(self):
1071
+ """Yield the unique project names of the available distributions"""
1072
+ for key in self._distmap.keys():
1073
+ if self[key]:
1074
+ yield key
1075
+
1076
+ def __iadd__(self, other):
1077
+ """In-place addition of a distribution or environment"""
1078
+ if isinstance(other, Distribution):
1079
+ self.add(other)
1080
+ elif isinstance(other, Environment):
1081
+ for project in other:
1082
+ for dist in other[project]:
1083
+ self.add(dist)
1084
+ else:
1085
+ raise TypeError("Can't add %r to environment" % (other,))
1086
+ return self
1087
+
1088
+ def __add__(self, other):
1089
+ """Add an environment or distribution to an environment"""
1090
+ new = self.__class__([], platform=None, python=None)
1091
+ for env in self, other:
1092
+ new += env
1093
+ return new
1094
+
1095
+
1096
+ # XXX backward compatibility
1097
+ AvailableDistributions = Environment
1098
+
1099
+
1100
+ class ExtractionError(RuntimeError):
1101
+ """An error occurred extracting a resource
1102
+
1103
+ The following attributes are available from instances of this exception:
1104
+
1105
+ manager
1106
+ The resource manager that raised this exception
1107
+
1108
+ cache_path
1109
+ The base directory for resource extraction
1110
+
1111
+ original_error
1112
+ The exception instance that caused extraction to fail
1113
+ """
1114
+
1115
+
1116
+ class ResourceManager:
1117
+ """Manage resource extraction and packages"""
1118
+ extraction_path = None
1119
+
1120
+ def __init__(self):
1121
+ self.cached_files = {}
1122
+
1123
+ def resource_exists(self, package_or_requirement, resource_name):
1124
+ """Does the named resource exist?"""
1125
+ return get_provider(package_or_requirement).has_resource(resource_name)
1126
+
1127
+ def resource_isdir(self, package_or_requirement, resource_name):
1128
+ """Is the named resource an existing directory?"""
1129
+ return get_provider(package_or_requirement).resource_isdir(
1130
+ resource_name
1131
+ )
1132
+
1133
+ def resource_filename(self, package_or_requirement, resource_name):
1134
+ """Return a true filesystem path for specified resource"""
1135
+ return get_provider(package_or_requirement).get_resource_filename(
1136
+ self, resource_name
1137
+ )
1138
+
1139
+ def resource_stream(self, package_or_requirement, resource_name):
1140
+ """Return a readable file-like object for specified resource"""
1141
+ return get_provider(package_or_requirement).get_resource_stream(
1142
+ self, resource_name
1143
+ )
1144
+
1145
+ def resource_string(self, package_or_requirement, resource_name):
1146
+ """Return specified resource as a string"""
1147
+ return get_provider(package_or_requirement).get_resource_string(
1148
+ self, resource_name
1149
+ )
1150
+
1151
+ def resource_listdir(self, package_or_requirement, resource_name):
1152
+ """List the contents of the named resource directory"""
1153
+ return get_provider(package_or_requirement).resource_listdir(
1154
+ resource_name
1155
+ )
1156
+
1157
+ def extraction_error(self):
1158
+ """Give an error message for problems extracting file(s)"""
1159
+
1160
+ old_exc = sys.exc_info()[1]
1161
+ cache_path = self.extraction_path or get_default_cache()
1162
+
1163
+ tmpl = textwrap.dedent("""
1164
+ Can't extract file(s) to egg cache
1165
+
1166
+ The following error occurred while trying to extract file(s)
1167
+ to the Python egg cache:
1168
+
1169
+ {old_exc}
1170
+
1171
+ The Python egg cache directory is currently set to:
1172
+
1173
+ {cache_path}
1174
+
1175
+ Perhaps your account does not have write access to this directory?
1176
+ You can change the cache directory by setting the PYTHON_EGG_CACHE
1177
+ environment variable to point to an accessible directory.
1178
+ """).lstrip()
1179
+ err = ExtractionError(tmpl.format(**locals()))
1180
+ err.manager = self
1181
+ err.cache_path = cache_path
1182
+ err.original_error = old_exc
1183
+ raise err
1184
+
1185
+ def get_cache_path(self, archive_name, names=()):
1186
+ """Return absolute location in cache for `archive_name` and `names`
1187
+
1188
+ The parent directory of the resulting path will be created if it does
1189
+ not already exist. `archive_name` should be the base filename of the
1190
+ enclosing egg (which may not be the name of the enclosing zipfile!),
1191
+ including its ".egg" extension. `names`, if provided, should be a
1192
+ sequence of path name parts "under" the egg's extraction location.
1193
+
1194
+ This method should only be called by resource providers that need to
1195
+ obtain an extraction location, and only for names they intend to
1196
+ extract, as it tracks the generated names for possible cleanup later.
1197
+ """
1198
+ extract_path = self.extraction_path or get_default_cache()
1199
+ target_path = os.path.join(extract_path, archive_name + '-tmp', *names)
1200
+ try:
1201
+ _bypass_ensure_directory(target_path)
1202
+ except Exception:
1203
+ self.extraction_error()
1204
+
1205
+ self._warn_unsafe_extraction_path(extract_path)
1206
+
1207
+ self.cached_files[target_path] = 1
1208
+ return target_path
1209
+
1210
+ @staticmethod
1211
+ def _warn_unsafe_extraction_path(path):
1212
+ """
1213
+ If the default extraction path is overridden and set to an insecure
1214
+ location, such as /tmp, it opens up an opportunity for an attacker to
1215
+ replace an extracted file with an unauthorized payload. Warn the user
1216
+ if a known insecure location is used.
1217
+
1218
+ See Distribute #375 for more details.
1219
+ """
1220
+ if os.name == 'nt' and not path.startswith(os.environ['windir']):
1221
+ # On Windows, permissions are generally restrictive by default
1222
+ # and temp directories are not writable by other users, so
1223
+ # bypass the warning.
1224
+ return
1225
+ mode = os.stat(path).st_mode
1226
+ if mode & stat.S_IWOTH or mode & stat.S_IWGRP:
1227
+ msg = (
1228
+ "Extraction path is writable by group/others "
1229
+ "and vulnerable to attack when "
1230
+ "used with get_resource_filename ({path}). "
1231
+ "Consider a more secure "
1232
+ "location (set with .set_extraction_path or the "
1233
+ "PYTHON_EGG_CACHE environment variable)."
1234
+ ).format(**locals())
1235
+ warnings.warn(msg, UserWarning)
1236
+
1237
+ def postprocess(self, tempname, filename):
1238
+ """Perform any platform-specific postprocessing of `tempname`
1239
+
1240
+ This is where Mac header rewrites should be done; other platforms don't
1241
+ have anything special they should do.
1242
+
1243
+ Resource providers should call this method ONLY after successfully
1244
+ extracting a compressed resource. They must NOT call it on resources
1245
+ that are already in the filesystem.
1246
+
1247
+ `tempname` is the current (temporary) name of the file, and `filename`
1248
+ is the name it will be renamed to by the caller after this routine
1249
+ returns.
1250
+ """
1251
+
1252
+ if os.name == 'posix':
1253
+ # Make the resource executable
1254
+ mode = ((os.stat(tempname).st_mode) | 0o555) & 0o7777
1255
+ os.chmod(tempname, mode)
1256
+
1257
+ def set_extraction_path(self, path):
1258
+ """Set the base path where resources will be extracted to, if needed.
1259
+
1260
+ If you do not call this routine before any extractions take place, the
1261
+ path defaults to the return value of ``get_default_cache()``. (Which
1262
+ is based on the ``PYTHON_EGG_CACHE`` environment variable, with various
1263
+ platform-specific fallbacks. See that routine's documentation for more
1264
+ details.)
1265
+
1266
+ Resources are extracted to subdirectories of this path based upon
1267
+ information given by the ``IResourceProvider``. You may set this to a
1268
+ temporary directory, but then you must call ``cleanup_resources()`` to
1269
+ delete the extracted files when done. There is no guarantee that
1270
+ ``cleanup_resources()`` will be able to remove all extracted files.
1271
+
1272
+ (Note: you may not change the extraction path for a given resource
1273
+ manager once resources have been extracted, unless you first call
1274
+ ``cleanup_resources()``.)
1275
+ """
1276
+ if self.cached_files:
1277
+ raise ValueError(
1278
+ "Can't change extraction path, files already extracted"
1279
+ )
1280
+
1281
+ self.extraction_path = path
1282
+
1283
+ def cleanup_resources(self, force=False):
1284
+ """
1285
+ Delete all extracted resource files and directories, returning a list
1286
+ of the file and directory names that could not be successfully removed.
1287
+ This function does not have any concurrency protection, so it should
1288
+ generally only be called when the extraction path is a temporary
1289
+ directory exclusive to a single process. This method is not
1290
+ automatically called; you must call it explicitly or register it as an
1291
+ ``atexit`` function if you wish to ensure cleanup of a temporary
1292
+ directory used for extractions.
1293
+ """
1294
+ # XXX
1295
+
1296
+
1297
+ def get_default_cache():
1298
+ """
1299
+ Return the ``PYTHON_EGG_CACHE`` environment variable
1300
+ or a platform-relevant user cache dir for an app
1301
+ named "Python-Eggs".
1302
+ """
1303
+ return (
1304
+ os.environ.get('PYTHON_EGG_CACHE')
1305
+ or appdirs.user_cache_dir(appname='Python-Eggs')
1306
+ )
1307
+
1308
+
1309
+ def safe_name(name):
1310
+ """Convert an arbitrary string to a standard distribution name
1311
+
1312
+ Any runs of non-alphanumeric/. characters are replaced with a single '-'.
1313
+ """
1314
+ return re.sub('[^A-Za-z0-9.]+', '-', name)
1315
+
1316
+
1317
+ def safe_version(version):
1318
+ """
1319
+ Convert an arbitrary string to a standard version string
1320
+ """
1321
+ try:
1322
+ # normalize the version
1323
+ return str(packaging.version.Version(version))
1324
+ except packaging.version.InvalidVersion:
1325
+ version = version.replace(' ', '.')
1326
+ return re.sub('[^A-Za-z0-9.]+', '-', version)
1327
+
1328
+
1329
+ def safe_extra(extra):
1330
+ """Convert an arbitrary string to a standard 'extra' name
1331
+
1332
+ Any runs of non-alphanumeric characters are replaced with a single '_',
1333
+ and the result is always lowercased.
1334
+ """
1335
+ return re.sub('[^A-Za-z0-9.-]+', '_', extra).lower()
1336
+
1337
+
1338
+ def to_filename(name):
1339
+ """Convert a project or version name to its filename-escaped form
1340
+
1341
+ Any '-' characters are currently replaced with '_'.
1342
+ """
1343
+ return name.replace('-', '_')
1344
+
1345
+
1346
+ def invalid_marker(text):
1347
+ """
1348
+ Validate text as a PEP 508 environment marker; return an exception
1349
+ if invalid or False otherwise.
1350
+ """
1351
+ try:
1352
+ evaluate_marker(text)
1353
+ except SyntaxError as e:
1354
+ e.filename = None
1355
+ e.lineno = None
1356
+ return e
1357
+ return False
1358
+
1359
+
1360
+ def evaluate_marker(text, extra=None):
1361
+ """
1362
+ Evaluate a PEP 508 environment marker.
1363
+ Return a boolean indicating the marker result in this environment.
1364
+ Raise SyntaxError if marker is invalid.
1365
+
1366
+ This implementation uses the 'pyparsing' module.
1367
+ """
1368
+ try:
1369
+ marker = packaging.markers.Marker(text)
1370
+ return marker.evaluate()
1371
+ except packaging.markers.InvalidMarker as e:
1372
+ raise SyntaxError(e) from e
1373
+
1374
+
1375
+ class NullProvider:
1376
+ """Try to implement resources and metadata for arbitrary PEP 302 loaders"""
1377
+
1378
+ egg_name = None
1379
+ egg_info = None
1380
+ loader = None
1381
+
1382
+ def __init__(self, module):
1383
+ self.loader = getattr(module, '__loader__', None)
1384
+ self.module_path = os.path.dirname(getattr(module, '__file__', ''))
1385
+
1386
+ def get_resource_filename(self, manager, resource_name):
1387
+ return self._fn(self.module_path, resource_name)
1388
+
1389
+ def get_resource_stream(self, manager, resource_name):
1390
+ return io.BytesIO(self.get_resource_string(manager, resource_name))
1391
+
1392
+ def get_resource_string(self, manager, resource_name):
1393
+ return self._get(self._fn(self.module_path, resource_name))
1394
+
1395
+ def has_resource(self, resource_name):
1396
+ return self._has(self._fn(self.module_path, resource_name))
1397
+
1398
+ def _get_metadata_path(self, name):
1399
+ return self._fn(self.egg_info, name)
1400
+
1401
+ def has_metadata(self, name):
1402
+ if not self.egg_info:
1403
+ return self.egg_info
1404
+
1405
+ path = self._get_metadata_path(name)
1406
+ return self._has(path)
1407
+
1408
+ def get_metadata(self, name):
1409
+ if not self.egg_info:
1410
+ return ""
1411
+ path = self._get_metadata_path(name)
1412
+ value = self._get(path)
1413
+ try:
1414
+ return value.decode('utf-8')
1415
+ except UnicodeDecodeError as exc:
1416
+ # Include the path in the error message to simplify
1417
+ # troubleshooting, and without changing the exception type.
1418
+ exc.reason += ' in {} file at path: {}'.format(name, path)
1419
+ raise
1420
+
1421
+ def get_metadata_lines(self, name):
1422
+ return yield_lines(self.get_metadata(name))
1423
+
1424
+ def resource_isdir(self, resource_name):
1425
+ return self._isdir(self._fn(self.module_path, resource_name))
1426
+
1427
+ def metadata_isdir(self, name):
1428
+ return self.egg_info and self._isdir(self._fn(self.egg_info, name))
1429
+
1430
+ def resource_listdir(self, resource_name):
1431
+ return self._listdir(self._fn(self.module_path, resource_name))
1432
+
1433
+ def metadata_listdir(self, name):
1434
+ if self.egg_info:
1435
+ return self._listdir(self._fn(self.egg_info, name))
1436
+ return []
1437
+
1438
+ def run_script(self, script_name, namespace):
1439
+ script = 'scripts/' + script_name
1440
+ if not self.has_metadata(script):
1441
+ raise ResolutionError(
1442
+ "Script {script!r} not found in metadata at {self.egg_info!r}"
1443
+ .format(**locals()),
1444
+ )
1445
+ script_text = self.get_metadata(script).replace('\r\n', '\n')
1446
+ script_text = script_text.replace('\r', '\n')
1447
+ script_filename = self._fn(self.egg_info, script)
1448
+ namespace['__file__'] = script_filename
1449
+ if os.path.exists(script_filename):
1450
+ with open(script_filename) as fid:
1451
+ source = fid.read()
1452
+ code = compile(source, script_filename, 'exec')
1453
+ exec(code, namespace, namespace)
1454
+ else:
1455
+ from linecache import cache
1456
+ cache[script_filename] = (
1457
+ len(script_text), 0, script_text.split('\n'), script_filename
1458
+ )
1459
+ script_code = compile(script_text, script_filename, 'exec')
1460
+ exec(script_code, namespace, namespace)
1461
+
1462
+ def _has(self, path):
1463
+ raise NotImplementedError(
1464
+ "Can't perform this operation for unregistered loader type"
1465
+ )
1466
+
1467
+ def _isdir(self, path):
1468
+ raise NotImplementedError(
1469
+ "Can't perform this operation for unregistered loader type"
1470
+ )
1471
+
1472
+ def _listdir(self, path):
1473
+ raise NotImplementedError(
1474
+ "Can't perform this operation for unregistered loader type"
1475
+ )
1476
+
1477
+ def _fn(self, base, resource_name):
1478
+ self._validate_resource_path(resource_name)
1479
+ if resource_name:
1480
+ return os.path.join(base, *resource_name.split('/'))
1481
+ return base
1482
+
1483
+ @staticmethod
1484
+ def _validate_resource_path(path):
1485
+ """
1486
+ Validate the resource paths according to the docs.
1487
+ https://setuptools.pypa.io/en/latest/pkg_resources.html#basic-resource-access
1488
+
1489
+ >>> warned = getfixture('recwarn')
1490
+ >>> warnings.simplefilter('always')
1491
+ >>> vrp = NullProvider._validate_resource_path
1492
+ >>> vrp('foo/bar.txt')
1493
+ >>> bool(warned)
1494
+ False
1495
+ >>> vrp('../foo/bar.txt')
1496
+ >>> bool(warned)
1497
+ True
1498
+ >>> warned.clear()
1499
+ >>> vrp('/foo/bar.txt')
1500
+ >>> bool(warned)
1501
+ True
1502
+ >>> vrp('foo/../../bar.txt')
1503
+ >>> bool(warned)
1504
+ True
1505
+ >>> warned.clear()
1506
+ >>> vrp('foo/f../bar.txt')
1507
+ >>> bool(warned)
1508
+ False
1509
+
1510
+ Windows path separators are straight-up disallowed.
1511
+ >>> vrp(r'\\foo/bar.txt')
1512
+ Traceback (most recent call last):
1513
+ ...
1514
+ ValueError: Use of .. or absolute path in a resource path \
1515
+ is not allowed.
1516
+
1517
+ >>> vrp(r'C:\\foo/bar.txt')
1518
+ Traceback (most recent call last):
1519
+ ...
1520
+ ValueError: Use of .. or absolute path in a resource path \
1521
+ is not allowed.
1522
+
1523
+ Blank values are allowed
1524
+
1525
+ >>> vrp('')
1526
+ >>> bool(warned)
1527
+ False
1528
+
1529
+ Non-string values are not.
1530
+
1531
+ >>> vrp(None)
1532
+ Traceback (most recent call last):
1533
+ ...
1534
+ AttributeError: ...
1535
+ """
1536
+ invalid = (
1537
+ os.path.pardir in path.split(posixpath.sep) or
1538
+ posixpath.isabs(path) or
1539
+ ntpath.isabs(path)
1540
+ )
1541
+ if not invalid:
1542
+ return
1543
+
1544
+ msg = "Use of .. or absolute path in a resource path is not allowed."
1545
+
1546
+ # Aggressively disallow Windows absolute paths
1547
+ if ntpath.isabs(path) and not posixpath.isabs(path):
1548
+ raise ValueError(msg)
1549
+
1550
+ # for compatibility, warn; in future
1551
+ # raise ValueError(msg)
1552
+ warnings.warn(
1553
+ msg[:-1] + " and will raise exceptions in a future release.",
1554
+ DeprecationWarning,
1555
+ stacklevel=4,
1556
+ )
1557
+
1558
+ def _get(self, path):
1559
+ if hasattr(self.loader, 'get_data'):
1560
+ return self.loader.get_data(path)
1561
+ raise NotImplementedError(
1562
+ "Can't perform this operation for loaders without 'get_data()'"
1563
+ )
1564
+
1565
+
1566
+ register_loader_type(object, NullProvider)
1567
+
1568
+
1569
+ def _parents(path):
1570
+ """
1571
+ yield all parents of path including path
1572
+ """
1573
+ last = None
1574
+ while path != last:
1575
+ yield path
1576
+ last = path
1577
+ path, _ = os.path.split(path)
1578
+
1579
+
1580
+ class EggProvider(NullProvider):
1581
+ """Provider based on a virtual filesystem"""
1582
+
1583
+ def __init__(self, module):
1584
+ NullProvider.__init__(self, module)
1585
+ self._setup_prefix()
1586
+
1587
+ def _setup_prefix(self):
1588
+ # Assume that metadata may be nested inside a "basket"
1589
+ # of multiple eggs and use module_path instead of .archive.
1590
+ eggs = filter(_is_egg_path, _parents(self.module_path))
1591
+ egg = next(eggs, None)
1592
+ egg and self._set_egg(egg)
1593
+
1594
+ def _set_egg(self, path):
1595
+ self.egg_name = os.path.basename(path)
1596
+ self.egg_info = os.path.join(path, 'EGG-INFO')
1597
+ self.egg_root = path
1598
+
1599
+
1600
+ class DefaultProvider(EggProvider):
1601
+ """Provides access to package resources in the filesystem"""
1602
+
1603
+ def _has(self, path):
1604
+ return os.path.exists(path)
1605
+
1606
+ def _isdir(self, path):
1607
+ return os.path.isdir(path)
1608
+
1609
+ def _listdir(self, path):
1610
+ return os.listdir(path)
1611
+
1612
+ def get_resource_stream(self, manager, resource_name):
1613
+ return open(self._fn(self.module_path, resource_name), 'rb')
1614
+
1615
+ def _get(self, path):
1616
+ with open(path, 'rb') as stream:
1617
+ return stream.read()
1618
+
1619
+ @classmethod
1620
+ def _register(cls):
1621
+ loader_names = 'SourceFileLoader', 'SourcelessFileLoader',
1622
+ for name in loader_names:
1623
+ loader_cls = getattr(importlib_machinery, name, type(None))
1624
+ register_loader_type(loader_cls, cls)
1625
+
1626
+
1627
+ DefaultProvider._register()
1628
+
1629
+
1630
+ class EmptyProvider(NullProvider):
1631
+ """Provider that returns nothing for all requests"""
1632
+
1633
+ module_path = None
1634
+
1635
+ _isdir = _has = lambda self, path: False
1636
+
1637
+ def _get(self, path):
1638
+ return ''
1639
+
1640
+ def _listdir(self, path):
1641
+ return []
1642
+
1643
+ def __init__(self):
1644
+ pass
1645
+
1646
+
1647
+ empty_provider = EmptyProvider()
1648
+
1649
+
1650
+ class ZipManifests(dict):
1651
+ """
1652
+ zip manifest builder
1653
+ """
1654
+
1655
+ @classmethod
1656
+ def build(cls, path):
1657
+ """
1658
+ Build a dictionary similar to the zipimport directory
1659
+ caches, except instead of tuples, store ZipInfo objects.
1660
+
1661
+ Use a platform-specific path separator (os.sep) for the path keys
1662
+ for compatibility with pypy on Windows.
1663
+ """
1664
+ with zipfile.ZipFile(path) as zfile:
1665
+ items = (
1666
+ (
1667
+ name.replace('/', os.sep),
1668
+ zfile.getinfo(name),
1669
+ )
1670
+ for name in zfile.namelist()
1671
+ )
1672
+ return dict(items)
1673
+
1674
+ load = build
1675
+
1676
+
1677
+ class MemoizedZipManifests(ZipManifests):
1678
+ """
1679
+ Memoized zipfile manifests.
1680
+ """
1681
+ manifest_mod = collections.namedtuple('manifest_mod', 'manifest mtime')
1682
+
1683
+ def load(self, path):
1684
+ """
1685
+ Load a manifest at path or return a suitable manifest already loaded.
1686
+ """
1687
+ path = os.path.normpath(path)
1688
+ mtime = os.stat(path).st_mtime
1689
+
1690
+ if path not in self or self[path].mtime != mtime:
1691
+ manifest = self.build(path)
1692
+ self[path] = self.manifest_mod(manifest, mtime)
1693
+
1694
+ return self[path].manifest
1695
+
1696
+
1697
+ class ZipProvider(EggProvider):
1698
+ """Resource support for zips and eggs"""
1699
+
1700
+ eagers = None
1701
+ _zip_manifests = MemoizedZipManifests()
1702
+
1703
+ def __init__(self, module):
1704
+ EggProvider.__init__(self, module)
1705
+ self.zip_pre = self.loader.archive + os.sep
1706
+
1707
+ def _zipinfo_name(self, fspath):
1708
+ # Convert a virtual filename (full path to file) into a zipfile subpath
1709
+ # usable with the zipimport directory cache for our target archive
1710
+ fspath = fspath.rstrip(os.sep)
1711
+ if fspath == self.loader.archive:
1712
+ return ''
1713
+ if fspath.startswith(self.zip_pre):
1714
+ return fspath[len(self.zip_pre):]
1715
+ raise AssertionError(
1716
+ "%s is not a subpath of %s" % (fspath, self.zip_pre)
1717
+ )
1718
+
1719
+ def _parts(self, zip_path):
1720
+ # Convert a zipfile subpath into an egg-relative path part list.
1721
+ # pseudo-fs path
1722
+ fspath = self.zip_pre + zip_path
1723
+ if fspath.startswith(self.egg_root + os.sep):
1724
+ return fspath[len(self.egg_root) + 1:].split(os.sep)
1725
+ raise AssertionError(
1726
+ "%s is not a subpath of %s" % (fspath, self.egg_root)
1727
+ )
1728
+
1729
+ @property
1730
+ def zipinfo(self):
1731
+ return self._zip_manifests.load(self.loader.archive)
1732
+
1733
+ def get_resource_filename(self, manager, resource_name):
1734
+ if not self.egg_name:
1735
+ raise NotImplementedError(
1736
+ "resource_filename() only supported for .egg, not .zip"
1737
+ )
1738
+ # no need to lock for extraction, since we use temp names
1739
+ zip_path = self._resource_to_zip(resource_name)
1740
+ eagers = self._get_eager_resources()
1741
+ if '/'.join(self._parts(zip_path)) in eagers:
1742
+ for name in eagers:
1743
+ self._extract_resource(manager, self._eager_to_zip(name))
1744
+ return self._extract_resource(manager, zip_path)
1745
+
1746
+ @staticmethod
1747
+ def _get_date_and_size(zip_stat):
1748
+ size = zip_stat.file_size
1749
+ # ymdhms+wday, yday, dst
1750
+ date_time = zip_stat.date_time + (0, 0, -1)
1751
+ # 1980 offset already done
1752
+ timestamp = time.mktime(date_time)
1753
+ return timestamp, size
1754
+
1755
+ # FIXME: 'ZipProvider._extract_resource' is too complex (12)
1756
+ def _extract_resource(self, manager, zip_path): # noqa: C901
1757
+
1758
+ if zip_path in self._index():
1759
+ for name in self._index()[zip_path]:
1760
+ last = self._extract_resource(
1761
+ manager, os.path.join(zip_path, name)
1762
+ )
1763
+ # return the extracted directory name
1764
+ return os.path.dirname(last)
1765
+
1766
+ timestamp, size = self._get_date_and_size(self.zipinfo[zip_path])
1767
+
1768
+ if not WRITE_SUPPORT:
1769
+ raise IOError('"os.rename" and "os.unlink" are not supported '
1770
+ 'on this platform')
1771
+ try:
1772
+
1773
+ real_path = manager.get_cache_path(
1774
+ self.egg_name, self._parts(zip_path)
1775
+ )
1776
+
1777
+ if self._is_current(real_path, zip_path):
1778
+ return real_path
1779
+
1780
+ outf, tmpnam = _mkstemp(
1781
+ ".$extract",
1782
+ dir=os.path.dirname(real_path),
1783
+ )
1784
+ os.write(outf, self.loader.get_data(zip_path))
1785
+ os.close(outf)
1786
+ utime(tmpnam, (timestamp, timestamp))
1787
+ manager.postprocess(tmpnam, real_path)
1788
+
1789
+ try:
1790
+ rename(tmpnam, real_path)
1791
+
1792
+ except os.error:
1793
+ if os.path.isfile(real_path):
1794
+ if self._is_current(real_path, zip_path):
1795
+ # the file became current since it was checked above,
1796
+ # so proceed.
1797
+ return real_path
1798
+ # Windows, del old file and retry
1799
+ elif os.name == 'nt':
1800
+ unlink(real_path)
1801
+ rename(tmpnam, real_path)
1802
+ return real_path
1803
+ raise
1804
+
1805
+ except os.error:
1806
+ # report a user-friendly error
1807
+ manager.extraction_error()
1808
+
1809
+ return real_path
1810
+
1811
+ def _is_current(self, file_path, zip_path):
1812
+ """
1813
+ Return True if the file_path is current for this zip_path
1814
+ """
1815
+ timestamp, size = self._get_date_and_size(self.zipinfo[zip_path])
1816
+ if not os.path.isfile(file_path):
1817
+ return False
1818
+ stat = os.stat(file_path)
1819
+ if stat.st_size != size or stat.st_mtime != timestamp:
1820
+ return False
1821
+ # check that the contents match
1822
+ zip_contents = self.loader.get_data(zip_path)
1823
+ with open(file_path, 'rb') as f:
1824
+ file_contents = f.read()
1825
+ return zip_contents == file_contents
1826
+
1827
+ def _get_eager_resources(self):
1828
+ if self.eagers is None:
1829
+ eagers = []
1830
+ for name in ('native_libs.txt', 'eager_resources.txt'):
1831
+ if self.has_metadata(name):
1832
+ eagers.extend(self.get_metadata_lines(name))
1833
+ self.eagers = eagers
1834
+ return self.eagers
1835
+
1836
+ def _index(self):
1837
+ try:
1838
+ return self._dirindex
1839
+ except AttributeError:
1840
+ ind = {}
1841
+ for path in self.zipinfo:
1842
+ parts = path.split(os.sep)
1843
+ while parts:
1844
+ parent = os.sep.join(parts[:-1])
1845
+ if parent in ind:
1846
+ ind[parent].append(parts[-1])
1847
+ break
1848
+ else:
1849
+ ind[parent] = [parts.pop()]
1850
+ self._dirindex = ind
1851
+ return ind
1852
+
1853
+ def _has(self, fspath):
1854
+ zip_path = self._zipinfo_name(fspath)
1855
+ return zip_path in self.zipinfo or zip_path in self._index()
1856
+
1857
+ def _isdir(self, fspath):
1858
+ return self._zipinfo_name(fspath) in self._index()
1859
+
1860
+ def _listdir(self, fspath):
1861
+ return list(self._index().get(self._zipinfo_name(fspath), ()))
1862
+
1863
+ def _eager_to_zip(self, resource_name):
1864
+ return self._zipinfo_name(self._fn(self.egg_root, resource_name))
1865
+
1866
+ def _resource_to_zip(self, resource_name):
1867
+ return self._zipinfo_name(self._fn(self.module_path, resource_name))
1868
+
1869
+
1870
+ register_loader_type(zipimport.zipimporter, ZipProvider)
1871
+
1872
+
1873
+ class FileMetadata(EmptyProvider):
1874
+ """Metadata handler for standalone PKG-INFO files
1875
+
1876
+ Usage::
1877
+
1878
+ metadata = FileMetadata("/path/to/PKG-INFO")
1879
+
1880
+ This provider rejects all data and metadata requests except for PKG-INFO,
1881
+ which is treated as existing, and will be the contents of the file at
1882
+ the provided location.
1883
+ """
1884
+
1885
+ def __init__(self, path):
1886
+ self.path = path
1887
+
1888
+ def _get_metadata_path(self, name):
1889
+ return self.path
1890
+
1891
+ def has_metadata(self, name):
1892
+ return name == 'PKG-INFO' and os.path.isfile(self.path)
1893
+
1894
+ def get_metadata(self, name):
1895
+ if name != 'PKG-INFO':
1896
+ raise KeyError("No metadata except PKG-INFO is available")
1897
+
1898
+ with io.open(self.path, encoding='utf-8', errors="replace") as f:
1899
+ metadata = f.read()
1900
+ self._warn_on_replacement(metadata)
1901
+ return metadata
1902
+
1903
+ def _warn_on_replacement(self, metadata):
1904
+ replacement_char = '�'
1905
+ if replacement_char in metadata:
1906
+ tmpl = "{self.path} could not be properly decoded in UTF-8"
1907
+ msg = tmpl.format(**locals())
1908
+ warnings.warn(msg)
1909
+
1910
+ def get_metadata_lines(self, name):
1911
+ return yield_lines(self.get_metadata(name))
1912
+
1913
+
1914
+ class PathMetadata(DefaultProvider):
1915
+ """Metadata provider for egg directories
1916
+
1917
+ Usage::
1918
+
1919
+ # Development eggs:
1920
+
1921
+ egg_info = "/path/to/PackageName.egg-info"
1922
+ base_dir = os.path.dirname(egg_info)
1923
+ metadata = PathMetadata(base_dir, egg_info)
1924
+ dist_name = os.path.splitext(os.path.basename(egg_info))[0]
1925
+ dist = Distribution(basedir, project_name=dist_name, metadata=metadata)
1926
+
1927
+ # Unpacked egg directories:
1928
+
1929
+ egg_path = "/path/to/PackageName-ver-pyver-etc.egg"
1930
+ metadata = PathMetadata(egg_path, os.path.join(egg_path,'EGG-INFO'))
1931
+ dist = Distribution.from_filename(egg_path, metadata=metadata)
1932
+ """
1933
+
1934
+ def __init__(self, path, egg_info):
1935
+ self.module_path = path
1936
+ self.egg_info = egg_info
1937
+
1938
+
1939
+ class EggMetadata(ZipProvider):
1940
+ """Metadata provider for .egg files"""
1941
+
1942
+ def __init__(self, importer):
1943
+ """Create a metadata provider from a zipimporter"""
1944
+
1945
+ self.zip_pre = importer.archive + os.sep
1946
+ self.loader = importer
1947
+ if importer.prefix:
1948
+ self.module_path = os.path.join(importer.archive, importer.prefix)
1949
+ else:
1950
+ self.module_path = importer.archive
1951
+ self._setup_prefix()
1952
+
1953
+
1954
+ _declare_state('dict', _distribution_finders={})
1955
+
1956
+
1957
+ def register_finder(importer_type, distribution_finder):
1958
+ """Register `distribution_finder` to find distributions in sys.path items
1959
+
1960
+ `importer_type` is the type or class of a PEP 302 "Importer" (sys.path item
1961
+ handler), and `distribution_finder` is a callable that, passed a path
1962
+ item and the importer instance, yields ``Distribution`` instances found on
1963
+ that path item. See ``pkg_resources.find_on_path`` for an example."""
1964
+ _distribution_finders[importer_type] = distribution_finder
1965
+
1966
+
1967
+ def find_distributions(path_item, only=False):
1968
+ """Yield distributions accessible via `path_item`"""
1969
+ importer = get_importer(path_item)
1970
+ finder = _find_adapter(_distribution_finders, importer)
1971
+ return finder(importer, path_item, only)
1972
+
1973
+
1974
+ def find_eggs_in_zip(importer, path_item, only=False):
1975
+ """
1976
+ Find eggs in zip files; possibly multiple nested eggs.
1977
+ """
1978
+ if importer.archive.endswith('.whl'):
1979
+ # wheels are not supported with this finder
1980
+ # they don't have PKG-INFO metadata, and won't ever contain eggs
1981
+ return
1982
+ metadata = EggMetadata(importer)
1983
+ if metadata.has_metadata('PKG-INFO'):
1984
+ yield Distribution.from_filename(path_item, metadata=metadata)
1985
+ if only:
1986
+ # don't yield nested distros
1987
+ return
1988
+ for subitem in metadata.resource_listdir(''):
1989
+ if _is_egg_path(subitem):
1990
+ subpath = os.path.join(path_item, subitem)
1991
+ dists = find_eggs_in_zip(zipimport.zipimporter(subpath), subpath)
1992
+ for dist in dists:
1993
+ yield dist
1994
+ elif subitem.lower().endswith(('.dist-info', '.egg-info')):
1995
+ subpath = os.path.join(path_item, subitem)
1996
+ submeta = EggMetadata(zipimport.zipimporter(subpath))
1997
+ submeta.egg_info = subpath
1998
+ yield Distribution.from_location(path_item, subitem, submeta)
1999
+
2000
+
2001
+ register_finder(zipimport.zipimporter, find_eggs_in_zip)
2002
+
2003
+
2004
+ def find_nothing(importer, path_item, only=False):
2005
+ return ()
2006
+
2007
+
2008
+ register_finder(object, find_nothing)
2009
+
2010
+
2011
+ def _by_version_descending(names):
2012
+ """
2013
+ Given a list of filenames, return them in descending order
2014
+ by version number.
2015
+
2016
+ >>> names = 'bar', 'foo', 'Python-2.7.10.egg', 'Python-2.7.2.egg'
2017
+ >>> _by_version_descending(names)
2018
+ ['Python-2.7.10.egg', 'Python-2.7.2.egg', 'bar', 'foo']
2019
+ >>> names = 'Setuptools-1.2.3b1.egg', 'Setuptools-1.2.3.egg'
2020
+ >>> _by_version_descending(names)
2021
+ ['Setuptools-1.2.3.egg', 'Setuptools-1.2.3b1.egg']
2022
+ >>> names = 'Setuptools-1.2.3b1.egg', 'Setuptools-1.2.3.post1.egg'
2023
+ >>> _by_version_descending(names)
2024
+ ['Setuptools-1.2.3.post1.egg', 'Setuptools-1.2.3b1.egg']
2025
+ """
2026
+ def try_parse(name):
2027
+ """
2028
+ Attempt to parse as a version or return a null version.
2029
+ """
2030
+ try:
2031
+ return packaging.version.Version(name)
2032
+ except Exception:
2033
+ return packaging.version.Version('0')
2034
+
2035
+ def _by_version(name):
2036
+ """
2037
+ Parse each component of the filename
2038
+ """
2039
+ name, ext = os.path.splitext(name)
2040
+ parts = itertools.chain(name.split('-'), [ext])
2041
+ return [try_parse(part) for part in parts]
2042
+
2043
+ return sorted(names, key=_by_version, reverse=True)
2044
+
2045
+
2046
+ def find_on_path(importer, path_item, only=False):
2047
+ """Yield distributions accessible on a sys.path directory"""
2048
+ path_item = _normalize_cached(path_item)
2049
+
2050
+ if _is_unpacked_egg(path_item):
2051
+ yield Distribution.from_filename(
2052
+ path_item, metadata=PathMetadata(
2053
+ path_item, os.path.join(path_item, 'EGG-INFO')
2054
+ )
2055
+ )
2056
+ return
2057
+
2058
+ entries = (
2059
+ os.path.join(path_item, child)
2060
+ for child in safe_listdir(path_item)
2061
+ )
2062
+
2063
+ # for performance, before sorting by version,
2064
+ # screen entries for only those that will yield
2065
+ # distributions
2066
+ filtered = (
2067
+ entry
2068
+ for entry in entries
2069
+ if dist_factory(path_item, entry, only)
2070
+ )
2071
+
2072
+ # scan for .egg and .egg-info in directory
2073
+ path_item_entries = _by_version_descending(filtered)
2074
+ for entry in path_item_entries:
2075
+ fullpath = os.path.join(path_item, entry)
2076
+ factory = dist_factory(path_item, entry, only)
2077
+ for dist in factory(fullpath):
2078
+ yield dist
2079
+
2080
+
2081
+ def dist_factory(path_item, entry, only):
2082
+ """Return a dist_factory for the given entry."""
2083
+ lower = entry.lower()
2084
+ is_egg_info = lower.endswith('.egg-info')
2085
+ is_dist_info = (
2086
+ lower.endswith('.dist-info') and
2087
+ os.path.isdir(os.path.join(path_item, entry))
2088
+ )
2089
+ is_meta = is_egg_info or is_dist_info
2090
+ return (
2091
+ distributions_from_metadata
2092
+ if is_meta else
2093
+ find_distributions
2094
+ if not only and _is_egg_path(entry) else
2095
+ resolve_egg_link
2096
+ if not only and lower.endswith('.egg-link') else
2097
+ NoDists()
2098
+ )
2099
+
2100
+
2101
+ class NoDists:
2102
+ """
2103
+ >>> bool(NoDists())
2104
+ False
2105
+
2106
+ >>> list(NoDists()('anything'))
2107
+ []
2108
+ """
2109
+ def __bool__(self):
2110
+ return False
2111
+
2112
+ def __call__(self, fullpath):
2113
+ return iter(())
2114
+
2115
+
2116
+ def safe_listdir(path):
2117
+ """
2118
+ Attempt to list contents of path, but suppress some exceptions.
2119
+ """
2120
+ try:
2121
+ return os.listdir(path)
2122
+ except (PermissionError, NotADirectoryError):
2123
+ pass
2124
+ except OSError as e:
2125
+ # Ignore the directory if does not exist, not a directory or
2126
+ # permission denied
2127
+ if e.errno not in (errno.ENOTDIR, errno.EACCES, errno.ENOENT):
2128
+ raise
2129
+ return ()
2130
+
2131
+
2132
+ def distributions_from_metadata(path):
2133
+ root = os.path.dirname(path)
2134
+ if os.path.isdir(path):
2135
+ if len(os.listdir(path)) == 0:
2136
+ # empty metadata dir; skip
2137
+ return
2138
+ metadata = PathMetadata(root, path)
2139
+ else:
2140
+ metadata = FileMetadata(path)
2141
+ entry = os.path.basename(path)
2142
+ yield Distribution.from_location(
2143
+ root, entry, metadata, precedence=DEVELOP_DIST,
2144
+ )
2145
+
2146
+
2147
+ def non_empty_lines(path):
2148
+ """
2149
+ Yield non-empty lines from file at path
2150
+ """
2151
+ with open(path) as f:
2152
+ for line in f:
2153
+ line = line.strip()
2154
+ if line:
2155
+ yield line
2156
+
2157
+
2158
+ def resolve_egg_link(path):
2159
+ """
2160
+ Given a path to an .egg-link, resolve distributions
2161
+ present in the referenced path.
2162
+ """
2163
+ referenced_paths = non_empty_lines(path)
2164
+ resolved_paths = (
2165
+ os.path.join(os.path.dirname(path), ref)
2166
+ for ref in referenced_paths
2167
+ )
2168
+ dist_groups = map(find_distributions, resolved_paths)
2169
+ return next(dist_groups, ())
2170
+
2171
+
2172
+ register_finder(pkgutil.ImpImporter, find_on_path)
2173
+
2174
+ if hasattr(importlib_machinery, 'FileFinder'):
2175
+ register_finder(importlib_machinery.FileFinder, find_on_path)
2176
+
2177
+ _declare_state('dict', _namespace_handlers={})
2178
+ _declare_state('dict', _namespace_packages={})
2179
+
2180
+
2181
+ def register_namespace_handler(importer_type, namespace_handler):
2182
+ """Register `namespace_handler` to declare namespace packages
2183
+
2184
+ `importer_type` is the type or class of a PEP 302 "Importer" (sys.path item
2185
+ handler), and `namespace_handler` is a callable like this::
2186
+
2187
+ def namespace_handler(importer, path_entry, moduleName, module):
2188
+ # return a path_entry to use for child packages
2189
+
2190
+ Namespace handlers are only called if the importer object has already
2191
+ agreed that it can handle the relevant path item, and they should only
2192
+ return a subpath if the module __path__ does not already contain an
2193
+ equivalent subpath. For an example namespace handler, see
2194
+ ``pkg_resources.file_ns_handler``.
2195
+ """
2196
+ _namespace_handlers[importer_type] = namespace_handler
2197
+
2198
+
2199
+ def _handle_ns(packageName, path_item):
2200
+ """Ensure that named package includes a subpath of path_item (if needed)"""
2201
+
2202
+ importer = get_importer(path_item)
2203
+ if importer is None:
2204
+ return None
2205
+
2206
+ # use find_spec (PEP 451) and fall-back to find_module (PEP 302)
2207
+ try:
2208
+ loader = importer.find_spec(packageName).loader
2209
+ except AttributeError:
2210
+ # capture warnings due to #1111
2211
+ with warnings.catch_warnings():
2212
+ warnings.simplefilter("ignore")
2213
+ loader = importer.find_module(packageName)
2214
+
2215
+ if loader is None:
2216
+ return None
2217
+ module = sys.modules.get(packageName)
2218
+ if module is None:
2219
+ module = sys.modules[packageName] = types.ModuleType(packageName)
2220
+ module.__path__ = []
2221
+ _set_parent_ns(packageName)
2222
+ elif not hasattr(module, '__path__'):
2223
+ raise TypeError("Not a package:", packageName)
2224
+ handler = _find_adapter(_namespace_handlers, importer)
2225
+ subpath = handler(importer, path_item, packageName, module)
2226
+ if subpath is not None:
2227
+ path = module.__path__
2228
+ path.append(subpath)
2229
+ importlib.import_module(packageName)
2230
+ _rebuild_mod_path(path, packageName, module)
2231
+ return subpath
2232
+
2233
+
2234
+ def _rebuild_mod_path(orig_path, package_name, module):
2235
+ """
2236
+ Rebuild module.__path__ ensuring that all entries are ordered
2237
+ corresponding to their sys.path order
2238
+ """
2239
+ sys_path = [_normalize_cached(p) for p in sys.path]
2240
+
2241
+ def safe_sys_path_index(entry):
2242
+ """
2243
+ Workaround for #520 and #513.
2244
+ """
2245
+ try:
2246
+ return sys_path.index(entry)
2247
+ except ValueError:
2248
+ return float('inf')
2249
+
2250
+ def position_in_sys_path(path):
2251
+ """
2252
+ Return the ordinal of the path based on its position in sys.path
2253
+ """
2254
+ path_parts = path.split(os.sep)
2255
+ module_parts = package_name.count('.') + 1
2256
+ parts = path_parts[:-module_parts]
2257
+ return safe_sys_path_index(_normalize_cached(os.sep.join(parts)))
2258
+
2259
+ new_path = sorted(orig_path, key=position_in_sys_path)
2260
+ new_path = [_normalize_cached(p) for p in new_path]
2261
+
2262
+ if isinstance(module.__path__, list):
2263
+ module.__path__[:] = new_path
2264
+ else:
2265
+ module.__path__ = new_path
2266
+
2267
+
2268
+ def declare_namespace(packageName):
2269
+ """Declare that package 'packageName' is a namespace package"""
2270
+
2271
+ _imp.acquire_lock()
2272
+ try:
2273
+ if packageName in _namespace_packages:
2274
+ return
2275
+
2276
+ path = sys.path
2277
+ parent, _, _ = packageName.rpartition('.')
2278
+
2279
+ if parent:
2280
+ declare_namespace(parent)
2281
+ if parent not in _namespace_packages:
2282
+ __import__(parent)
2283
+ try:
2284
+ path = sys.modules[parent].__path__
2285
+ except AttributeError as e:
2286
+ raise TypeError("Not a package:", parent) from e
2287
+
2288
+ # Track what packages are namespaces, so when new path items are added,
2289
+ # they can be updated
2290
+ _namespace_packages.setdefault(parent or None, []).append(packageName)
2291
+ _namespace_packages.setdefault(packageName, [])
2292
+
2293
+ for path_item in path:
2294
+ # Ensure all the parent's path items are reflected in the child,
2295
+ # if they apply
2296
+ _handle_ns(packageName, path_item)
2297
+
2298
+ finally:
2299
+ _imp.release_lock()
2300
+
2301
+
2302
+ def fixup_namespace_packages(path_item, parent=None):
2303
+ """Ensure that previously-declared namespace packages include path_item"""
2304
+ _imp.acquire_lock()
2305
+ try:
2306
+ for package in _namespace_packages.get(parent, ()):
2307
+ subpath = _handle_ns(package, path_item)
2308
+ if subpath:
2309
+ fixup_namespace_packages(subpath, package)
2310
+ finally:
2311
+ _imp.release_lock()
2312
+
2313
+
2314
+ def file_ns_handler(importer, path_item, packageName, module):
2315
+ """Compute an ns-package subpath for a filesystem or zipfile importer"""
2316
+
2317
+ subpath = os.path.join(path_item, packageName.split('.')[-1])
2318
+ normalized = _normalize_cached(subpath)
2319
+ for item in module.__path__:
2320
+ if _normalize_cached(item) == normalized:
2321
+ break
2322
+ else:
2323
+ # Only return the path if it's not already there
2324
+ return subpath
2325
+
2326
+
2327
+ register_namespace_handler(pkgutil.ImpImporter, file_ns_handler)
2328
+ register_namespace_handler(zipimport.zipimporter, file_ns_handler)
2329
+
2330
+ if hasattr(importlib_machinery, 'FileFinder'):
2331
+ register_namespace_handler(importlib_machinery.FileFinder, file_ns_handler)
2332
+
2333
+
2334
+ def null_ns_handler(importer, path_item, packageName, module):
2335
+ return None
2336
+
2337
+
2338
+ register_namespace_handler(object, null_ns_handler)
2339
+
2340
+
2341
+ def normalize_path(filename):
2342
+ """Normalize a file/dir name for comparison purposes"""
2343
+ return os.path.normcase(os.path.realpath(os.path.normpath(
2344
+ _cygwin_patch(filename))))
2345
+
2346
+
2347
+ def _cygwin_patch(filename): # pragma: nocover
2348
+ """
2349
+ Contrary to POSIX 2008, on Cygwin, getcwd (3) contains
2350
+ symlink components. Using
2351
+ os.path.abspath() works around this limitation. A fix in os.getcwd()
2352
+ would probably better, in Cygwin even more so, except
2353
+ that this seems to be by design...
2354
+ """
2355
+ return os.path.abspath(filename) if sys.platform == 'cygwin' else filename
2356
+
2357
+
2358
+ def _normalize_cached(filename, _cache={}):
2359
+ try:
2360
+ return _cache[filename]
2361
+ except KeyError:
2362
+ _cache[filename] = result = normalize_path(filename)
2363
+ return result
2364
+
2365
+
2366
+ def _is_egg_path(path):
2367
+ """
2368
+ Determine if given path appears to be an egg.
2369
+ """
2370
+ return _is_zip_egg(path) or _is_unpacked_egg(path)
2371
+
2372
+
2373
+ def _is_zip_egg(path):
2374
+ return (
2375
+ path.lower().endswith('.egg') and
2376
+ os.path.isfile(path) and
2377
+ zipfile.is_zipfile(path)
2378
+ )
2379
+
2380
+
2381
+ def _is_unpacked_egg(path):
2382
+ """
2383
+ Determine if given path appears to be an unpacked egg.
2384
+ """
2385
+ return (
2386
+ path.lower().endswith('.egg') and
2387
+ os.path.isfile(os.path.join(path, 'EGG-INFO', 'PKG-INFO'))
2388
+ )
2389
+
2390
+
2391
+ def _set_parent_ns(packageName):
2392
+ parts = packageName.split('.')
2393
+ name = parts.pop()
2394
+ if parts:
2395
+ parent = '.'.join(parts)
2396
+ setattr(sys.modules[parent], name, sys.modules[packageName])
2397
+
2398
+
2399
+ def _nonblank(str):
2400
+ return str and not str.startswith('#')
2401
+
2402
+
2403
+ @functools.singledispatch
2404
+ def yield_lines(iterable):
2405
+ """Yield valid lines of a string or iterable"""
2406
+ return itertools.chain.from_iterable(map(yield_lines, iterable))
2407
+
2408
+
2409
+ @yield_lines.register(str)
2410
+ def _(text):
2411
+ return filter(_nonblank, map(str.strip, text.splitlines()))
2412
+
2413
+
2414
+ MODULE = re.compile(r"\w+(\.\w+)*$").match
2415
+ EGG_NAME = re.compile(
2416
+ r"""
2417
+ (?P<name>[^-]+) (
2418
+ -(?P<ver>[^-]+) (
2419
+ -py(?P<pyver>[^-]+) (
2420
+ -(?P<plat>.+)
2421
+ )?
2422
+ )?
2423
+ )?
2424
+ """,
2425
+ re.VERBOSE | re.IGNORECASE,
2426
+ ).match
2427
+
2428
+
2429
+ class EntryPoint:
2430
+ """Object representing an advertised importable object"""
2431
+
2432
+ def __init__(self, name, module_name, attrs=(), extras=(), dist=None):
2433
+ if not MODULE(module_name):
2434
+ raise ValueError("Invalid module name", module_name)
2435
+ self.name = name
2436
+ self.module_name = module_name
2437
+ self.attrs = tuple(attrs)
2438
+ self.extras = tuple(extras)
2439
+ self.dist = dist
2440
+
2441
+ def __str__(self):
2442
+ s = "%s = %s" % (self.name, self.module_name)
2443
+ if self.attrs:
2444
+ s += ':' + '.'.join(self.attrs)
2445
+ if self.extras:
2446
+ s += ' [%s]' % ','.join(self.extras)
2447
+ return s
2448
+
2449
+ def __repr__(self):
2450
+ return "EntryPoint.parse(%r)" % str(self)
2451
+
2452
+ def load(self, require=True, *args, **kwargs):
2453
+ """
2454
+ Require packages for this EntryPoint, then resolve it.
2455
+ """
2456
+ if not require or args or kwargs:
2457
+ warnings.warn(
2458
+ "Parameters to load are deprecated. Call .resolve and "
2459
+ ".require separately.",
2460
+ PkgResourcesDeprecationWarning,
2461
+ stacklevel=2,
2462
+ )
2463
+ if require:
2464
+ self.require(*args, **kwargs)
2465
+ return self.resolve()
2466
+
2467
+ def resolve(self):
2468
+ """
2469
+ Resolve the entry point from its module and attrs.
2470
+ """
2471
+ module = __import__(self.module_name, fromlist=['__name__'], level=0)
2472
+ try:
2473
+ return functools.reduce(getattr, self.attrs, module)
2474
+ except AttributeError as exc:
2475
+ raise ImportError(str(exc)) from exc
2476
+
2477
+ def require(self, env=None, installer=None):
2478
+ if self.extras and not self.dist:
2479
+ raise UnknownExtra("Can't require() without a distribution", self)
2480
+
2481
+ # Get the requirements for this entry point with all its extras and
2482
+ # then resolve them. We have to pass `extras` along when resolving so
2483
+ # that the working set knows what extras we want. Otherwise, for
2484
+ # dist-info distributions, the working set will assume that the
2485
+ # requirements for that extra are purely optional and skip over them.
2486
+ reqs = self.dist.requires(self.extras)
2487
+ items = working_set.resolve(reqs, env, installer, extras=self.extras)
2488
+ list(map(working_set.add, items))
2489
+
2490
+ pattern = re.compile(
2491
+ r'\s*'
2492
+ r'(?P<name>.+?)\s*'
2493
+ r'=\s*'
2494
+ r'(?P<module>[\w.]+)\s*'
2495
+ r'(:\s*(?P<attr>[\w.]+))?\s*'
2496
+ r'(?P<extras>\[.*\])?\s*$'
2497
+ )
2498
+
2499
+ @classmethod
2500
+ def parse(cls, src, dist=None):
2501
+ """Parse a single entry point from string `src`
2502
+
2503
+ Entry point syntax follows the form::
2504
+
2505
+ name = some.module:some.attr [extra1, extra2]
2506
+
2507
+ The entry name and module name are required, but the ``:attrs`` and
2508
+ ``[extras]`` parts are optional
2509
+ """
2510
+ m = cls.pattern.match(src)
2511
+ if not m:
2512
+ msg = "EntryPoint must be in 'name=module:attrs [extras]' format"
2513
+ raise ValueError(msg, src)
2514
+ res = m.groupdict()
2515
+ extras = cls._parse_extras(res['extras'])
2516
+ attrs = res['attr'].split('.') if res['attr'] else ()
2517
+ return cls(res['name'], res['module'], attrs, extras, dist)
2518
+
2519
+ @classmethod
2520
+ def _parse_extras(cls, extras_spec):
2521
+ if not extras_spec:
2522
+ return ()
2523
+ req = Requirement.parse('x' + extras_spec)
2524
+ if req.specs:
2525
+ raise ValueError()
2526
+ return req.extras
2527
+
2528
+ @classmethod
2529
+ def parse_group(cls, group, lines, dist=None):
2530
+ """Parse an entry point group"""
2531
+ if not MODULE(group):
2532
+ raise ValueError("Invalid group name", group)
2533
+ this = {}
2534
+ for line in yield_lines(lines):
2535
+ ep = cls.parse(line, dist)
2536
+ if ep.name in this:
2537
+ raise ValueError("Duplicate entry point", group, ep.name)
2538
+ this[ep.name] = ep
2539
+ return this
2540
+
2541
+ @classmethod
2542
+ def parse_map(cls, data, dist=None):
2543
+ """Parse a map of entry point groups"""
2544
+ if isinstance(data, dict):
2545
+ data = data.items()
2546
+ else:
2547
+ data = split_sections(data)
2548
+ maps = {}
2549
+ for group, lines in data:
2550
+ if group is None:
2551
+ if not lines:
2552
+ continue
2553
+ raise ValueError("Entry points must be listed in groups")
2554
+ group = group.strip()
2555
+ if group in maps:
2556
+ raise ValueError("Duplicate group name", group)
2557
+ maps[group] = cls.parse_group(group, lines, dist)
2558
+ return maps
2559
+
2560
+
2561
+ def _version_from_file(lines):
2562
+ """
2563
+ Given an iterable of lines from a Metadata file, return
2564
+ the value of the Version field, if present, or None otherwise.
2565
+ """
2566
+ def is_version_line(line):
2567
+ return line.lower().startswith('version:')
2568
+ version_lines = filter(is_version_line, lines)
2569
+ line = next(iter(version_lines), '')
2570
+ _, _, value = line.partition(':')
2571
+ return safe_version(value.strip()) or None
2572
+
2573
+
2574
+ class Distribution:
2575
+ """Wrap an actual or potential sys.path entry w/metadata"""
2576
+ PKG_INFO = 'PKG-INFO'
2577
+
2578
+ def __init__(
2579
+ self, location=None, metadata=None, project_name=None,
2580
+ version=None, py_version=PY_MAJOR, platform=None,
2581
+ precedence=EGG_DIST):
2582
+ self.project_name = safe_name(project_name or 'Unknown')
2583
+ if version is not None:
2584
+ self._version = safe_version(version)
2585
+ self.py_version = py_version
2586
+ self.platform = platform
2587
+ self.location = location
2588
+ self.precedence = precedence
2589
+ self._provider = metadata or empty_provider
2590
+
2591
+ @classmethod
2592
+ def from_location(cls, location, basename, metadata=None, **kw):
2593
+ project_name, version, py_version, platform = [None] * 4
2594
+ basename, ext = os.path.splitext(basename)
2595
+ if ext.lower() in _distributionImpl:
2596
+ cls = _distributionImpl[ext.lower()]
2597
+
2598
+ match = EGG_NAME(basename)
2599
+ if match:
2600
+ project_name, version, py_version, platform = match.group(
2601
+ 'name', 'ver', 'pyver', 'plat'
2602
+ )
2603
+ return cls(
2604
+ location, metadata, project_name=project_name, version=version,
2605
+ py_version=py_version, platform=platform, **kw
2606
+ )._reload_version()
2607
+
2608
+ def _reload_version(self):
2609
+ return self
2610
+
2611
+ @property
2612
+ def hashcmp(self):
2613
+ return (
2614
+ self.parsed_version,
2615
+ self.precedence,
2616
+ self.key,
2617
+ self.location,
2618
+ self.py_version or '',
2619
+ self.platform or '',
2620
+ )
2621
+
2622
+ def __hash__(self):
2623
+ return hash(self.hashcmp)
2624
+
2625
+ def __lt__(self, other):
2626
+ return self.hashcmp < other.hashcmp
2627
+
2628
+ def __le__(self, other):
2629
+ return self.hashcmp <= other.hashcmp
2630
+
2631
+ def __gt__(self, other):
2632
+ return self.hashcmp > other.hashcmp
2633
+
2634
+ def __ge__(self, other):
2635
+ return self.hashcmp >= other.hashcmp
2636
+
2637
+ def __eq__(self, other):
2638
+ if not isinstance(other, self.__class__):
2639
+ # It's not a Distribution, so they are not equal
2640
+ return False
2641
+ return self.hashcmp == other.hashcmp
2642
+
2643
+ def __ne__(self, other):
2644
+ return not self == other
2645
+
2646
+ # These properties have to be lazy so that we don't have to load any
2647
+ # metadata until/unless it's actually needed. (i.e., some distributions
2648
+ # may not know their name or version without loading PKG-INFO)
2649
+
2650
+ @property
2651
+ def key(self):
2652
+ try:
2653
+ return self._key
2654
+ except AttributeError:
2655
+ self._key = key = self.project_name.lower()
2656
+ return key
2657
+
2658
+ @property
2659
+ def parsed_version(self):
2660
+ if not hasattr(self, "_parsed_version"):
2661
+ self._parsed_version = parse_version(self.version)
2662
+
2663
+ return self._parsed_version
2664
+
2665
+ def _warn_legacy_version(self):
2666
+ LV = packaging.version.LegacyVersion
2667
+ is_legacy = isinstance(self._parsed_version, LV)
2668
+ if not is_legacy:
2669
+ return
2670
+
2671
+ # While an empty version is technically a legacy version and
2672
+ # is not a valid PEP 440 version, it's also unlikely to
2673
+ # actually come from someone and instead it is more likely that
2674
+ # it comes from setuptools attempting to parse a filename and
2675
+ # including it in the list. So for that we'll gate this warning
2676
+ # on if the version is anything at all or not.
2677
+ if not self.version:
2678
+ return
2679
+
2680
+ tmpl = textwrap.dedent("""
2681
+ '{project_name} ({version})' is being parsed as a legacy,
2682
+ non PEP 440,
2683
+ version. You may find odd behavior and sort order.
2684
+ In particular it will be sorted as less than 0.0. It
2685
+ is recommended to migrate to PEP 440 compatible
2686
+ versions.
2687
+ """).strip().replace('\n', ' ')
2688
+
2689
+ warnings.warn(tmpl.format(**vars(self)), PEP440Warning)
2690
+
2691
+ @property
2692
+ def version(self):
2693
+ try:
2694
+ return self._version
2695
+ except AttributeError as e:
2696
+ version = self._get_version()
2697
+ if version is None:
2698
+ path = self._get_metadata_path_for_display(self.PKG_INFO)
2699
+ msg = (
2700
+ "Missing 'Version:' header and/or {} file at path: {}"
2701
+ ).format(self.PKG_INFO, path)
2702
+ raise ValueError(msg, self) from e
2703
+
2704
+ return version
2705
+
2706
+ @property
2707
+ def _dep_map(self):
2708
+ """
2709
+ A map of extra to its list of (direct) requirements
2710
+ for this distribution, including the null extra.
2711
+ """
2712
+ try:
2713
+ return self.__dep_map
2714
+ except AttributeError:
2715
+ self.__dep_map = self._filter_extras(self._build_dep_map())
2716
+ return self.__dep_map
2717
+
2718
+ @staticmethod
2719
+ def _filter_extras(dm):
2720
+ """
2721
+ Given a mapping of extras to dependencies, strip off
2722
+ environment markers and filter out any dependencies
2723
+ not matching the markers.
2724
+ """
2725
+ for extra in list(filter(None, dm)):
2726
+ new_extra = extra
2727
+ reqs = dm.pop(extra)
2728
+ new_extra, _, marker = extra.partition(':')
2729
+ fails_marker = marker and (
2730
+ invalid_marker(marker)
2731
+ or not evaluate_marker(marker)
2732
+ )
2733
+ if fails_marker:
2734
+ reqs = []
2735
+ new_extra = safe_extra(new_extra) or None
2736
+
2737
+ dm.setdefault(new_extra, []).extend(reqs)
2738
+ return dm
2739
+
2740
+ def _build_dep_map(self):
2741
+ dm = {}
2742
+ for name in 'requires.txt', 'depends.txt':
2743
+ for extra, reqs in split_sections(self._get_metadata(name)):
2744
+ dm.setdefault(extra, []).extend(parse_requirements(reqs))
2745
+ return dm
2746
+
2747
+ def requires(self, extras=()):
2748
+ """List of Requirements needed for this distro if `extras` are used"""
2749
+ dm = self._dep_map
2750
+ deps = []
2751
+ deps.extend(dm.get(None, ()))
2752
+ for ext in extras:
2753
+ try:
2754
+ deps.extend(dm[safe_extra(ext)])
2755
+ except KeyError as e:
2756
+ raise UnknownExtra(
2757
+ "%s has no such extra feature %r" % (self, ext)
2758
+ ) from e
2759
+ return deps
2760
+
2761
+ def _get_metadata_path_for_display(self, name):
2762
+ """
2763
+ Return the path to the given metadata file, if available.
2764
+ """
2765
+ try:
2766
+ # We need to access _get_metadata_path() on the provider object
2767
+ # directly rather than through this class's __getattr__()
2768
+ # since _get_metadata_path() is marked private.
2769
+ path = self._provider._get_metadata_path(name)
2770
+
2771
+ # Handle exceptions e.g. in case the distribution's metadata
2772
+ # provider doesn't support _get_metadata_path().
2773
+ except Exception:
2774
+ return '[could not detect]'
2775
+
2776
+ return path
2777
+
2778
+ def _get_metadata(self, name):
2779
+ if self.has_metadata(name):
2780
+ for line in self.get_metadata_lines(name):
2781
+ yield line
2782
+
2783
+ def _get_version(self):
2784
+ lines = self._get_metadata(self.PKG_INFO)
2785
+ version = _version_from_file(lines)
2786
+
2787
+ return version
2788
+
2789
+ def activate(self, path=None, replace=False):
2790
+ """Ensure distribution is importable on `path` (default=sys.path)"""
2791
+ if path is None:
2792
+ path = sys.path
2793
+ self.insert_on(path, replace=replace)
2794
+ if path is sys.path:
2795
+ fixup_namespace_packages(self.location)
2796
+ for pkg in self._get_metadata('namespace_packages.txt'):
2797
+ if pkg in sys.modules:
2798
+ declare_namespace(pkg)
2799
+
2800
+ def egg_name(self):
2801
+ """Return what this distribution's standard .egg filename should be"""
2802
+ filename = "%s-%s-py%s" % (
2803
+ to_filename(self.project_name), to_filename(self.version),
2804
+ self.py_version or PY_MAJOR
2805
+ )
2806
+
2807
+ if self.platform:
2808
+ filename += '-' + self.platform
2809
+ return filename
2810
+
2811
+ def __repr__(self):
2812
+ if self.location:
2813
+ return "%s (%s)" % (self, self.location)
2814
+ else:
2815
+ return str(self)
2816
+
2817
+ def __str__(self):
2818
+ try:
2819
+ version = getattr(self, 'version', None)
2820
+ except ValueError:
2821
+ version = None
2822
+ version = version or "[unknown version]"
2823
+ return "%s %s" % (self.project_name, version)
2824
+
2825
+ def __getattr__(self, attr):
2826
+ """Delegate all unrecognized public attributes to .metadata provider"""
2827
+ if attr.startswith('_'):
2828
+ raise AttributeError(attr)
2829
+ return getattr(self._provider, attr)
2830
+
2831
+ def __dir__(self):
2832
+ return list(
2833
+ set(super(Distribution, self).__dir__())
2834
+ | set(
2835
+ attr for attr in self._provider.__dir__()
2836
+ if not attr.startswith('_')
2837
+ )
2838
+ )
2839
+
2840
+ @classmethod
2841
+ def from_filename(cls, filename, metadata=None, **kw):
2842
+ return cls.from_location(
2843
+ _normalize_cached(filename), os.path.basename(filename), metadata,
2844
+ **kw
2845
+ )
2846
+
2847
+ def as_requirement(self):
2848
+ """Return a ``Requirement`` that matches this distribution exactly"""
2849
+ if isinstance(self.parsed_version, packaging.version.Version):
2850
+ spec = "%s==%s" % (self.project_name, self.parsed_version)
2851
+ else:
2852
+ spec = "%s===%s" % (self.project_name, self.parsed_version)
2853
+
2854
+ return Requirement.parse(spec)
2855
+
2856
+ def load_entry_point(self, group, name):
2857
+ """Return the `name` entry point of `group` or raise ImportError"""
2858
+ ep = self.get_entry_info(group, name)
2859
+ if ep is None:
2860
+ raise ImportError("Entry point %r not found" % ((group, name),))
2861
+ return ep.load()
2862
+
2863
+ def get_entry_map(self, group=None):
2864
+ """Return the entry point map for `group`, or the full entry map"""
2865
+ try:
2866
+ ep_map = self._ep_map
2867
+ except AttributeError:
2868
+ ep_map = self._ep_map = EntryPoint.parse_map(
2869
+ self._get_metadata('entry_points.txt'), self
2870
+ )
2871
+ if group is not None:
2872
+ return ep_map.get(group, {})
2873
+ return ep_map
2874
+
2875
+ def get_entry_info(self, group, name):
2876
+ """Return the EntryPoint object for `group`+`name`, or ``None``"""
2877
+ return self.get_entry_map(group).get(name)
2878
+
2879
+ # FIXME: 'Distribution.insert_on' is too complex (13)
2880
+ def insert_on(self, path, loc=None, replace=False): # noqa: C901
2881
+ """Ensure self.location is on path
2882
+
2883
+ If replace=False (default):
2884
+ - If location is already in path anywhere, do nothing.
2885
+ - Else:
2886
+ - If it's an egg and its parent directory is on path,
2887
+ insert just ahead of the parent.
2888
+ - Else: add to the end of path.
2889
+ If replace=True:
2890
+ - If location is already on path anywhere (not eggs)
2891
+ or higher priority than its parent (eggs)
2892
+ do nothing.
2893
+ - Else:
2894
+ - If it's an egg and its parent directory is on path,
2895
+ insert just ahead of the parent,
2896
+ removing any lower-priority entries.
2897
+ - Else: add it to the front of path.
2898
+ """
2899
+
2900
+ loc = loc or self.location
2901
+ if not loc:
2902
+ return
2903
+
2904
+ nloc = _normalize_cached(loc)
2905
+ bdir = os.path.dirname(nloc)
2906
+ npath = [(p and _normalize_cached(p) or p) for p in path]
2907
+
2908
+ for p, item in enumerate(npath):
2909
+ if item == nloc:
2910
+ if replace:
2911
+ break
2912
+ else:
2913
+ # don't modify path (even removing duplicates) if
2914
+ # found and not replace
2915
+ return
2916
+ elif item == bdir and self.precedence == EGG_DIST:
2917
+ # if it's an .egg, give it precedence over its directory
2918
+ # UNLESS it's already been added to sys.path and replace=False
2919
+ if (not replace) and nloc in npath[p:]:
2920
+ return
2921
+ if path is sys.path:
2922
+ self.check_version_conflict()
2923
+ path.insert(p, loc)
2924
+ npath.insert(p, nloc)
2925
+ break
2926
+ else:
2927
+ if path is sys.path:
2928
+ self.check_version_conflict()
2929
+ if replace:
2930
+ path.insert(0, loc)
2931
+ else:
2932
+ path.append(loc)
2933
+ return
2934
+
2935
+ # p is the spot where we found or inserted loc; now remove duplicates
2936
+ while True:
2937
+ try:
2938
+ np = npath.index(nloc, p + 1)
2939
+ except ValueError:
2940
+ break
2941
+ else:
2942
+ del npath[np], path[np]
2943
+ # ha!
2944
+ p = np
2945
+
2946
+ return
2947
+
2948
+ def check_version_conflict(self):
2949
+ if self.key == 'setuptools':
2950
+ # ignore the inevitable setuptools self-conflicts :(
2951
+ return
2952
+
2953
+ nsp = dict.fromkeys(self._get_metadata('namespace_packages.txt'))
2954
+ loc = normalize_path(self.location)
2955
+ for modname in self._get_metadata('top_level.txt'):
2956
+ if (modname not in sys.modules or modname in nsp
2957
+ or modname in _namespace_packages):
2958
+ continue
2959
+ if modname in ('pkg_resources', 'setuptools', 'site'):
2960
+ continue
2961
+ fn = getattr(sys.modules[modname], '__file__', None)
2962
+ if fn and (normalize_path(fn).startswith(loc) or
2963
+ fn.startswith(self.location)):
2964
+ continue
2965
+ issue_warning(
2966
+ "Module %s was already imported from %s, but %s is being added"
2967
+ " to sys.path" % (modname, fn, self.location),
2968
+ )
2969
+
2970
+ def has_version(self):
2971
+ try:
2972
+ self.version
2973
+ except ValueError:
2974
+ issue_warning("Unbuilt egg for " + repr(self))
2975
+ return False
2976
+ return True
2977
+
2978
+ def clone(self, **kw):
2979
+ """Copy this distribution, substituting in any changed keyword args"""
2980
+ names = 'project_name version py_version platform location precedence'
2981
+ for attr in names.split():
2982
+ kw.setdefault(attr, getattr(self, attr, None))
2983
+ kw.setdefault('metadata', self._provider)
2984
+ return self.__class__(**kw)
2985
+
2986
+ @property
2987
+ def extras(self):
2988
+ return [dep for dep in self._dep_map if dep]
2989
+
2990
+
2991
+ class EggInfoDistribution(Distribution):
2992
+ def _reload_version(self):
2993
+ """
2994
+ Packages installed by distutils (e.g. numpy or scipy),
2995
+ which uses an old safe_version, and so
2996
+ their version numbers can get mangled when
2997
+ converted to filenames (e.g., 1.11.0.dev0+2329eae to
2998
+ 1.11.0.dev0_2329eae). These distributions will not be
2999
+ parsed properly
3000
+ downstream by Distribution and safe_version, so
3001
+ take an extra step and try to get the version number from
3002
+ the metadata file itself instead of the filename.
3003
+ """
3004
+ md_version = self._get_version()
3005
+ if md_version:
3006
+ self._version = md_version
3007
+ return self
3008
+
3009
+
3010
+ class DistInfoDistribution(Distribution):
3011
+ """
3012
+ Wrap an actual or potential sys.path entry
3013
+ w/metadata, .dist-info style.
3014
+ """
3015
+ PKG_INFO = 'METADATA'
3016
+ EQEQ = re.compile(r"([\(,])\s*(\d.*?)\s*([,\)])")
3017
+
3018
+ @property
3019
+ def _parsed_pkg_info(self):
3020
+ """Parse and cache metadata"""
3021
+ try:
3022
+ return self._pkg_info
3023
+ except AttributeError:
3024
+ metadata = self.get_metadata(self.PKG_INFO)
3025
+ self._pkg_info = email.parser.Parser().parsestr(metadata)
3026
+ return self._pkg_info
3027
+
3028
+ @property
3029
+ def _dep_map(self):
3030
+ try:
3031
+ return self.__dep_map
3032
+ except AttributeError:
3033
+ self.__dep_map = self._compute_dependencies()
3034
+ return self.__dep_map
3035
+
3036
+ def _compute_dependencies(self):
3037
+ """Recompute this distribution's dependencies."""
3038
+ dm = self.__dep_map = {None: []}
3039
+
3040
+ reqs = []
3041
+ # Including any condition expressions
3042
+ for req in self._parsed_pkg_info.get_all('Requires-Dist') or []:
3043
+ reqs.extend(parse_requirements(req))
3044
+
3045
+ def reqs_for_extra(extra):
3046
+ for req in reqs:
3047
+ if not req.marker or req.marker.evaluate({'extra': extra}):
3048
+ yield req
3049
+
3050
+ common = types.MappingProxyType(dict.fromkeys(reqs_for_extra(None)))
3051
+ dm[None].extend(common)
3052
+
3053
+ for extra in self._parsed_pkg_info.get_all('Provides-Extra') or []:
3054
+ s_extra = safe_extra(extra.strip())
3055
+ dm[s_extra] = [r for r in reqs_for_extra(extra) if r not in common]
3056
+
3057
+ return dm
3058
+
3059
+
3060
+ _distributionImpl = {
3061
+ '.egg': Distribution,
3062
+ '.egg-info': EggInfoDistribution,
3063
+ '.dist-info': DistInfoDistribution,
3064
+ }
3065
+
3066
+
3067
+ def issue_warning(*args, **kw):
3068
+ level = 1
3069
+ g = globals()
3070
+ try:
3071
+ # find the first stack frame that is *not* code in
3072
+ # the pkg_resources module, to use for the warning
3073
+ while sys._getframe(level).f_globals is g:
3074
+ level += 1
3075
+ except ValueError:
3076
+ pass
3077
+ warnings.warn(stacklevel=level + 1, *args, **kw)
3078
+
3079
+
3080
+ def parse_requirements(strs):
3081
+ """Yield ``Requirement`` objects for each specification in `strs`
3082
+
3083
+ `strs` must be a string, or a (possibly-nested) iterable thereof.
3084
+ """
3085
+ # create a steppable iterator, so we can handle \-continuations
3086
+ lines = iter(yield_lines(strs))
3087
+
3088
+ for line in lines:
3089
+ # Drop comments -- a hash without a space may be in a URL.
3090
+ if ' #' in line:
3091
+ line = line[:line.find(' #')]
3092
+ # If there is a line continuation, drop it, and append the next line.
3093
+ if line.endswith('\\'):
3094
+ line = line[:-2].strip()
3095
+ try:
3096
+ line += next(lines)
3097
+ except StopIteration:
3098
+ return
3099
+ yield Requirement(line)
3100
+
3101
+
3102
+ class RequirementParseError(packaging.requirements.InvalidRequirement):
3103
+ "Compatibility wrapper for InvalidRequirement"
3104
+
3105
+
3106
+ class Requirement(packaging.requirements.Requirement):
3107
+ def __init__(self, requirement_string):
3108
+ """DO NOT CALL THIS UNDOCUMENTED METHOD; use Requirement.parse()!"""
3109
+ super(Requirement, self).__init__(requirement_string)
3110
+ self.unsafe_name = self.name
3111
+ project_name = safe_name(self.name)
3112
+ self.project_name, self.key = project_name, project_name.lower()
3113
+ self.specs = [
3114
+ (spec.operator, spec.version) for spec in self.specifier]
3115
+ self.extras = tuple(map(safe_extra, self.extras))
3116
+ self.hashCmp = (
3117
+ self.key,
3118
+ self.url,
3119
+ self.specifier,
3120
+ frozenset(self.extras),
3121
+ str(self.marker) if self.marker else None,
3122
+ )
3123
+ self.__hash = hash(self.hashCmp)
3124
+
3125
+ def __eq__(self, other):
3126
+ return (
3127
+ isinstance(other, Requirement) and
3128
+ self.hashCmp == other.hashCmp
3129
+ )
3130
+
3131
+ def __ne__(self, other):
3132
+ return not self == other
3133
+
3134
+ def __contains__(self, item):
3135
+ if isinstance(item, Distribution):
3136
+ if item.key != self.key:
3137
+ return False
3138
+
3139
+ item = item.version
3140
+
3141
+ # Allow prereleases always in order to match the previous behavior of
3142
+ # this method. In the future this should be smarter and follow PEP 440
3143
+ # more accurately.
3144
+ return self.specifier.contains(item, prereleases=True)
3145
+
3146
+ def __hash__(self):
3147
+ return self.__hash
3148
+
3149
+ def __repr__(self):
3150
+ return "Requirement.parse(%r)" % str(self)
3151
+
3152
+ @staticmethod
3153
+ def parse(s):
3154
+ req, = parse_requirements(s)
3155
+ return req
3156
+
3157
+
3158
+ def _always_object(classes):
3159
+ """
3160
+ Ensure object appears in the mro even
3161
+ for old-style classes.
3162
+ """
3163
+ if object not in classes:
3164
+ return classes + (object,)
3165
+ return classes
3166
+
3167
+
3168
+ def _find_adapter(registry, ob):
3169
+ """Return an adapter factory for `ob` from `registry`"""
3170
+ types = _always_object(inspect.getmro(getattr(ob, '__class__', type(ob))))
3171
+ for t in types:
3172
+ if t in registry:
3173
+ return registry[t]
3174
+
3175
+
3176
+ def ensure_directory(path):
3177
+ """Ensure that the parent directory of `path` exists"""
3178
+ dirname = os.path.dirname(path)
3179
+ os.makedirs(dirname, exist_ok=True)
3180
+
3181
+
3182
+ def _bypass_ensure_directory(path):
3183
+ """Sandbox-bypassing version of ensure_directory()"""
3184
+ if not WRITE_SUPPORT:
3185
+ raise IOError('"os.mkdir" not supported on this platform.')
3186
+ dirname, filename = split(path)
3187
+ if dirname and filename and not isdir(dirname):
3188
+ _bypass_ensure_directory(dirname)
3189
+ try:
3190
+ mkdir(dirname, 0o755)
3191
+ except FileExistsError:
3192
+ pass
3193
+
3194
+
3195
+ def split_sections(s):
3196
+ """Split a string or iterable thereof into (section, content) pairs
3197
+
3198
+ Each ``section`` is a stripped version of the section header ("[section]")
3199
+ and each ``content`` is a list of stripped lines excluding blank lines and
3200
+ comment-only lines. If there are any such lines before the first section
3201
+ header, they're returned in a first ``section`` of ``None``.
3202
+ """
3203
+ section = None
3204
+ content = []
3205
+ for line in yield_lines(s):
3206
+ if line.startswith("["):
3207
+ if line.endswith("]"):
3208
+ if section or content:
3209
+ yield section, content
3210
+ section = line[1:-1].strip()
3211
+ content = []
3212
+ else:
3213
+ raise ValueError("Invalid section heading", line)
3214
+ else:
3215
+ content.append(line)
3216
+
3217
+ # wrap up last segment
3218
+ yield section, content
3219
+
3220
+
3221
+ def _mkstemp(*args, **kw):
3222
+ old_open = os.open
3223
+ try:
3224
+ # temporarily bypass sandboxing
3225
+ os.open = os_open
3226
+ return tempfile.mkstemp(*args, **kw)
3227
+ finally:
3228
+ # and then put it back
3229
+ os.open = old_open
3230
+
3231
+
3232
+ # Silence the PEP440Warning by default, so that end users don't get hit by it
3233
+ # randomly just because they use pkg_resources. We want to append the rule
3234
+ # because we want earlier uses of filterwarnings to take precedence over this
3235
+ # one.
3236
+ warnings.filterwarnings("ignore", category=PEP440Warning, append=True)
3237
+
3238
+
3239
+ # from jaraco.functools 1.3
3240
+ def _call_aside(f, *args, **kwargs):
3241
+ f(*args, **kwargs)
3242
+ return f
3243
+
3244
+
3245
+ @_call_aside
3246
+ def _initialize(g=globals()):
3247
+ "Set up global resource manager (deliberately not state-saved)"
3248
+ manager = ResourceManager()
3249
+ g['_manager'] = manager
3250
+ g.update(
3251
+ (name, getattr(manager, name))
3252
+ for name in dir(manager)
3253
+ if not name.startswith('_')
3254
+ )
3255
+
3256
+
3257
+ class PkgResourcesDeprecationWarning(Warning):
3258
+ """
3259
+ Base class for warning about deprecations in ``pkg_resources``
3260
+
3261
+ This class is not derived from ``DeprecationWarning``, and as such is
3262
+ visible by default.
3263
+ """
3264
+
3265
+
3266
+ @_call_aside
3267
+ def _initialize_master_working_set():
3268
+ """
3269
+ Prepare the master working set and make the ``require()``
3270
+ API available.
3271
+
3272
+ This function has explicit effects on the global state
3273
+ of pkg_resources. It is intended to be invoked once at
3274
+ the initialization of this module.
3275
+
3276
+ Invocation by other packages is unsupported and done
3277
+ at their own risk.
3278
+ """
3279
+ working_set = WorkingSet._build_master()
3280
+ _declare_state('object', working_set=working_set)
3281
+
3282
+ require = working_set.require
3283
+ iter_entry_points = working_set.iter_entry_points
3284
+ add_activation_listener = working_set.subscribe
3285
+ run_script = working_set.run_script
3286
+ # backward compatibility
3287
+ run_main = run_script
3288
+ # Activate all distributions already on sys.path with replace=False and
3289
+ # ensure that all distributions added to the working set in the future
3290
+ # (e.g. by calling ``require()``) will get activated as well,
3291
+ # with higher priority (replace=True).
3292
+ tuple(
3293
+ dist.activate(replace=False)
3294
+ for dist in working_set
3295
+ )
3296
+ add_activation_listener(
3297
+ lambda dist: dist.activate(replace=True),
3298
+ existing=False,
3299
+ )
3300
+ working_set.entries = []
3301
+ # match order
3302
+ list(map(working_set.add_entry, sys.path))
3303
+ globals().update(locals())