py2docfx 0.1.16.dev2064350__py3-none-any.whl → 0.1.17__py3-none-any.whl

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.
Files changed (388) hide show
  1. py2docfx/convert_prepare/environment.py +1 -3
  2. py2docfx/convert_prepare/get_source.py +1 -6
  3. py2docfx/convert_prepare/package_info.py +1 -1
  4. py2docfx/docfx_yaml/miss_reference.py +1 -1
  5. py2docfx/docfx_yaml/parameter_utils.py +58 -6
  6. py2docfx/docfx_yaml/tests/roots/test-translator-typing/code_with_typing.py +14 -0
  7. py2docfx/docfx_yaml/tests/roots/test-translator-typing/conf.py +18 -0
  8. py2docfx/docfx_yaml/tests/test_translator_typing.py +39 -0
  9. py2docfx/docfx_yaml/utils.py +2 -2
  10. py2docfx/venv/basevenv/Lib/site-packages/certifi/__init__.py +1 -1
  11. py2docfx/venv/basevenv/Lib/site-packages/certifi/core.py +1 -32
  12. py2docfx/venv/basevenv/Lib/site-packages/charset_normalizer/cli/__main__.py +62 -2
  13. py2docfx/venv/basevenv/Lib/site-packages/charset_normalizer/constant.py +17 -0
  14. py2docfx/venv/basevenv/Lib/site-packages/charset_normalizer/legacy.py +1 -3
  15. py2docfx/venv/basevenv/Lib/site-packages/charset_normalizer/md.py +19 -14
  16. py2docfx/venv/basevenv/Lib/site-packages/charset_normalizer/utils.py +6 -0
  17. py2docfx/venv/basevenv/Lib/site-packages/charset_normalizer/version.py +1 -1
  18. py2docfx/venv/basevenv/Lib/site-packages/packaging/__init__.py +1 -1
  19. py2docfx/venv/basevenv/Lib/site-packages/packaging/_elffile.py +1 -2
  20. py2docfx/venv/basevenv/Lib/site-packages/packaging/_manylinux.py +1 -2
  21. py2docfx/venv/basevenv/Lib/site-packages/packaging/_parser.py +1 -2
  22. py2docfx/venv/basevenv/Lib/site-packages/packaging/_tokenizer.py +5 -4
  23. py2docfx/venv/basevenv/Lib/site-packages/packaging/licenses/__init__.py +1 -1
  24. py2docfx/venv/basevenv/Lib/site-packages/packaging/markers.py +53 -22
  25. py2docfx/venv/basevenv/Lib/site-packages/packaging/metadata.py +1 -2
  26. py2docfx/venv/basevenv/Lib/site-packages/packaging/specifiers.py +1 -2
  27. py2docfx/venv/basevenv/Lib/site-packages/packaging/tags.py +39 -0
  28. py2docfx/venv/basevenv/Lib/site-packages/pkg_resources/__init__.py +6 -7
  29. py2docfx/venv/basevenv/Lib/site-packages/pygments/__init__.py +1 -1
  30. py2docfx/venv/basevenv/Lib/site-packages/pygments/lexers/_sql_builtins.py +106 -0
  31. py2docfx/venv/basevenv/Lib/site-packages/pygments/lexers/scripting.py +5 -3
  32. py2docfx/venv/basevenv/Lib/site-packages/pygments/lexers/sql.py +24 -118
  33. py2docfx/venv/basevenv/Lib/site-packages/requests/__version__.py +2 -2
  34. py2docfx/venv/basevenv/Lib/site-packages/requests/compat.py +12 -0
  35. py2docfx/venv/basevenv/Lib/site-packages/requests/models.py +3 -1
  36. py2docfx/venv/basevenv/Lib/site-packages/requests/utils.py +6 -16
  37. py2docfx/venv/basevenv/Lib/site-packages/setuptools/__init__.py +0 -38
  38. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_discovery.py +33 -0
  39. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_distutils/command/build_scripts.py +1 -1
  40. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_distutils/command/config.py +0 -2
  41. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_distutils/compilers/C/tests/test_unix.py +63 -0
  42. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_distutils/compilers/C/unix.py +5 -6
  43. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_entry_points.py +4 -0
  44. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_normalization.py +0 -2
  45. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_path.py +12 -3
  46. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_reqs.py +1 -1
  47. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_scripts.py +361 -0
  48. py2docfx/venv/basevenv/Lib/site-packages/setuptools/_shutil.py +6 -0
  49. py2docfx/venv/basevenv/Lib/site-packages/setuptools/build_meta.py +25 -37
  50. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/bdist_egg.py +9 -11
  51. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/bdist_wheel.py +1 -1
  52. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/build_ext.py +29 -28
  53. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/develop.py +39 -179
  54. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/easy_install.py +17 -2352
  55. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/editable_wheel.py +14 -31
  56. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/egg_info.py +0 -2
  57. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/install.py +3 -55
  58. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/install_scripts.py +5 -11
  59. py2docfx/venv/basevenv/Lib/site-packages/setuptools/command/sdist.py +1 -1
  60. py2docfx/venv/basevenv/Lib/site-packages/setuptools/compat/py310.py +11 -0
  61. py2docfx/venv/basevenv/Lib/site-packages/setuptools/dist.py +10 -12
  62. py2docfx/venv/basevenv/Lib/site-packages/setuptools/installer.py +34 -29
  63. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/contexts.py +0 -14
  64. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/fixtures.py +235 -0
  65. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/integration/test_pbr.py +20 -0
  66. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_build_meta.py +0 -24
  67. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_develop.py +1 -64
  68. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_dist.py +2 -2
  69. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_dist_info.py +0 -63
  70. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_editable_install.py +15 -41
  71. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_egg_info.py +3 -2
  72. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_scripts.py +12 -0
  73. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_wheel.py +12 -36
  74. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_windows_wrappers.py +3 -4
  75. py2docfx/venv/basevenv/Lib/site-packages/setuptools/wheel.py +49 -24
  76. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/__init__.py +6 -0
  77. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/arabic_stemmer.py +798 -797
  78. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/armenian_stemmer.py +212 -213
  79. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/basestemmer.py +20 -54
  80. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/basque_stemmer.py +202 -228
  81. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/catalan_stemmer.py +370 -375
  82. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/danish_stemmer.py +63 -61
  83. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/dutch_porter_stemmer.py +466 -0
  84. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/dutch_stemmer.py +1217 -343
  85. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/english_stemmer.py +295 -264
  86. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/esperanto_stemmer.py +588 -0
  87. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/estonian_stemmer.py +850 -0
  88. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/finnish_stemmer.py +144 -143
  89. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/french_stemmer.py +308 -246
  90. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/german_stemmer.py +224 -167
  91. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/greek_stemmer.py +1314 -1313
  92. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/hindi_stemmer.py +39 -38
  93. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/hungarian_stemmer.py +231 -256
  94. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/indonesian_stemmer.py +61 -64
  95. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/irish_stemmer.py +101 -106
  96. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/italian_stemmer.py +272 -272
  97. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/lithuanian_stemmer.py +233 -240
  98. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/nepali_stemmer.py +108 -134
  99. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/norwegian_stemmer.py +108 -63
  100. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/porter_stemmer.py +101 -108
  101. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/portuguese_stemmer.py +241 -250
  102. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/romanian_stemmer.py +332 -296
  103. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/russian_stemmer.py +178 -179
  104. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/serbian_stemmer.py +2331 -2332
  105. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/spanish_stemmer.py +254 -259
  106. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/swedish_stemmer.py +143 -70
  107. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/tamil_stemmer.py +638 -1491
  108. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/turkish_stemmer.py +326 -292
  109. py2docfx/venv/basevenv/Lib/site-packages/snowballstemmer/yiddish_stemmer.py +245 -246
  110. py2docfx/venv/basevenv/Lib/site-packages/urllib3/_version.py +2 -2
  111. py2docfx/venv/basevenv/Lib/site-packages/urllib3/connection.py +87 -38
  112. py2docfx/venv/basevenv/Lib/site-packages/urllib3/contrib/emscripten/fetch.py +20 -0
  113. py2docfx/venv/basevenv/Lib/site-packages/urllib3/poolmanager.py +17 -1
  114. py2docfx/venv/basevenv/Lib/site-packages/urllib3/response.py +53 -24
  115. py2docfx/venv/basevenv/Lib/site-packages/urllib3/util/request.py +12 -4
  116. py2docfx/venv/basevenv/Lib/site-packages/urllib3/util/ssl_.py +1 -1
  117. py2docfx/venv/venv1/Lib/site-packages/azure/core/_version.py +1 -1
  118. py2docfx/venv/venv1/Lib/site-packages/azure/core/pipeline/_base_async.py +1 -1
  119. py2docfx/venv/venv1/Lib/site-packages/azure/core/pipeline/transport/_aiohttp.py +1 -1
  120. py2docfx/venv/venv1/Lib/site-packages/azure/core/pipeline/transport/_base_async.py +2 -1
  121. py2docfx/venv/venv1/Lib/site-packages/azure/core/pipeline/transport/_requests_asyncio.py +1 -1
  122. py2docfx/venv/venv1/Lib/site-packages/azure/core/rest/_aiohttp.py +2 -2
  123. py2docfx/venv/venv1/Lib/site-packages/azure/core/rest/_requests_asyncio.py +1 -1
  124. py2docfx/venv/venv1/Lib/site-packages/azure/core/tracing/opentelemetry.py +13 -1
  125. py2docfx/venv/venv1/Lib/site-packages/azure/core/utils/_pipeline_transport_rest_shared_async.py +2 -1
  126. py2docfx/venv/venv1/Lib/site-packages/azure/core/utils/_utils.py +1 -1
  127. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_constants.py +1 -0
  128. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/default.py +23 -2
  129. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/environment.py +12 -16
  130. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/service_fabric.py +22 -1
  131. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/user_password.py +10 -6
  132. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/vscode.py +13 -4
  133. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/auth_code_redirect_handler.py +3 -5
  134. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/msal_client.py +2 -1
  135. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_persistent_cache.py +3 -2
  136. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_version.py +1 -1
  137. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/azd_cli.py +1 -1
  138. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/azure_cli.py +1 -1
  139. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/azure_powershell.py +1 -1
  140. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/chained.py +1 -1
  141. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/default.py +22 -2
  142. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/environment.py +2 -2
  143. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/service_fabric.py +17 -1
  144. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/vscode.py +4 -4
  145. py2docfx/venv/venv1/Lib/site-packages/certifi/__init__.py +1 -1
  146. py2docfx/venv/venv1/Lib/site-packages/certifi/core.py +1 -32
  147. py2docfx/venv/venv1/Lib/site-packages/charset_normalizer/cli/__main__.py +62 -2
  148. py2docfx/venv/venv1/Lib/site-packages/charset_normalizer/constant.py +17 -0
  149. py2docfx/venv/venv1/Lib/site-packages/charset_normalizer/legacy.py +1 -3
  150. py2docfx/venv/venv1/Lib/site-packages/charset_normalizer/md.py +19 -14
  151. py2docfx/venv/venv1/Lib/site-packages/charset_normalizer/utils.py +6 -0
  152. py2docfx/venv/venv1/Lib/site-packages/charset_normalizer/version.py +1 -1
  153. py2docfx/venv/venv1/Lib/site-packages/cryptography/__about__.py +2 -2
  154. py2docfx/venv/venv1/Lib/site-packages/cryptography/__init__.py +2 -2
  155. py2docfx/venv/venv1/Lib/site-packages/cryptography/fernet.py +2 -1
  156. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/_oid.py +35 -2
  157. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/backends/openssl/backend.py +33 -10
  158. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/__init__.pyi +14 -5
  159. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/ocsp.pyi +2 -2
  160. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/__init__.pyi +3 -0
  161. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/aead.pyi +49 -45
  162. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/ciphers.pyi +2 -2
  163. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/ed25519.pyi +2 -1
  164. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/ed448.pyi +2 -1
  165. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/hashes.pyi +10 -1
  166. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/hmac.pyi +3 -2
  167. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/kdf.pyi +8 -2
  168. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/keys.pyi +3 -2
  169. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/poly1305.pyi +6 -4
  170. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/x25519.pyi +2 -1
  171. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/x448.pyi +2 -1
  172. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/pkcs12.pyi +9 -3
  173. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/pkcs7.pyi +7 -6
  174. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/test_support.pyi +2 -1
  175. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/x509.pyi +79 -12
  176. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/openssl/_conditional.py +9 -1
  177. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/openssl/binding.py +2 -1
  178. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/decrepit/ciphers/algorithms.py +5 -0
  179. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/_cipheralgorithm.py +4 -2
  180. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/_serialization.py +1 -2
  181. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/asymmetric/dh.py +12 -0
  182. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/asymmetric/dsa.py +16 -3
  183. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/asymmetric/ec.py +47 -3
  184. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/asymmetric/ed25519.py +16 -3
  185. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/asymmetric/ed448.py +16 -3
  186. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/asymmetric/rsa.py +14 -0
  187. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/asymmetric/x25519.py +14 -1
  188. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/asymmetric/x448.py +14 -1
  189. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/ciphers/algorithms.py +6 -6
  190. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/ciphers/base.py +5 -4
  191. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/ciphers/modes.py +18 -18
  192. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/hashes.py +5 -1
  193. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/kdf/concatkdf.py +5 -4
  194. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/kdf/hkdf.py +4 -4
  195. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/kdf/kbkdf.py +7 -4
  196. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/kdf/pbkdf2.py +1 -1
  197. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/kdf/x963kdf.py +1 -1
  198. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/padding.py +7 -121
  199. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/serialization/__init__.py +2 -0
  200. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/serialization/pkcs12.py +21 -1
  201. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/serialization/pkcs7.py +48 -6
  202. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/serialization/ssh.py +68 -18
  203. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/twofactor/hotp.py +3 -2
  204. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/twofactor/totp.py +2 -1
  205. py2docfx/venv/venv1/Lib/site-packages/cryptography/utils.py +15 -3
  206. py2docfx/venv/venv1/Lib/site-packages/cryptography/x509/__init__.py +3 -0
  207. py2docfx/venv/venv1/Lib/site-packages/cryptography/x509/base.py +39 -6
  208. py2docfx/venv/venv1/Lib/site-packages/cryptography/x509/extensions.py +100 -49
  209. py2docfx/venv/venv1/Lib/site-packages/cryptography/x509/name.py +27 -15
  210. py2docfx/venv/venv1/Lib/site-packages/cryptography/x509/ocsp.py +60 -25
  211. py2docfx/venv/venv1/Lib/site-packages/cryptography/x509/oid.py +2 -0
  212. py2docfx/venv/venv1/Lib/site-packages/cryptography/x509/verification.py +6 -0
  213. py2docfx/venv/venv1/Lib/site-packages/google/api_core/bidi.py +17 -4
  214. py2docfx/venv/venv1/Lib/site-packages/google/api_core/client_info.py +6 -0
  215. py2docfx/venv/venv1/Lib/site-packages/google/api_core/gapic_v1/client_info.py +1 -0
  216. py2docfx/venv/venv1/Lib/site-packages/google/api_core/retry/retry_base.py +13 -4
  217. py2docfx/venv/venv1/Lib/site-packages/google/api_core/retry/retry_streaming.py +7 -6
  218. py2docfx/venv/venv1/Lib/site-packages/google/api_core/retry/retry_streaming_async.py +8 -5
  219. py2docfx/venv/venv1/Lib/site-packages/google/api_core/retry/retry_unary.py +7 -6
  220. py2docfx/venv/venv1/Lib/site-packages/google/api_core/retry/retry_unary_async.py +7 -6
  221. py2docfx/venv/venv1/Lib/site-packages/google/api_core/version.py +1 -1
  222. py2docfx/venv/venv1/Lib/site-packages/google/auth/_default.py +2 -36
  223. py2docfx/venv/venv1/Lib/site-packages/google/auth/_helpers.py +240 -0
  224. py2docfx/venv/venv1/Lib/site-packages/google/auth/aio/_helpers.py +62 -0
  225. py2docfx/venv/venv1/Lib/site-packages/google/auth/aio/transport/aiohttp.py +6 -0
  226. py2docfx/venv/venv1/Lib/site-packages/google/auth/compute_engine/_metadata.py +5 -1
  227. py2docfx/venv/venv1/Lib/site-packages/google/auth/compute_engine/credentials.py +2 -1
  228. py2docfx/venv/venv1/Lib/site-packages/google/auth/identity_pool.py +91 -2
  229. py2docfx/venv/venv1/Lib/site-packages/google/auth/impersonated_credentials.py +75 -0
  230. py2docfx/venv/venv1/Lib/site-packages/google/auth/transport/__init__.py +1 -0
  231. py2docfx/venv/venv1/Lib/site-packages/google/auth/transport/_aiohttp_requests.py +8 -1
  232. py2docfx/venv/venv1/Lib/site-packages/google/auth/transport/_http_client.py +3 -1
  233. py2docfx/venv/venv1/Lib/site-packages/google/auth/transport/requests.py +4 -1
  234. py2docfx/venv/venv1/Lib/site-packages/google/auth/transport/urllib3.py +15 -5
  235. py2docfx/venv/venv1/Lib/site-packages/google/auth/version.py +1 -1
  236. py2docfx/venv/venv1/Lib/site-packages/google/oauth2/id_token.py +12 -0
  237. py2docfx/venv/venv1/Lib/site-packages/google/oauth2/webauthn_types.py +1 -1
  238. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/__init__.py +1 -1
  239. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/any.py +15 -1
  240. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/any_pb2.py +3 -3
  241. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/api_pb2.py +3 -3
  242. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/compiler/plugin_pb2.py +3 -3
  243. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/descriptor.py +15 -2
  244. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/descriptor_pb2.py +258 -113
  245. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/descriptor_pool.py +22 -8
  246. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/duration_pb2.py +3 -3
  247. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/empty_pb2.py +3 -3
  248. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/field_mask_pb2.py +3 -3
  249. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/decoder.py +106 -23
  250. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/field_mask.py +3 -1
  251. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/python_edition_defaults.py +1 -1
  252. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/python_message.py +21 -18
  253. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/testing_refleaks.py +8 -2
  254. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/well_known_types.py +60 -43
  255. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/json_format.py +4 -5
  256. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/message_factory.py +16 -0
  257. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/runtime_version.py +2 -2
  258. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/source_context_pb2.py +3 -3
  259. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/struct_pb2.py +3 -3
  260. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/text_format.py +11 -7
  261. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/timestamp_pb2.py +3 -3
  262. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/type_pb2.py +3 -3
  263. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/wrappers_pb2.py +3 -3
  264. py2docfx/venv/venv1/Lib/site-packages/google/rpc/error_details_pb2.py +29 -23
  265. py2docfx/venv/venv1/Lib/site-packages/google/rpc/error_details_pb2.pyi +41 -2
  266. py2docfx/venv/venv1/Lib/site-packages/msal/application.py +1 -0
  267. py2docfx/venv/venv1/Lib/site-packages/msal/individual_cache.py +9 -5
  268. py2docfx/venv/venv1/Lib/site-packages/msal/managed_identity.py +4 -5
  269. py2docfx/venv/venv1/Lib/site-packages/msal/sku.py +1 -1
  270. py2docfx/venv/venv1/Lib/site-packages/msal/throttled_http_client.py +58 -30
  271. py2docfx/venv/venv1/Lib/site-packages/opencensus/__init__.py +1 -1
  272. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/__init__.py +1 -1
  273. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/__init__.py +1 -1
  274. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/common/__init__.py +138 -138
  275. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/common/exporter.py +93 -93
  276. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/common/processor.py +63 -63
  277. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/common/protocol.py +206 -206
  278. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/common/storage.py +205 -205
  279. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/common/transport.py +355 -355
  280. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/common/utils.py +79 -79
  281. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/common/version.py +15 -15
  282. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/log_exporter/__init__.py +314 -314
  283. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/metrics_exporter/__init__.py +190 -190
  284. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/metrics_exporter/standard_metrics/__init__.py +62 -62
  285. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/metrics_exporter/standard_metrics/cpu.py +50 -50
  286. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/metrics_exporter/standard_metrics/http_requests.py +176 -176
  287. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/metrics_exporter/standard_metrics/memory.py +42 -42
  288. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/metrics_exporter/standard_metrics/process.py +87 -87
  289. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/statsbeat/__init__.py +1 -1
  290. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/statsbeat/state.py +50 -50
  291. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/statsbeat/statsbeat.py +100 -100
  292. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/statsbeat/statsbeat_metrics.py +480 -480
  293. py2docfx/venv/venv1/Lib/site-packages/opencensus/ext/azure/trace_exporter/__init__.py +236 -236
  294. py2docfx/venv/venv1/Lib/site-packages/packaging/__init__.py +1 -1
  295. py2docfx/venv/venv1/Lib/site-packages/packaging/_elffile.py +1 -2
  296. py2docfx/venv/venv1/Lib/site-packages/packaging/_manylinux.py +1 -2
  297. py2docfx/venv/venv1/Lib/site-packages/packaging/_parser.py +1 -2
  298. py2docfx/venv/venv1/Lib/site-packages/packaging/_tokenizer.py +5 -4
  299. py2docfx/venv/venv1/Lib/site-packages/packaging/licenses/__init__.py +1 -1
  300. py2docfx/venv/venv1/Lib/site-packages/packaging/markers.py +53 -22
  301. py2docfx/venv/venv1/Lib/site-packages/packaging/metadata.py +1 -2
  302. py2docfx/venv/venv1/Lib/site-packages/packaging/specifiers.py +1 -2
  303. py2docfx/venv/venv1/Lib/site-packages/packaging/tags.py +39 -0
  304. py2docfx/venv/venv1/Lib/site-packages/pkg_resources/__init__.py +6 -7
  305. py2docfx/venv/venv1/Lib/site-packages/requests/__version__.py +2 -2
  306. py2docfx/venv/venv1/Lib/site-packages/requests/compat.py +12 -0
  307. py2docfx/venv/venv1/Lib/site-packages/requests/models.py +3 -1
  308. py2docfx/venv/venv1/Lib/site-packages/requests/utils.py +6 -16
  309. py2docfx/venv/venv1/Lib/site-packages/rsa/__init__.py +2 -2
  310. py2docfx/venv/venv1/Lib/site-packages/rsa/asn1.py +52 -52
  311. py2docfx/venv/venv1/Lib/site-packages/rsa/cli.py +321 -321
  312. py2docfx/venv/venv1/Lib/site-packages/rsa/common.py +184 -184
  313. py2docfx/venv/venv1/Lib/site-packages/rsa/core.py +53 -53
  314. py2docfx/venv/venv1/Lib/site-packages/rsa/key.py +858 -858
  315. py2docfx/venv/venv1/Lib/site-packages/rsa/parallel.py +96 -96
  316. py2docfx/venv/venv1/Lib/site-packages/rsa/pem.py +134 -134
  317. py2docfx/venv/venv1/Lib/site-packages/rsa/pkcs1.py +485 -485
  318. py2docfx/venv/venv1/Lib/site-packages/rsa/pkcs1_v2.py +100 -100
  319. py2docfx/venv/venv1/Lib/site-packages/rsa/prime.py +198 -198
  320. py2docfx/venv/venv1/Lib/site-packages/rsa/py.typed +1 -1
  321. py2docfx/venv/venv1/Lib/site-packages/rsa/randnum.py +95 -95
  322. py2docfx/venv/venv1/Lib/site-packages/rsa/transform.py +72 -72
  323. py2docfx/venv/venv1/Lib/site-packages/rsa/util.py +97 -97
  324. py2docfx/venv/venv1/Lib/site-packages/setuptools/__init__.py +0 -38
  325. py2docfx/venv/venv1/Lib/site-packages/setuptools/_discovery.py +33 -0
  326. py2docfx/venv/venv1/Lib/site-packages/setuptools/_distutils/command/build_scripts.py +1 -1
  327. py2docfx/venv/venv1/Lib/site-packages/setuptools/_distutils/command/config.py +0 -2
  328. py2docfx/venv/venv1/Lib/site-packages/setuptools/_distutils/compilers/C/tests/test_unix.py +63 -0
  329. py2docfx/venv/venv1/Lib/site-packages/setuptools/_distutils/compilers/C/unix.py +5 -6
  330. py2docfx/venv/venv1/Lib/site-packages/setuptools/_entry_points.py +4 -0
  331. py2docfx/venv/venv1/Lib/site-packages/setuptools/_normalization.py +0 -2
  332. py2docfx/venv/venv1/Lib/site-packages/setuptools/_path.py +12 -3
  333. py2docfx/venv/venv1/Lib/site-packages/setuptools/_reqs.py +1 -1
  334. py2docfx/venv/venv1/Lib/site-packages/setuptools/_scripts.py +361 -0
  335. py2docfx/venv/venv1/Lib/site-packages/setuptools/_shutil.py +6 -0
  336. py2docfx/venv/venv1/Lib/site-packages/setuptools/build_meta.py +25 -37
  337. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/bdist_egg.py +9 -11
  338. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/bdist_wheel.py +1 -1
  339. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/build_ext.py +29 -28
  340. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/develop.py +39 -179
  341. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/easy_install.py +17 -2352
  342. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/editable_wheel.py +14 -31
  343. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/egg_info.py +0 -2
  344. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/install.py +3 -55
  345. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/install_scripts.py +5 -11
  346. py2docfx/venv/venv1/Lib/site-packages/setuptools/command/sdist.py +1 -1
  347. py2docfx/venv/venv1/Lib/site-packages/setuptools/compat/py310.py +11 -0
  348. py2docfx/venv/venv1/Lib/site-packages/setuptools/dist.py +10 -12
  349. py2docfx/venv/venv1/Lib/site-packages/setuptools/installer.py +34 -29
  350. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/contexts.py +0 -14
  351. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/fixtures.py +235 -0
  352. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/integration/test_pbr.py +20 -0
  353. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_build_meta.py +0 -24
  354. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_develop.py +1 -64
  355. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_dist.py +2 -2
  356. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_dist_info.py +0 -63
  357. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_editable_install.py +15 -41
  358. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_egg_info.py +3 -2
  359. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_scripts.py +12 -0
  360. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_wheel.py +12 -36
  361. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_windows_wrappers.py +3 -4
  362. py2docfx/venv/venv1/Lib/site-packages/setuptools/wheel.py +49 -24
  363. py2docfx/venv/venv1/Lib/site-packages/typing_extensions.py +357 -703
  364. py2docfx/venv/venv1/Lib/site-packages/urllib3/_version.py +2 -2
  365. py2docfx/venv/venv1/Lib/site-packages/urllib3/connection.py +87 -38
  366. py2docfx/venv/venv1/Lib/site-packages/urllib3/contrib/emscripten/fetch.py +20 -0
  367. py2docfx/venv/venv1/Lib/site-packages/urllib3/poolmanager.py +17 -1
  368. py2docfx/venv/venv1/Lib/site-packages/urllib3/response.py +53 -24
  369. py2docfx/venv/venv1/Lib/site-packages/urllib3/util/request.py +12 -4
  370. py2docfx/venv/venv1/Lib/site-packages/urllib3/util/ssl_.py +1 -1
  371. {py2docfx-0.1.16.dev2064350.dist-info → py2docfx-0.1.17.dist-info}/METADATA +1 -1
  372. {py2docfx-0.1.16.dev2064350.dist-info → py2docfx-0.1.17.dist-info}/RECORD +374 -372
  373. {py2docfx-0.1.16.dev2064350.dist-info → py2docfx-0.1.17.dist-info}/WHEEL +1 -1
  374. py2docfx/venv/basevenv/Lib/site-packages/setuptools/package_index.py +0 -1137
  375. py2docfx/venv/basevenv/Lib/site-packages/setuptools/sandbox.py +0 -536
  376. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/server.py +0 -86
  377. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_easy_install.py +0 -1476
  378. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_packageindex.py +0 -267
  379. py2docfx/venv/basevenv/Lib/site-packages/setuptools/tests/test_sandbox.py +0 -134
  380. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/application.py +0 -119
  381. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/application.py +0 -121
  382. py2docfx/venv/venv1/Lib/site-packages/setuptools/package_index.py +0 -1137
  383. py2docfx/venv/venv1/Lib/site-packages/setuptools/sandbox.py +0 -536
  384. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/server.py +0 -86
  385. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_easy_install.py +0 -1476
  386. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_packageindex.py +0 -267
  387. py2docfx/venv/venv1/Lib/site-packages/setuptools/tests/test_sandbox.py +0 -134
  388. {py2docfx-0.1.16.dev2064350.dist-info → py2docfx-0.1.17.dist-info}/top_level.txt +0 -0
@@ -1,2365 +1,30 @@
1
- """
2
- Easy Install
3
- ------------
4
-
5
- A tool for doing automatic download/extract/build of distutils-based Python
6
- packages. For detailed documentation, see the accompanying EasyInstall.txt
7
- file, or visit the `EasyInstall home page`__.
8
-
9
- __ https://setuptools.pypa.io/en/latest/deprecated/easy_install.html
10
-
11
- """
12
-
13
- from __future__ import annotations
14
-
15
- import configparser
16
- import contextlib
17
- import io
18
1
  import os
19
- import random
20
- import re
21
- import shlex
22
- import shutil
23
- import site
24
- import stat
25
- import struct
26
- import subprocess
27
2
  import sys
28
- import sysconfig
29
- import tempfile
30
- import textwrap
31
- import warnings
32
- import zipfile
33
- import zipimport
34
- from collections.abc import Iterable
35
- from glob import glob
36
- from sysconfig import get_path
37
- from typing import TYPE_CHECKING, NoReturn, TypedDict
38
-
39
- from jaraco.text import yield_lines
3
+ import types
40
4
 
41
- import pkg_resources
42
- from pkg_resources import (
43
- DEVELOP_DIST,
44
- Distribution,
45
- DistributionNotFound,
46
- EggMetadata,
47
- Environment,
48
- PathMetadata,
49
- Requirement,
50
- VersionConflict,
51
- WorkingSet,
52
- find_distributions,
53
- get_distribution,
54
- normalize_path,
55
- resource_string,
56
- )
57
5
  from setuptools import Command
58
- from setuptools.archive_util import unpack_archive
59
- from setuptools.command import bdist_egg, egg_info, setopt
60
- from setuptools.package_index import URL_SCHEME, PackageIndex, parse_requirement_arg
61
- from setuptools.sandbox import run_setup
62
- from setuptools.warnings import SetuptoolsDeprecationWarning, SetuptoolsWarning
63
- from setuptools.wheel import Wheel
64
-
65
- from .._path import ensure_directory
66
- from .._shutil import attempt_chmod_verbose as chmod, rmtree as _rmtree
67
- from ..compat import py39, py312
68
-
69
- from distutils import dir_util, log
70
- from distutils.command import install
71
- from distutils.command.build_scripts import first_line_re
72
- from distutils.errors import (
73
- DistutilsArgError,
74
- DistutilsError,
75
- DistutilsOptionError,
76
- DistutilsPlatformError,
77
- )
78
- from distutils.util import convert_path, get_platform, subst_vars
79
-
80
- if TYPE_CHECKING:
81
- from typing_extensions import Self
82
-
83
- # Turn on PEP440Warnings
84
- warnings.filterwarnings("default", category=pkg_resources.PEP440Warning)
85
-
86
- __all__ = [
87
- 'easy_install',
88
- 'PthDistributions',
89
- 'extract_wininst_cfg',
90
- 'get_exe_prefixes',
91
- ]
92
6
 
93
-
94
- def is_64bit():
95
- return struct.calcsize("P") == 8
96
-
97
-
98
- def _to_bytes(s):
99
- return s.encode('utf8')
100
-
101
-
102
- def isascii(s):
103
- try:
104
- s.encode('ascii')
105
- except UnicodeError:
106
- return False
107
- return True
108
-
109
-
110
- def _one_liner(text):
111
- return textwrap.dedent(text).strip().replace('\n', '; ')
7
+ from .. import _scripts, warnings
112
8
 
113
9
 
114
10
  class easy_install(Command):
115
- """Manage a download/build/install process"""
11
+ """Stubbed command for temporary pbr compatibility."""
116
12
 
117
- description = "Find/get/install Python packages"
118
- command_consumes_arguments = True
119
13
 
120
- user_options = [
121
- ('prefix=', None, "installation prefix"),
122
- ("zip-ok", "z", "install package as a zipfile"),
123
- ("multi-version", "m", "make apps have to require() a version"),
124
- ("upgrade", "U", "force upgrade (searches PyPI for latest versions)"),
125
- ("install-dir=", "d", "install package to DIR"),
126
- ("script-dir=", "s", "install scripts to DIR"),
127
- ("exclude-scripts", "x", "Don't install scripts"),
128
- ("always-copy", "a", "Copy all needed packages to install dir"),
129
- ("index-url=", "i", "base URL of Python Package Index"),
130
- ("find-links=", "f", "additional URL(s) to search for packages"),
131
- ("build-directory=", "b", "download/extract/build in DIR; keep the results"),
132
- (
133
- 'optimize=',
134
- 'O',
135
- 'also compile with optimization: -O1 for "python -O", '
136
- '-O2 for "python -OO", and -O0 to disable [default: -O0]',
137
- ),
138
- ('record=', None, "filename in which to record list of installed files"),
139
- ('always-unzip', 'Z', "don't install as a zipfile, no matter what"),
140
- ('site-dirs=', 'S', "list of directories where .pth files work"),
141
- ('editable', 'e', "Install specified packages in editable form"),
142
- ('no-deps', 'N', "don't install dependencies"),
143
- ('allow-hosts=', 'H', "pattern(s) that hostnames must match"),
144
- ('local-snapshots-ok', 'l', "allow building eggs from local checkouts"),
145
- ('version', None, "print version information and exit"),
146
- (
147
- 'no-find-links',
148
- None,
149
- "Don't load find-links defined in packages being installed",
14
+ def __getattr__(name):
15
+ attr = getattr(
16
+ types.SimpleNamespace(
17
+ ScriptWriter=_scripts.ScriptWriter,
18
+ sys_executable=os.environ.get(
19
+ "__PYVENV_LAUNCHER__", os.path.normpath(sys.executable)
20
+ ),
150
21
  ),
151
- ('user', None, f"install in user site-package '{site.USER_SITE}'"),
152
- ]
153
- boolean_options = [
154
- 'zip-ok',
155
- 'multi-version',
156
- 'exclude-scripts',
157
- 'upgrade',
158
- 'always-copy',
159
- 'editable',
160
- 'no-deps',
161
- 'local-snapshots-ok',
162
- 'version',
163
- 'user',
164
- ]
165
-
166
- negative_opt = {'always-unzip': 'zip-ok'}
167
- create_index = PackageIndex
168
-
169
- def initialize_options(self):
170
- EasyInstallDeprecationWarning.emit()
171
-
172
- # the --user option seems to be an opt-in one,
173
- # so the default should be False.
174
- self.user = False
175
- self.zip_ok = self.local_snapshots_ok = None
176
- self.install_dir = self.script_dir = self.exclude_scripts = None
177
- self.index_url = None
178
- self.find_links = None
179
- self.build_directory = None
180
- self.args = None
181
- self.optimize = self.record = None
182
- self.upgrade = self.always_copy = self.multi_version = None
183
- self.editable = self.no_deps = self.allow_hosts = None
184
- self.root = self.prefix = self.no_report = None
185
- self.version = None
186
- self.install_purelib = None # for pure module distributions
187
- self.install_platlib = None # non-pure (dists w/ extensions)
188
- self.install_headers = None # for C/C++ headers
189
- self.install_lib = None # set to either purelib or platlib
190
- self.install_scripts = None
191
- self.install_data = None
192
- self.install_base = None
193
- self.install_platbase = None
194
- self.install_userbase = site.USER_BASE
195
- self.install_usersite = site.USER_SITE
196
- self.no_find_links = None
197
-
198
- # Options not specifiable via command line
199
- self.package_index = None
200
- self.pth_file = self.always_copy_from = None
201
- self.site_dirs = None
202
- self.installed_projects = {}
203
- # Always read easy_install options, even if we are subclassed, or have
204
- # an independent instance created. This ensures that defaults will
205
- # always come from the standard configuration file(s)' "easy_install"
206
- # section, even if this is a "develop" or "install" command, or some
207
- # other embedding.
208
- self._dry_run = None
209
- self.verbose = self.distribution.verbose
210
- self.distribution._set_command_options(
211
- self, self.distribution.get_option_dict('easy_install')
212
- )
213
-
214
- def delete_blockers(self, blockers) -> None:
215
- extant_blockers = (
216
- filename
217
- for filename in blockers
218
- if os.path.exists(filename) or os.path.islink(filename)
219
- )
220
- list(map(self._delete_path, extant_blockers))
221
-
222
- def _delete_path(self, path):
223
- log.info("Deleting %s", path)
224
- if self.dry_run:
225
- return
226
-
227
- is_tree = os.path.isdir(path) and not os.path.islink(path)
228
- remover = _rmtree if is_tree else os.unlink
229
- remover(path)
230
-
231
- @staticmethod
232
- def _render_version():
233
- """
234
- Render the Setuptools version and installation details, then exit.
235
- """
236
- ver = f'{sys.version_info.major}.{sys.version_info.minor}'
237
- dist = get_distribution('setuptools')
238
- print(f'setuptools {dist.version} from {dist.location} (Python {ver})')
239
- raise SystemExit
240
-
241
- def finalize_options(self) -> None: # noqa: C901 # is too complex (25) # FIXME
242
- self.version and self._render_version()
243
-
244
- py_version = sys.version.split()[0]
245
-
246
- self.config_vars = dict(sysconfig.get_config_vars())
247
-
248
- self.config_vars.update({
249
- 'dist_name': self.distribution.get_name(),
250
- 'dist_version': self.distribution.get_version(),
251
- 'dist_fullname': self.distribution.get_fullname(),
252
- 'py_version': py_version,
253
- 'py_version_short': f'{sys.version_info.major}.{sys.version_info.minor}',
254
- 'py_version_nodot': f'{sys.version_info.major}{sys.version_info.minor}',
255
- 'sys_prefix': self.config_vars['prefix'],
256
- 'sys_exec_prefix': self.config_vars['exec_prefix'],
257
- # Only POSIX systems have abiflags
258
- 'abiflags': getattr(sys, 'abiflags', ''),
259
- # Only python 3.9+ has platlibdir
260
- 'platlibdir': getattr(sys, 'platlibdir', 'lib'),
261
- })
262
- with contextlib.suppress(AttributeError):
263
- # only for distutils outside stdlib
264
- self.config_vars.update({
265
- 'implementation_lower': install._get_implementation().lower(),
266
- 'implementation': install._get_implementation(),
267
- })
268
-
269
- # pypa/distutils#113 Python 3.9 compat
270
- self.config_vars.setdefault(
271
- 'py_version_nodot_plat',
272
- getattr(sys, 'windir', '').replace('.', ''),
273
- )
274
-
275
- self.config_vars['userbase'] = self.install_userbase
276
- self.config_vars['usersite'] = self.install_usersite
277
- if self.user and not site.ENABLE_USER_SITE:
278
- log.warn("WARNING: The user site-packages directory is disabled.")
279
-
280
- self._fix_install_dir_for_user_site()
281
-
282
- self.expand_basedirs()
283
- self.expand_dirs()
284
-
285
- self._expand(
286
- 'install_dir',
287
- 'script_dir',
288
- 'build_directory',
289
- 'site_dirs',
290
- )
291
- # If a non-default installation directory was specified, default the
292
- # script directory to match it.
293
- if self.script_dir is None:
294
- self.script_dir = self.install_dir
295
-
296
- if self.no_find_links is None:
297
- self.no_find_links = False
298
-
299
- # Let install_dir get set by install_lib command, which in turn
300
- # gets its info from the install command, and takes into account
301
- # --prefix and --home and all that other crud.
302
- self.set_undefined_options('install_lib', ('install_dir', 'install_dir'))
303
- # Likewise, set default script_dir from 'install_scripts.install_dir'
304
- self.set_undefined_options('install_scripts', ('install_dir', 'script_dir'))
305
-
306
- if self.user and self.install_purelib:
307
- self.install_dir = self.install_purelib
308
- self.script_dir = self.install_scripts
309
- # default --record from the install command
310
- self.set_undefined_options('install', ('record', 'record'))
311
- self.all_site_dirs = get_site_dirs()
312
- self.all_site_dirs.extend(self._process_site_dirs(self.site_dirs))
313
-
314
- if not self.editable:
315
- self.check_site_dir()
316
- default_index = os.getenv("__EASYINSTALL_INDEX", "https://pypi.org/simple/")
317
- # ^ Private API for testing purposes only
318
- self.index_url = self.index_url or default_index
319
- self.shadow_path = self.all_site_dirs[:]
320
- for path_item in self.install_dir, normalize_path(self.script_dir):
321
- if path_item not in self.shadow_path:
322
- self.shadow_path.insert(0, path_item)
323
-
324
- if self.allow_hosts is not None:
325
- hosts = [s.strip() for s in self.allow_hosts.split(',')]
326
- else:
327
- hosts = ['*']
328
- if self.package_index is None:
329
- self.package_index = self.create_index(
330
- self.index_url,
331
- search_path=self.shadow_path,
332
- hosts=hosts,
333
- )
334
- self.local_index = Environment(self.shadow_path + sys.path)
335
-
336
- if self.find_links is not None:
337
- if isinstance(self.find_links, str):
338
- self.find_links = self.find_links.split()
339
- else:
340
- self.find_links = []
341
- if self.local_snapshots_ok:
342
- self.package_index.scan_egg_links(self.shadow_path + sys.path)
343
- if not self.no_find_links:
344
- self.package_index.add_find_links(self.find_links)
345
- self.set_undefined_options('install_lib', ('optimize', 'optimize'))
346
- self.optimize = self._validate_optimize(self.optimize)
347
-
348
- if self.editable and not self.build_directory:
349
- raise DistutilsArgError(
350
- "Must specify a build directory (-b) when using --editable"
351
- )
352
- if not self.args:
353
- raise DistutilsArgError(
354
- "No urls, filenames, or requirements specified (see --help)"
355
- )
356
-
357
- self.outputs: list[str] = []
358
-
359
- @staticmethod
360
- def _process_site_dirs(site_dirs):
361
- if site_dirs is None:
362
- return
363
-
364
- normpath = map(normalize_path, sys.path)
365
- site_dirs = [os.path.expanduser(s.strip()) for s in site_dirs.split(',')]
366
- for d in site_dirs:
367
- if not os.path.isdir(d):
368
- log.warn("%s (in --site-dirs) does not exist", d)
369
- elif normalize_path(d) not in normpath:
370
- raise DistutilsOptionError(d + " (in --site-dirs) is not on sys.path")
371
- else:
372
- yield normalize_path(d)
373
-
374
- @staticmethod
375
- def _validate_optimize(value):
376
- try:
377
- value = int(value)
378
- if value not in range(3):
379
- raise ValueError
380
- except ValueError as e:
381
- raise DistutilsOptionError("--optimize must be 0, 1, or 2") from e
382
-
383
- return value
384
-
385
- def _fix_install_dir_for_user_site(self):
386
- """
387
- Fix the install_dir if "--user" was used.
388
- """
389
- if not self.user:
390
- return
391
-
392
- self.create_home_path()
393
- if self.install_userbase is None:
394
- msg = "User base directory is not specified"
395
- raise DistutilsPlatformError(msg)
396
- self.install_base = self.install_platbase = self.install_userbase
397
- scheme_name = f'{os.name}_user'
398
- self.select_scheme(scheme_name)
399
-
400
- def _expand_attrs(self, attrs):
401
- for attr in attrs:
402
- val = getattr(self, attr)
403
- if val is not None:
404
- if os.name == 'posix' or os.name == 'nt':
405
- val = os.path.expanduser(val)
406
- val = subst_vars(val, self.config_vars)
407
- setattr(self, attr, val)
408
-
409
- def expand_basedirs(self) -> None:
410
- """Calls `os.path.expanduser` on install_base, install_platbase and
411
- root."""
412
- self._expand_attrs(['install_base', 'install_platbase', 'root'])
413
-
414
- def expand_dirs(self) -> None:
415
- """Calls `os.path.expanduser` on install dirs."""
416
- dirs = [
417
- 'install_purelib',
418
- 'install_platlib',
419
- 'install_lib',
420
- 'install_headers',
421
- 'install_scripts',
422
- 'install_data',
423
- ]
424
- self._expand_attrs(dirs)
425
-
426
- def run(self, show_deprecation: bool = True) -> None:
427
- if show_deprecation:
428
- self.announce(
429
- "WARNING: The easy_install command is deprecated "
430
- "and will be removed in a future version.",
431
- log.WARN,
432
- )
433
- if self.verbose != self.distribution.verbose:
434
- log.set_verbosity(self.verbose)
435
- try:
436
- for spec in self.args:
437
- self.easy_install(spec, not self.no_deps)
438
- if self.record:
439
- outputs = self.outputs
440
- if self.root: # strip any package prefix
441
- root_len = len(self.root)
442
- for counter in range(len(outputs)):
443
- outputs[counter] = outputs[counter][root_len:]
444
- from distutils import file_util
445
-
446
- self.execute(
447
- file_util.write_file,
448
- (self.record, outputs),
449
- f"writing list of installed files to '{self.record}'",
450
- )
451
- self.warn_deprecated_options()
452
- finally:
453
- log.set_verbosity(self.distribution.verbose)
454
-
455
- def pseudo_tempname(self):
456
- """Return a pseudo-tempname base in the install directory.
457
- This code is intentionally naive; if a malicious party can write to
458
- the target directory you're already in deep doodoo.
459
- """
460
- try:
461
- pid = os.getpid()
462
- except Exception:
463
- pid = random.randint(0, sys.maxsize)
464
- return os.path.join(self.install_dir, f"test-easy-install-{pid}")
465
-
466
- def warn_deprecated_options(self) -> None:
467
- pass
468
-
469
- def check_site_dir(self) -> None: # is too complex (12) # FIXME
470
- """Verify that self.install_dir is .pth-capable dir, if needed"""
471
-
472
- instdir = normalize_path(self.install_dir)
473
- pth_file = os.path.join(instdir, 'easy-install.pth')
474
-
475
- if not os.path.exists(instdir):
476
- try:
477
- os.makedirs(instdir)
478
- except OSError:
479
- self.cant_write_to_target()
480
-
481
- # Is it a configured, PYTHONPATH, implicit, or explicit site dir?
482
- is_site_dir = instdir in self.all_site_dirs
483
-
484
- if not is_site_dir and not self.multi_version:
485
- # No? Then directly test whether it does .pth file processing
486
- is_site_dir = self.check_pth_processing()
487
- else:
488
- # make sure we can write to target dir
489
- testfile = self.pseudo_tempname() + '.write-test'
490
- test_exists = os.path.exists(testfile)
491
- try:
492
- if test_exists:
493
- os.unlink(testfile)
494
- open(testfile, 'wb').close()
495
- os.unlink(testfile)
496
- except OSError:
497
- self.cant_write_to_target()
498
-
499
- if not is_site_dir and not self.multi_version:
500
- # Can't install non-multi to non-site dir with easy_install
501
- pythonpath = os.environ.get('PYTHONPATH', '')
502
- log.warn(self.__no_default_msg, self.install_dir, pythonpath)
503
-
504
- if is_site_dir:
505
- if self.pth_file is None:
506
- self.pth_file = PthDistributions(pth_file, self.all_site_dirs)
507
- else:
508
- self.pth_file = None
509
-
510
- if self.multi_version and not os.path.exists(pth_file):
511
- self.pth_file = None # don't create a .pth file
512
- self.install_dir = instdir
513
-
514
- __cant_write_msg = textwrap.dedent(
515
- """
516
- can't create or remove files in install directory
517
-
518
- The following error occurred while trying to add or remove files in the
519
- installation directory:
520
-
521
- %s
522
-
523
- The installation directory you specified (via --install-dir, --prefix, or
524
- the distutils default setting) was:
525
-
526
- %s
527
- """
528
- ).lstrip()
529
-
530
- __not_exists_id = textwrap.dedent(
531
- """
532
- This directory does not currently exist. Please create it and try again, or
533
- choose a different installation directory (using the -d or --install-dir
534
- option).
535
- """
536
- ).lstrip()
537
-
538
- __access_msg = textwrap.dedent(
539
- """
540
- Perhaps your account does not have write access to this directory? If the
541
- installation directory is a system-owned directory, you may need to sign in
542
- as the administrator or "root" account. If you do not have administrative
543
- access to this machine, you may wish to choose a different installation
544
- directory, preferably one that is listed in your PYTHONPATH environment
545
- variable.
546
-
547
- For information on other options, you may wish to consult the
548
- documentation at:
549
-
550
- https://setuptools.pypa.io/en/latest/deprecated/easy_install.html
551
-
552
- Please make the appropriate changes for your system and try again.
553
- """
554
- ).lstrip()
555
-
556
- def cant_write_to_target(self) -> NoReturn:
557
- msg = self.__cant_write_msg % (
558
- sys.exc_info()[1],
559
- self.install_dir,
560
- )
561
-
562
- if not os.path.exists(self.install_dir):
563
- msg += '\n' + self.__not_exists_id
564
- else:
565
- msg += '\n' + self.__access_msg
566
- raise DistutilsError(msg)
567
-
568
- def check_pth_processing(self): # noqa: C901
569
- """Empirically verify whether .pth files are supported in inst. dir"""
570
- instdir = self.install_dir
571
- log.info("Checking .pth file support in %s", instdir)
572
- pth_file = self.pseudo_tempname() + ".pth"
573
- ok_file = pth_file + '.ok'
574
- ok_exists = os.path.exists(ok_file)
575
- tmpl = (
576
- _one_liner(
577
- """
578
- import os
579
- f = open({ok_file!r}, 'w', encoding="utf-8")
580
- f.write('OK')
581
- f.close()
582
- """
583
- )
584
- + '\n'
585
- )
586
- try:
587
- if ok_exists:
588
- os.unlink(ok_file)
589
- dirname = os.path.dirname(ok_file)
590
- os.makedirs(dirname, exist_ok=True)
591
- f = open(pth_file, 'w', encoding=py312.PTH_ENCODING)
592
- # ^-- Python<3.13 require encoding="locale" instead of "utf-8",
593
- # see python/cpython#77102.
594
- except OSError:
595
- self.cant_write_to_target()
596
- else:
597
- try:
598
- f.write(tmpl.format(**locals()))
599
- f.close()
600
- f = None
601
- executable = sys.executable
602
- if os.name == 'nt':
603
- dirname, basename = os.path.split(executable)
604
- alt = os.path.join(dirname, 'pythonw.exe')
605
- use_alt = basename.lower() == 'python.exe' and os.path.exists(alt)
606
- if use_alt:
607
- # use pythonw.exe to avoid opening a console window
608
- executable = alt
609
-
610
- from distutils.spawn import spawn
611
-
612
- spawn([executable, '-E', '-c', 'pass'], 0)
613
-
614
- if os.path.exists(ok_file):
615
- log.info("TEST PASSED: %s appears to support .pth files", instdir)
616
- return True
617
- finally:
618
- if f:
619
- f.close()
620
- if os.path.exists(ok_file):
621
- os.unlink(ok_file)
622
- if os.path.exists(pth_file):
623
- os.unlink(pth_file)
624
- if not self.multi_version:
625
- log.warn("TEST FAILED: %s does NOT support .pth files", instdir)
626
- return False
627
-
628
- def install_egg_scripts(self, dist) -> None:
629
- """Write all the scripts for `dist`, unless scripts are excluded"""
630
- if not self.exclude_scripts and dist.metadata_isdir('scripts'):
631
- for script_name in dist.metadata_listdir('scripts'):
632
- if dist.metadata_isdir('scripts/' + script_name):
633
- # The "script" is a directory, likely a Python 3
634
- # __pycache__ directory, so skip it.
635
- continue
636
- self.install_script(
637
- dist, script_name, dist.get_metadata('scripts/' + script_name)
638
- )
639
- self.install_wrapper_scripts(dist)
640
-
641
- def add_output(self, path) -> None:
642
- if os.path.isdir(path):
643
- for base, dirs, files in os.walk(path):
644
- for filename in files:
645
- self.outputs.append(os.path.join(base, filename))
646
- else:
647
- self.outputs.append(path)
648
-
649
- def not_editable(self, spec) -> None:
650
- if self.editable:
651
- raise DistutilsArgError(
652
- f"Invalid argument {spec!r}: you can't use filenames or URLs "
653
- "with --editable (except via the --find-links option)."
654
- )
655
-
656
- def check_editable(self, spec) -> None:
657
- if not self.editable:
658
- return
659
-
660
- if os.path.exists(os.path.join(self.build_directory, spec.key)):
661
- raise DistutilsArgError(
662
- f"{spec.key!r} already exists in {self.build_directory}; can't do a checkout there"
663
- )
664
-
665
- @contextlib.contextmanager
666
- def _tmpdir(self):
667
- tmpdir = tempfile.mkdtemp(prefix="easy_install-")
668
- try:
669
- # cast to str as workaround for #709 and #710 and #712
670
- yield str(tmpdir)
671
- finally:
672
- os.path.exists(tmpdir) and _rmtree(tmpdir)
673
-
674
- def easy_install(self, spec, deps: bool = False) -> Distribution | None:
675
- with self._tmpdir() as tmpdir:
676
- if not isinstance(spec, Requirement):
677
- if URL_SCHEME(spec):
678
- # It's a url, download it to tmpdir and process
679
- self.not_editable(spec)
680
- dl = self.package_index.download(spec, tmpdir)
681
- return self.install_item(None, dl, tmpdir, deps, True)
682
-
683
- elif os.path.exists(spec):
684
- # Existing file or directory, just process it directly
685
- self.not_editable(spec)
686
- return self.install_item(None, spec, tmpdir, deps, True)
687
- else:
688
- spec = parse_requirement_arg(spec)
689
-
690
- self.check_editable(spec)
691
- dist = self.package_index.fetch_distribution(
692
- spec,
693
- tmpdir,
694
- self.upgrade,
695
- self.editable,
696
- not self.always_copy,
697
- self.local_index,
698
- )
699
- if dist is None:
700
- msg = f"Could not find suitable distribution for {spec!r}"
701
- if self.always_copy:
702
- msg += " (--always-copy skips system and development eggs)"
703
- raise DistutilsError(msg)
704
- elif dist.precedence == DEVELOP_DIST:
705
- # .egg-info dists don't need installing, just process deps
706
- self.process_distribution(spec, dist, deps, "Using")
707
- return dist
708
- else:
709
- return self.install_item(spec, dist.location, tmpdir, deps)
710
-
711
- def install_item(
712
- self, spec, download, tmpdir, deps, install_needed: bool = False
713
- ) -> Distribution | None:
714
- # Installation is also needed if file in tmpdir or is not an egg
715
- install_needed = install_needed or bool(self.always_copy)
716
- install_needed = install_needed or os.path.dirname(download) == tmpdir
717
- install_needed = install_needed or not download.endswith('.egg')
718
- install_needed = install_needed or (
719
- self.always_copy_from is not None
720
- and os.path.dirname(normalize_path(download))
721
- == normalize_path(self.always_copy_from)
722
- )
723
-
724
- if spec and not install_needed:
725
- # at this point, we know it's a local .egg, we just don't know if
726
- # it's already installed.
727
- for dist in self.local_index[spec.project_name]:
728
- if dist.location == download:
729
- break
730
- else:
731
- install_needed = True # it's not in the local index
732
-
733
- log.info("Processing %s", os.path.basename(download))
734
-
735
- if install_needed:
736
- dists = self.install_eggs(spec, download, tmpdir)
737
- for dist in dists:
738
- self.process_distribution(spec, dist, deps)
739
- else:
740
- dists = [self.egg_distribution(download)]
741
- self.process_distribution(spec, dists[0], deps, "Using")
742
-
743
- if spec is not None:
744
- for dist in dists:
745
- if dist in spec:
746
- return dist
747
- return None
748
-
749
- def select_scheme(self, name):
750
- try:
751
- install._select_scheme(self, name)
752
- except AttributeError:
753
- # stdlib distutils
754
- install.install.select_scheme(self, name.replace('posix', 'unix'))
755
-
756
- # FIXME: 'easy_install.process_distribution' is too complex (12)
757
- def process_distribution( # noqa: C901
758
- self,
759
- requirement,
760
- dist,
761
- deps: bool = True,
762
- *info,
763
- ) -> None:
764
- self.update_pth(dist)
765
- self.package_index.add(dist)
766
- if dist in self.local_index[dist.key]:
767
- self.local_index.remove(dist)
768
- self.local_index.add(dist)
769
- self.install_egg_scripts(dist)
770
- self.installed_projects[dist.key] = dist
771
- log.info(self.installation_report(requirement, dist, *info))
772
- if dist.has_metadata('dependency_links.txt') and not self.no_find_links:
773
- self.package_index.add_find_links(
774
- dist.get_metadata_lines('dependency_links.txt')
775
- )
776
- if not deps and not self.always_copy:
777
- return
778
- elif requirement is not None and dist.key != requirement.key:
779
- log.warn("Skipping dependencies for %s", dist)
780
- return # XXX this is not the distribution we were looking for
781
- elif requirement is None or dist not in requirement:
782
- # if we wound up with a different version, resolve what we've got
783
- distreq = dist.as_requirement()
784
- requirement = Requirement(str(distreq))
785
- log.info("Processing dependencies for %s", requirement)
786
- try:
787
- distros = WorkingSet([]).resolve(
788
- [requirement], self.local_index, self.easy_install
789
- )
790
- except DistributionNotFound as e:
791
- raise DistutilsError(str(e)) from e
792
- except VersionConflict as e:
793
- raise DistutilsError(e.report()) from e
794
- if self.always_copy or self.always_copy_from:
795
- # Force all the relevant distros to be copied or activated
796
- for dist in distros:
797
- if dist.key not in self.installed_projects:
798
- self.easy_install(dist.as_requirement())
799
- log.info("Finished processing dependencies for %s", requirement)
800
-
801
- def should_unzip(self, dist) -> bool:
802
- if self.zip_ok is not None:
803
- return not self.zip_ok
804
- if dist.has_metadata('not-zip-safe'):
805
- return True
806
- if not dist.has_metadata('zip-safe'):
807
- return True
808
- return False
809
-
810
- def maybe_move(self, spec, dist_filename, setup_base):
811
- dst = os.path.join(self.build_directory, spec.key)
812
- if os.path.exists(dst):
813
- msg = "%r already exists in %s; build directory %s will not be kept"
814
- log.warn(msg, spec.key, self.build_directory, setup_base)
815
- return setup_base
816
- if os.path.isdir(dist_filename):
817
- setup_base = dist_filename
818
- else:
819
- if os.path.dirname(dist_filename) == setup_base:
820
- os.unlink(dist_filename) # get it out of the tmp dir
821
- contents = os.listdir(setup_base)
822
- if len(contents) == 1:
823
- dist_filename = os.path.join(setup_base, contents[0])
824
- if os.path.isdir(dist_filename):
825
- # if the only thing there is a directory, move it instead
826
- setup_base = dist_filename
827
- ensure_directory(dst)
828
- shutil.move(setup_base, dst)
829
- return dst
830
-
831
- def install_wrapper_scripts(self, dist) -> None:
832
- if self.exclude_scripts:
833
- return
834
- for args in ScriptWriter.best().get_args(dist):
835
- self.write_script(*args)
836
-
837
- def install_script(self, dist, script_name, script_text, dev_path=None) -> None:
838
- """Generate a legacy script wrapper and install it"""
839
- spec = str(dist.as_requirement())
840
- is_script = is_python_script(script_text, script_name)
841
-
842
- if is_script:
843
- body = self._load_template(dev_path) % locals()
844
- script_text = ScriptWriter.get_header(script_text) + body
845
- self.write_script(script_name, _to_bytes(script_text), 'b')
846
-
847
- @staticmethod
848
- def _load_template(dev_path):
849
- """
850
- There are a couple of template scripts in the package. This
851
- function loads one of them and prepares it for use.
852
- """
853
- # See https://github.com/pypa/setuptools/issues/134 for info
854
- # on script file naming and downstream issues with SVR4
855
- name = 'script.tmpl'
856
- if dev_path:
857
- name = name.replace('.tmpl', ' (dev).tmpl')
858
-
859
- raw_bytes = resource_string('setuptools', name)
860
- return raw_bytes.decode('utf-8')
861
-
862
- def write_script(self, script_name, contents, mode: str = "t", blockers=()) -> None:
863
- """Write an executable file to the scripts directory"""
864
- self.delete_blockers( # clean up old .py/.pyw w/o a script
865
- [os.path.join(self.script_dir, x) for x in blockers]
866
- )
867
- log.info("Installing %s script to %s", script_name, self.script_dir)
868
- target = os.path.join(self.script_dir, script_name)
869
- self.add_output(target)
870
-
871
- if self.dry_run:
872
- return
873
-
874
- mask = current_umask()
875
- ensure_directory(target)
876
- if os.path.exists(target):
877
- os.unlink(target)
878
-
879
- encoding = None if "b" in mode else "utf-8"
880
- with open(target, "w" + mode, encoding=encoding) as f:
881
- f.write(contents)
882
- chmod(target, 0o777 - mask)
883
-
884
- def install_eggs(self, spec, dist_filename, tmpdir) -> list[Distribution]:
885
- # .egg dirs or files are already built, so just return them
886
- installer_map = {
887
- '.egg': self.install_egg,
888
- '.exe': self.install_exe,
889
- '.whl': self.install_wheel,
890
- }
891
- try:
892
- install_dist = installer_map[dist_filename.lower()[-4:]]
893
- except KeyError:
894
- pass
895
- else:
896
- return [install_dist(dist_filename, tmpdir)]
897
-
898
- # Anything else, try to extract and build
899
- setup_base = tmpdir
900
- if os.path.isfile(dist_filename) and not dist_filename.endswith('.py'):
901
- unpack_archive(dist_filename, tmpdir, self.unpack_progress)
902
- elif os.path.isdir(dist_filename):
903
- setup_base = os.path.abspath(dist_filename)
904
-
905
- if (
906
- setup_base.startswith(tmpdir) # something we downloaded
907
- and self.build_directory
908
- and spec is not None
909
- ):
910
- setup_base = self.maybe_move(spec, dist_filename, setup_base)
911
-
912
- # Find the setup.py file
913
- setup_script = os.path.join(setup_base, 'setup.py')
914
-
915
- if not os.path.exists(setup_script):
916
- setups = glob(os.path.join(setup_base, '*', 'setup.py'))
917
- if not setups:
918
- raise DistutilsError(
919
- f"Couldn't find a setup script in {os.path.abspath(dist_filename)}"
920
- )
921
- if len(setups) > 1:
922
- raise DistutilsError(
923
- f"Multiple setup scripts in {os.path.abspath(dist_filename)}"
924
- )
925
- setup_script = setups[0]
926
-
927
- # Now run it, and return the result
928
- if self.editable:
929
- log.info(self.report_editable(spec, setup_script))
930
- return []
931
- else:
932
- return self.build_and_install(setup_script, setup_base)
933
-
934
- def egg_distribution(self, egg_path):
935
- if os.path.isdir(egg_path):
936
- metadata = PathMetadata(egg_path, os.path.join(egg_path, 'EGG-INFO'))
937
- else:
938
- metadata = EggMetadata(zipimport.zipimporter(egg_path))
939
- return Distribution.from_filename(egg_path, metadata=metadata)
940
-
941
- # FIXME: 'easy_install.install_egg' is too complex (11)
942
- def install_egg(self, egg_path, tmpdir):
943
- destination = os.path.join(
944
- self.install_dir,
945
- os.path.basename(egg_path),
946
- )
947
- destination = os.path.abspath(destination)
948
- if not self.dry_run:
949
- ensure_directory(destination)
950
-
951
- dist = self.egg_distribution(egg_path)
952
- if not (
953
- os.path.exists(destination) and os.path.samefile(egg_path, destination)
954
- ):
955
- if os.path.isdir(destination) and not os.path.islink(destination):
956
- dir_util.remove_tree(destination, dry_run=self.dry_run)
957
- elif os.path.exists(destination):
958
- self.execute(
959
- os.unlink,
960
- (destination,),
961
- "Removing " + destination,
962
- )
963
- try:
964
- new_dist_is_zipped = False
965
- if os.path.isdir(egg_path):
966
- if egg_path.startswith(tmpdir):
967
- f, m = shutil.move, "Moving"
968
- else:
969
- f, m = shutil.copytree, "Copying"
970
- elif self.should_unzip(dist):
971
- self.mkpath(destination)
972
- f, m = self.unpack_and_compile, "Extracting"
973
- else:
974
- new_dist_is_zipped = True
975
- if egg_path.startswith(tmpdir):
976
- f, m = shutil.move, "Moving"
977
- else:
978
- f, m = shutil.copy2, "Copying"
979
- self.execute(
980
- f,
981
- (egg_path, destination),
982
- (m + " %s to %s")
983
- % (os.path.basename(egg_path), os.path.dirname(destination)),
984
- )
985
- update_dist_caches(
986
- destination,
987
- fix_zipimporter_caches=new_dist_is_zipped,
988
- )
989
- except Exception:
990
- update_dist_caches(destination, fix_zipimporter_caches=False)
991
- raise
992
-
993
- self.add_output(destination)
994
- return self.egg_distribution(destination)
995
-
996
- def install_exe(self, dist_filename, tmpdir):
997
- # See if it's valid, get data
998
- cfg = extract_wininst_cfg(dist_filename)
999
- if cfg is None:
1000
- raise DistutilsError(
1001
- f"{dist_filename} is not a valid distutils Windows .exe"
1002
- )
1003
- # Create a dummy distribution object until we build the real distro
1004
- dist = Distribution(
1005
- None,
1006
- project_name=cfg.get('metadata', 'name'),
1007
- version=cfg.get('metadata', 'version'),
1008
- platform=get_platform(),
1009
- )
1010
-
1011
- # Convert the .exe to an unpacked egg
1012
- egg_path = os.path.join(tmpdir, dist.egg_name() + '.egg')
1013
- dist.location = egg_path
1014
- egg_tmp = egg_path + '.tmp'
1015
- _egg_info = os.path.join(egg_tmp, 'EGG-INFO')
1016
- pkg_inf = os.path.join(_egg_info, 'PKG-INFO')
1017
- ensure_directory(pkg_inf) # make sure EGG-INFO dir exists
1018
- dist._provider = PathMetadata(egg_tmp, _egg_info) # XXX
1019
- self.exe_to_egg(dist_filename, egg_tmp)
1020
-
1021
- # Write EGG-INFO/PKG-INFO
1022
- if not os.path.exists(pkg_inf):
1023
- with open(pkg_inf, 'w', encoding="utf-8") as f:
1024
- f.write('Metadata-Version: 1.0\n')
1025
- for k, v in cfg.items('metadata'):
1026
- if k != 'target_version':
1027
- k = k.replace('_', '-').title()
1028
- f.write(f'{k}: {v}\n')
1029
- script_dir = os.path.join(_egg_info, 'scripts')
1030
- # delete entry-point scripts to avoid duping
1031
- self.delete_blockers([
1032
- os.path.join(script_dir, args[0]) for args in ScriptWriter.get_args(dist)
1033
- ])
1034
- # Build .egg file from tmpdir
1035
- bdist_egg.make_zipfile(
1036
- egg_path,
1037
- egg_tmp,
1038
- verbose=self.verbose,
1039
- dry_run=self.dry_run,
1040
- )
1041
- # install the .egg
1042
- return self.install_egg(egg_path, tmpdir)
1043
-
1044
- # FIXME: 'easy_install.exe_to_egg' is too complex (12)
1045
- def exe_to_egg(self, dist_filename, egg_tmp) -> None: # noqa: C901
1046
- """Extract a bdist_wininst to the directories an egg would use"""
1047
- # Check for .pth file and set up prefix translations
1048
- prefixes = get_exe_prefixes(dist_filename)
1049
- to_compile = []
1050
- native_libs = []
1051
- top_level = set()
1052
-
1053
- def process(src, dst):
1054
- s = src.lower()
1055
- for old, new in prefixes:
1056
- if s.startswith(old):
1057
- src = new + src[len(old) :]
1058
- parts = src.split('/')
1059
- dst = os.path.join(egg_tmp, *parts)
1060
- dl = dst.lower()
1061
- if dl.endswith('.pyd') or dl.endswith('.dll'):
1062
- parts[-1] = bdist_egg.strip_module(parts[-1])
1063
- top_level.add([os.path.splitext(parts[0])[0]])
1064
- native_libs.append(src)
1065
- elif dl.endswith('.py') and old != 'SCRIPTS/':
1066
- top_level.add([os.path.splitext(parts[0])[0]])
1067
- to_compile.append(dst)
1068
- return dst
1069
- if not src.endswith('.pth'):
1070
- log.warn("WARNING: can't process %s", src)
1071
- return None
1072
-
1073
- # extract, tracking .pyd/.dll->native_libs and .py -> to_compile
1074
- unpack_archive(dist_filename, egg_tmp, process)
1075
- stubs = []
1076
- for res in native_libs:
1077
- if res.lower().endswith('.pyd'): # create stubs for .pyd's
1078
- parts = res.split('/')
1079
- resource = parts[-1]
1080
- parts[-1] = bdist_egg.strip_module(parts[-1]) + '.py'
1081
- pyfile = os.path.join(egg_tmp, *parts)
1082
- to_compile.append(pyfile)
1083
- stubs.append(pyfile)
1084
- bdist_egg.write_stub(resource, pyfile)
1085
- self.byte_compile(to_compile) # compile .py's
1086
- bdist_egg.write_safety_flag(
1087
- os.path.join(egg_tmp, 'EGG-INFO'), bdist_egg.analyze_egg(egg_tmp, stubs)
1088
- ) # write zip-safety flag
1089
-
1090
- for name in 'top_level', 'native_libs':
1091
- if locals()[name]:
1092
- txt = os.path.join(egg_tmp, 'EGG-INFO', name + '.txt')
1093
- if not os.path.exists(txt):
1094
- with open(txt, 'w', encoding="utf-8") as f:
1095
- f.write('\n'.join(locals()[name]) + '\n')
1096
-
1097
- def install_wheel(self, wheel_path, tmpdir):
1098
- wheel = Wheel(wheel_path)
1099
- assert wheel.is_compatible()
1100
- destination = os.path.join(self.install_dir, wheel.egg_name())
1101
- destination = os.path.abspath(destination)
1102
- if not self.dry_run:
1103
- ensure_directory(destination)
1104
- if os.path.isdir(destination) and not os.path.islink(destination):
1105
- dir_util.remove_tree(destination, dry_run=self.dry_run)
1106
- elif os.path.exists(destination):
1107
- self.execute(
1108
- os.unlink,
1109
- (destination,),
1110
- "Removing " + destination,
1111
- )
1112
- try:
1113
- self.execute(
1114
- wheel.install_as_egg,
1115
- (destination,),
1116
- (
1117
- f"Installing {os.path.basename(wheel_path)} to {os.path.dirname(destination)}"
1118
- ),
1119
- )
1120
- finally:
1121
- update_dist_caches(destination, fix_zipimporter_caches=False)
1122
- self.add_output(destination)
1123
- return self.egg_distribution(destination)
1124
-
1125
- __mv_warning = textwrap.dedent(
1126
- """
1127
- Because this distribution was installed --multi-version, before you can
1128
- import modules from this package in an application, you will need to
1129
- 'import pkg_resources' and then use a 'require()' call similar to one of
1130
- these examples, in order to select the desired version:
1131
-
1132
- pkg_resources.require("%(name)s") # latest installed version
1133
- pkg_resources.require("%(name)s==%(version)s") # this exact version
1134
- pkg_resources.require("%(name)s>=%(version)s") # this version or higher
1135
- """
1136
- ).lstrip()
1137
-
1138
- __id_warning = textwrap.dedent(
1139
- """
1140
- Note also that the installation directory must be on sys.path at runtime for
1141
- this to work. (e.g. by being the application's script directory, by being on
1142
- PYTHONPATH, or by being added to sys.path by your code.)
1143
- """
22
+ name,
1144
23
  )
1145
-
1146
- def installation_report(self, req, dist, what: str = "Installed") -> str:
1147
- """Helpful installation message for display to package users"""
1148
- msg = "\n%(what)s %(eggloc)s%(extras)s"
1149
- if self.multi_version and not self.no_report:
1150
- msg += '\n' + self.__mv_warning
1151
- if self.install_dir not in map(normalize_path, sys.path):
1152
- msg += '\n' + self.__id_warning
1153
-
1154
- eggloc = dist.location
1155
- name = dist.project_name
1156
- version = dist.version
1157
- extras = '' # TODO: self.report_extras(req, dist)
1158
- return msg % locals()
1159
-
1160
- __editable_msg = textwrap.dedent(
1161
- """
1162
- Extracted editable version of %(spec)s to %(dirname)s
1163
-
1164
- If it uses setuptools in its setup script, you can activate it in
1165
- "development" mode by going to that directory and running::
1166
-
1167
- %(python)s setup.py develop
1168
-
1169
- See the setuptools documentation for the "develop" command for more info.
1170
- """
1171
- ).lstrip()
1172
-
1173
- def report_editable(self, spec, setup_script):
1174
- dirname = os.path.dirname(setup_script)
1175
- python = sys.executable
1176
- return '\n' + self.__editable_msg % locals()
1177
-
1178
- def run_setup(self, setup_script, setup_base, args) -> None:
1179
- sys.modules.setdefault('distutils.command.bdist_egg', bdist_egg)
1180
- sys.modules.setdefault('distutils.command.egg_info', egg_info)
1181
-
1182
- args = list(args)
1183
- if self.verbose > 2:
1184
- v = 'v' * (self.verbose - 1)
1185
- args.insert(0, '-' + v)
1186
- elif self.verbose < 2:
1187
- args.insert(0, '-q')
1188
- if self.dry_run:
1189
- args.insert(0, '-n')
1190
- log.info("Running %s %s", setup_script[len(setup_base) + 1 :], ' '.join(args))
1191
- try:
1192
- run_setup(setup_script, args)
1193
- except SystemExit as v:
1194
- raise DistutilsError(f"Setup script exited with {v.args[0]}") from v
1195
-
1196
- def build_and_install(self, setup_script, setup_base):
1197
- args = ['bdist_egg', '--dist-dir']
1198
-
1199
- dist_dir = tempfile.mkdtemp(
1200
- prefix='egg-dist-tmp-', dir=os.path.dirname(setup_script)
1201
- )
1202
- try:
1203
- self._set_fetcher_options(os.path.dirname(setup_script))
1204
- args.append(dist_dir)
1205
-
1206
- self.run_setup(setup_script, setup_base, args)
1207
- all_eggs = Environment([dist_dir])
1208
- eggs = [
1209
- self.install_egg(dist.location, setup_base)
1210
- for key in all_eggs
1211
- for dist in all_eggs[key]
1212
- ]
1213
- if not eggs and not self.dry_run:
1214
- log.warn("No eggs found in %s (setup script problem?)", dist_dir)
1215
- return eggs
1216
- finally:
1217
- _rmtree(dist_dir)
1218
- log.set_verbosity(self.verbose) # restore our log verbosity
1219
-
1220
- def _set_fetcher_options(self, base):
1221
- """
1222
- When easy_install is about to run bdist_egg on a source dist, that
1223
- source dist might have 'setup_requires' directives, requiring
1224
- additional fetching. Ensure the fetcher options given to easy_install
1225
- are available to that command as well.
1226
- """
1227
- # find the fetch options from easy_install and write them out
1228
- # to the setup.cfg file.
1229
- ei_opts = self.distribution.get_option_dict('easy_install').copy()
1230
- fetch_directives = (
1231
- 'find_links',
1232
- 'site_dirs',
1233
- 'index_url',
1234
- 'optimize',
1235
- 'allow_hosts',
1236
- )
1237
- fetch_options = {}
1238
- for key, val in ei_opts.items():
1239
- if key not in fetch_directives:
1240
- continue
1241
- fetch_options[key] = val[1]
1242
- # create a settings dictionary suitable for `edit_config`
1243
- settings = dict(easy_install=fetch_options)
1244
- cfg_filename = os.path.join(base, 'setup.cfg')
1245
- setopt.edit_config(cfg_filename, settings)
1246
-
1247
- def update_pth(self, dist) -> None: # noqa: C901 # is too complex (11) # FIXME
1248
- if self.pth_file is None:
1249
- return
1250
-
1251
- for d in self.pth_file[dist.key]: # drop old entries
1252
- if not self.multi_version and d.location == dist.location:
1253
- continue
1254
-
1255
- log.info("Removing %s from easy-install.pth file", d)
1256
- self.pth_file.remove(d)
1257
- if d.location in self.shadow_path:
1258
- self.shadow_path.remove(d.location)
1259
-
1260
- if not self.multi_version:
1261
- if dist.location in self.pth_file.paths:
1262
- log.info(
1263
- "%s is already the active version in easy-install.pth",
1264
- dist,
1265
- )
1266
- else:
1267
- log.info("Adding %s to easy-install.pth file", dist)
1268
- self.pth_file.add(dist) # add new entry
1269
- if dist.location not in self.shadow_path:
1270
- self.shadow_path.append(dist.location)
1271
-
1272
- if self.dry_run:
1273
- return
1274
-
1275
- self.pth_file.save()
1276
-
1277
- if dist.key != 'setuptools':
1278
- return
1279
-
1280
- # Ensure that setuptools itself never becomes unavailable!
1281
- # XXX should this check for latest version?
1282
- filename = os.path.join(self.install_dir, 'setuptools.pth')
1283
- if os.path.islink(filename):
1284
- os.unlink(filename)
1285
-
1286
- with open(filename, 'wt', encoding=py312.PTH_ENCODING) as f:
1287
- # ^-- Python<3.13 require encoding="locale" instead of "utf-8",
1288
- # see python/cpython#77102.
1289
- f.write(self.pth_file.make_relative(dist.location) + '\n')
1290
-
1291
- def unpack_progress(self, src, dst):
1292
- # Progress filter for unpacking
1293
- log.debug("Unpacking %s to %s", src, dst)
1294
- return dst # only unpack-and-compile skips files for dry run
1295
-
1296
- def unpack_and_compile(self, egg_path, destination) -> None:
1297
- to_compile = []
1298
- to_chmod = []
1299
-
1300
- def pf(src, dst):
1301
- if dst.endswith('.py') and not src.startswith('EGG-INFO/'):
1302
- to_compile.append(dst)
1303
- elif dst.endswith('.dll') or dst.endswith('.so'):
1304
- to_chmod.append(dst)
1305
- self.unpack_progress(src, dst)
1306
- return not self.dry_run and dst or None
1307
-
1308
- unpack_archive(egg_path, destination, pf)
1309
- self.byte_compile(to_compile)
1310
- if not self.dry_run:
1311
- for f in to_chmod:
1312
- mode = ((os.stat(f)[stat.ST_MODE]) | 0o555) & 0o7755
1313
- chmod(f, mode)
1314
-
1315
- def byte_compile(self, to_compile) -> None:
1316
- if sys.dont_write_bytecode:
1317
- return
1318
-
1319
- from distutils.util import byte_compile
1320
-
1321
- try:
1322
- # try to make the byte compile messages quieter
1323
- log.set_verbosity(self.verbose - 1)
1324
-
1325
- byte_compile(to_compile, optimize=0, force=True, dry_run=self.dry_run)
1326
- if self.optimize:
1327
- byte_compile(
1328
- to_compile,
1329
- optimize=self.optimize,
1330
- force=True,
1331
- dry_run=self.dry_run,
1332
- )
1333
- finally:
1334
- log.set_verbosity(self.verbose) # restore original verbosity
1335
-
1336
- __no_default_msg = textwrap.dedent(
1337
- """
1338
- bad install directory or PYTHONPATH
1339
-
1340
- You are attempting to install a package to a directory that is not
1341
- on PYTHONPATH and which Python does not read ".pth" files from. The
1342
- installation directory you specified (via --install-dir, --prefix, or
1343
- the distutils default setting) was:
1344
-
1345
- %s
1346
-
1347
- and your PYTHONPATH environment variable currently contains:
1348
-
1349
- %r
1350
-
1351
- Here are some of your options for correcting the problem:
1352
-
1353
- * You can choose a different installation directory, i.e., one that is
1354
- on PYTHONPATH or supports .pth files
1355
-
1356
- * You can add the installation directory to the PYTHONPATH environment
1357
- variable. (It must then also be on PYTHONPATH whenever you run
1358
- Python and want to use the package(s) you are installing.)
1359
-
1360
- * You can set up the installation directory to support ".pth" files by
1361
- using one of the approaches described here:
1362
-
1363
- https://setuptools.pypa.io/en/latest/deprecated/easy_install.html#custom-installation-locations
1364
-
1365
-
1366
- Please make the appropriate changes for your system and try again.
1367
- """
1368
- ).strip()
1369
-
1370
- def create_home_path(self) -> None:
1371
- """Create directories under ~."""
1372
- if not self.user:
1373
- return
1374
- home = convert_path(os.path.expanduser("~"))
1375
- for path in only_strs(self.config_vars.values()):
1376
- if path.startswith(home) and not os.path.isdir(path):
1377
- self.debug_print(f"os.makedirs('{path}', 0o700)")
1378
- os.makedirs(path, 0o700)
1379
-
1380
- INSTALL_SCHEMES = dict(
1381
- posix=dict(
1382
- install_dir='$base/lib/python$py_version_short/site-packages',
1383
- script_dir='$base/bin',
1384
- ),
1385
- )
1386
-
1387
- DEFAULT_SCHEME = dict(
1388
- install_dir='$base/Lib/site-packages',
1389
- script_dir='$base/Scripts',
1390
- )
1391
-
1392
- def _expand(self, *attrs):
1393
- config_vars = self.get_finalized_command('install').config_vars
1394
-
1395
- if self.prefix:
1396
- # Set default install_dir/scripts from --prefix
1397
- config_vars = dict(config_vars)
1398
- config_vars['base'] = self.prefix
1399
- scheme = self.INSTALL_SCHEMES.get(os.name, self.DEFAULT_SCHEME)
1400
- for attr, val in scheme.items():
1401
- if getattr(self, attr, None) is None:
1402
- setattr(self, attr, val)
1403
-
1404
- from distutils.util import subst_vars
1405
-
1406
- for attr in attrs:
1407
- val = getattr(self, attr)
1408
- if val is not None:
1409
- val = subst_vars(val, config_vars)
1410
- if os.name == 'posix':
1411
- val = os.path.expanduser(val)
1412
- setattr(self, attr, val)
1413
-
1414
-
1415
- def _pythonpath():
1416
- items = os.environ.get('PYTHONPATH', '').split(os.pathsep)
1417
- return filter(None, items)
1418
-
1419
-
1420
- def get_site_dirs():
1421
- """
1422
- Return a list of 'site' dirs
1423
- """
1424
-
1425
- sitedirs = []
1426
-
1427
- # start with PYTHONPATH
1428
- sitedirs.extend(_pythonpath())
1429
-
1430
- prefixes = [sys.prefix]
1431
- if sys.exec_prefix != sys.prefix:
1432
- prefixes.append(sys.exec_prefix)
1433
- for prefix in prefixes:
1434
- if not prefix:
1435
- continue
1436
-
1437
- if sys.platform in ('os2emx', 'riscos'):
1438
- sitedirs.append(os.path.join(prefix, "Lib", "site-packages"))
1439
- elif os.sep == '/':
1440
- sitedirs.extend([
1441
- os.path.join(
1442
- prefix,
1443
- "lib",
1444
- f"python{sys.version_info.major}.{sys.version_info.minor}",
1445
- "site-packages",
1446
- ),
1447
- os.path.join(prefix, "lib", "site-python"),
1448
- ])
1449
- else:
1450
- sitedirs.extend([
1451
- prefix,
1452
- os.path.join(prefix, "lib", "site-packages"),
1453
- ])
1454
- if sys.platform != 'darwin':
1455
- continue
1456
-
1457
- # for framework builds *only* we add the standard Apple
1458
- # locations. Currently only per-user, but /Library and
1459
- # /Network/Library could be added too
1460
- if 'Python.framework' not in prefix:
1461
- continue
1462
-
1463
- home = os.environ.get('HOME')
1464
- if not home:
1465
- continue
1466
-
1467
- home_sp = os.path.join(
1468
- home,
1469
- 'Library',
1470
- 'Python',
1471
- f'{sys.version_info.major}.{sys.version_info.minor}',
1472
- 'site-packages',
1473
- )
1474
- sitedirs.append(home_sp)
1475
- lib_paths = get_path('purelib'), get_path('platlib')
1476
-
1477
- sitedirs.extend(s for s in lib_paths if s not in sitedirs)
1478
-
1479
- if site.ENABLE_USER_SITE:
1480
- sitedirs.append(site.USER_SITE)
1481
-
1482
- with contextlib.suppress(AttributeError):
1483
- sitedirs.extend(site.getsitepackages())
1484
-
1485
- return list(map(normalize_path, sitedirs))
1486
-
1487
-
1488
- def expand_paths(inputs): # noqa: C901 # is too complex (11) # FIXME
1489
- """Yield sys.path directories that might contain "old-style" packages"""
1490
-
1491
- seen = set()
1492
-
1493
- for dirname in inputs:
1494
- dirname = normalize_path(dirname)
1495
- if dirname in seen:
1496
- continue
1497
-
1498
- seen.add(dirname)
1499
- if not os.path.isdir(dirname):
1500
- continue
1501
-
1502
- files = os.listdir(dirname)
1503
- yield dirname, files
1504
-
1505
- for name in files:
1506
- if not name.endswith('.pth'):
1507
- # We only care about the .pth files
1508
- continue
1509
- if name in ('easy-install.pth', 'setuptools.pth'):
1510
- # Ignore .pth files that we control
1511
- continue
1512
-
1513
- # Read the .pth file
1514
- content = _read_pth(os.path.join(dirname, name))
1515
- lines = list(yield_lines(content))
1516
-
1517
- # Yield existing non-dupe, non-import directory lines from it
1518
- for line in lines:
1519
- if line.startswith("import"):
1520
- continue
1521
-
1522
- line = normalize_path(line.rstrip())
1523
- if line in seen:
1524
- continue
1525
-
1526
- seen.add(line)
1527
- if not os.path.isdir(line):
1528
- continue
1529
-
1530
- yield line, os.listdir(line)
1531
-
1532
-
1533
- def extract_wininst_cfg(dist_filename):
1534
- """Extract configuration data from a bdist_wininst .exe
1535
-
1536
- Returns a configparser.RawConfigParser, or None
1537
- """
1538
- f = open(dist_filename, 'rb')
1539
- try:
1540
- endrec = zipfile._EndRecData(f)
1541
- if endrec is None:
1542
- return None
1543
-
1544
- prepended = (endrec[9] - endrec[5]) - endrec[6]
1545
- if prepended < 12: # no wininst data here
1546
- return None
1547
- f.seek(prepended - 12)
1548
-
1549
- tag, cfglen, _bmlen = struct.unpack("<iii", f.read(12))
1550
- if tag not in (0x1234567A, 0x1234567B):
1551
- return None # not a valid tag
1552
-
1553
- f.seek(prepended - (12 + cfglen))
1554
- init = {'version': '', 'target_version': ''}
1555
- cfg = configparser.RawConfigParser(init)
1556
- try:
1557
- part = f.read(cfglen)
1558
- # Read up to the first null byte.
1559
- config = part.split(b'\0', 1)[0]
1560
- # Now the config is in bytes, but for RawConfigParser, it should
1561
- # be text, so decode it.
1562
- config = config.decode(sys.getfilesystemencoding())
1563
- cfg.read_file(io.StringIO(config))
1564
- except configparser.Error:
1565
- return None
1566
- if not cfg.has_section('metadata') or not cfg.has_section('Setup'):
1567
- return None
1568
- return cfg
1569
-
1570
- finally:
1571
- f.close()
1572
-
1573
-
1574
- def get_exe_prefixes(exe_filename):
1575
- """Get exe->egg path translations for a given .exe file"""
1576
-
1577
- prefixes = [
1578
- ('PURELIB/', ''),
1579
- ('PLATLIB/pywin32_system32', ''),
1580
- ('PLATLIB/', ''),
1581
- ('SCRIPTS/', 'EGG-INFO/scripts/'),
1582
- ('DATA/lib/site-packages', ''),
1583
- ]
1584
- z = zipfile.ZipFile(exe_filename)
1585
- try:
1586
- for info in z.infolist():
1587
- name = info.filename
1588
- parts = name.split('/')
1589
- if len(parts) == 3 and parts[2] == 'PKG-INFO':
1590
- if parts[1].endswith('.egg-info'):
1591
- prefixes.insert(0, ('/'.join(parts[:2]), 'EGG-INFO/'))
1592
- break
1593
- if len(parts) != 2 or not name.endswith('.pth'):
1594
- continue
1595
- if name.endswith('-nspkg.pth'):
1596
- continue
1597
- if parts[0].upper() in ('PURELIB', 'PLATLIB'):
1598
- contents = z.read(name).decode()
1599
- for pth in yield_lines(contents):
1600
- pth = pth.strip().replace('\\', '/')
1601
- if not pth.startswith('import'):
1602
- prefixes.append(((f'{parts[0]}/{pth}/'), ''))
1603
- finally:
1604
- z.close()
1605
- prefixes = [(x.lower(), y) for x, y in prefixes]
1606
- prefixes.sort()
1607
- prefixes.reverse()
1608
- return prefixes
1609
-
1610
-
1611
- class PthDistributions(Environment):
1612
- """A .pth file with Distribution paths in it"""
1613
-
1614
- def __init__(self, filename, sitedirs=()) -> None:
1615
- self.filename = filename
1616
- self.sitedirs = list(map(normalize_path, sitedirs))
1617
- self.basedir = normalize_path(os.path.dirname(self.filename))
1618
- self.paths, self.dirty = self._load()
1619
- # keep a copy if someone manually updates the paths attribute on the instance
1620
- self._init_paths = self.paths[:]
1621
- super().__init__([], None, None)
1622
- for path in yield_lines(self.paths):
1623
- list(map(self.add, find_distributions(path, True)))
1624
-
1625
- def _load_raw(self):
1626
- paths = []
1627
- dirty = saw_import = False
1628
- seen = set(self.sitedirs)
1629
- content = _read_pth(self.filename)
1630
- for line in content.splitlines():
1631
- path = line.rstrip()
1632
- # still keep imports and empty/commented lines for formatting
1633
- paths.append(path)
1634
- if line.startswith(('import ', 'from ')):
1635
- saw_import = True
1636
- continue
1637
- stripped_path = path.strip()
1638
- if not stripped_path or stripped_path.startswith('#'):
1639
- continue
1640
- # skip non-existent paths, in case somebody deleted a package
1641
- # manually, and duplicate paths as well
1642
- normalized_path = normalize_path(os.path.join(self.basedir, path))
1643
- if normalized_path in seen or not os.path.exists(normalized_path):
1644
- log.debug("cleaned up dirty or duplicated %r", path)
1645
- dirty = True
1646
- paths.pop()
1647
- continue
1648
- seen.add(normalized_path)
1649
- # remove any trailing empty/blank line
1650
- while paths and not paths[-1].strip():
1651
- paths.pop()
1652
- dirty = True
1653
- return paths, dirty or (paths and saw_import)
1654
-
1655
- def _load(self):
1656
- if os.path.isfile(self.filename):
1657
- return self._load_raw()
1658
- return [], False
1659
-
1660
- def save(self) -> None:
1661
- """Write changed .pth file back to disk"""
1662
- # first reload the file
1663
- last_paths, last_dirty = self._load()
1664
- # and check that there are no difference with what we have.
1665
- # there can be difference if someone else has written to the file
1666
- # since we first loaded it.
1667
- # we don't want to lose the eventual new paths added since then.
1668
- for path in last_paths[:]:
1669
- if path not in self.paths:
1670
- self.paths.append(path)
1671
- log.info("detected new path %r", path)
1672
- last_dirty = True
1673
- else:
1674
- last_paths.remove(path)
1675
- # also, re-check that all paths are still valid before saving them
1676
- for path in self.paths[:]:
1677
- if path not in last_paths and not path.startswith((
1678
- 'import ',
1679
- 'from ',
1680
- '#',
1681
- )):
1682
- absolute_path = os.path.join(self.basedir, path)
1683
- if not os.path.exists(absolute_path):
1684
- self.paths.remove(path)
1685
- log.info("removing now non-existent path %r", path)
1686
- last_dirty = True
1687
-
1688
- self.dirty |= last_dirty or self.paths != self._init_paths
1689
- if not self.dirty:
1690
- return
1691
-
1692
- rel_paths = list(map(self.make_relative, self.paths))
1693
- if rel_paths:
1694
- log.debug("Saving %s", self.filename)
1695
- lines = self._wrap_lines(rel_paths)
1696
- data = '\n'.join(lines) + '\n'
1697
- if os.path.islink(self.filename):
1698
- os.unlink(self.filename)
1699
- with open(self.filename, 'wt', encoding=py312.PTH_ENCODING) as f:
1700
- # ^-- Python<3.13 require encoding="locale" instead of "utf-8",
1701
- # see python/cpython#77102.
1702
- f.write(data)
1703
- elif os.path.exists(self.filename):
1704
- log.debug("Deleting empty %s", self.filename)
1705
- os.unlink(self.filename)
1706
-
1707
- self.dirty = False
1708
- self._init_paths[:] = self.paths[:]
1709
-
1710
- @staticmethod
1711
- def _wrap_lines(lines):
1712
- return lines
1713
-
1714
- def add(self, dist) -> None:
1715
- """Add `dist` to the distribution map"""
1716
- new_path = dist.location not in self.paths and (
1717
- dist.location not in self.sitedirs
1718
- or
1719
- # account for '.' being in PYTHONPATH
1720
- dist.location == os.getcwd()
1721
- )
1722
- if new_path:
1723
- self.paths.append(dist.location)
1724
- self.dirty = True
1725
- super().add(dist)
1726
-
1727
- def remove(self, dist) -> None:
1728
- """Remove `dist` from the distribution map"""
1729
- while dist.location in self.paths:
1730
- self.paths.remove(dist.location)
1731
- self.dirty = True
1732
- super().remove(dist)
1733
-
1734
- def make_relative(self, path):
1735
- npath, last = os.path.split(normalize_path(path))
1736
- baselen = len(self.basedir)
1737
- parts = [last]
1738
- sep = os.altsep == '/' and '/' or os.sep
1739
- while len(npath) >= baselen:
1740
- if npath == self.basedir:
1741
- parts.append(os.curdir)
1742
- parts.reverse()
1743
- return sep.join(parts)
1744
- npath, last = os.path.split(npath)
1745
- parts.append(last)
1746
- else:
1747
- return path
1748
-
1749
-
1750
- class RewritePthDistributions(PthDistributions):
1751
- @classmethod
1752
- def _wrap_lines(cls, lines):
1753
- yield cls.prelude
1754
- yield from lines
1755
- yield cls.postlude
1756
-
1757
- prelude = _one_liner(
1758
- """
1759
- import sys
1760
- sys.__plen = len(sys.path)
1761
- """
1762
- )
1763
- postlude = _one_liner(
1764
- """
1765
- import sys
1766
- new = sys.path[sys.__plen:]
1767
- del sys.path[sys.__plen:]
1768
- p = getattr(sys, '__egginsert', 0)
1769
- sys.path[p:p] = new
1770
- sys.__egginsert = p + len(new)
1771
- """
1772
- )
1773
-
1774
-
1775
- if os.environ.get('SETUPTOOLS_SYS_PATH_TECHNIQUE', 'raw') == 'rewrite':
1776
- PthDistributions = RewritePthDistributions # type: ignore[misc] # Overwriting type
1777
-
1778
-
1779
- def _first_line_re():
1780
- """
1781
- Return a regular expression based on first_line_re suitable for matching
1782
- strings.
1783
- """
1784
- if isinstance(first_line_re.pattern, str):
1785
- return first_line_re
1786
-
1787
- # first_line_re in Python >=3.1.4 and >=3.2.1 is a bytes pattern.
1788
- return re.compile(first_line_re.pattern.decode())
1789
-
1790
-
1791
- def update_dist_caches(dist_path, fix_zipimporter_caches):
1792
- """
1793
- Fix any globally cached `dist_path` related data
1794
-
1795
- `dist_path` should be a path of a newly installed egg distribution (zipped
1796
- or unzipped).
1797
-
1798
- sys.path_importer_cache contains finder objects that have been cached when
1799
- importing data from the original distribution. Any such finders need to be
1800
- cleared since the replacement distribution might be packaged differently,
1801
- e.g. a zipped egg distribution might get replaced with an unzipped egg
1802
- folder or vice versa. Having the old finders cached may then cause Python
1803
- to attempt loading modules from the replacement distribution using an
1804
- incorrect loader.
1805
-
1806
- zipimport.zipimporter objects are Python loaders charged with importing
1807
- data packaged inside zip archives. If stale loaders referencing the
1808
- original distribution, are left behind, they can fail to load modules from
1809
- the replacement distribution. E.g. if an old zipimport.zipimporter instance
1810
- is used to load data from a new zipped egg archive, it may cause the
1811
- operation to attempt to locate the requested data in the wrong location -
1812
- one indicated by the original distribution's zip archive directory
1813
- information. Such an operation may then fail outright, e.g. report having
1814
- read a 'bad local file header', or even worse, it may fail silently &
1815
- return invalid data.
1816
-
1817
- zipimport._zip_directory_cache contains cached zip archive directory
1818
- information for all existing zipimport.zipimporter instances and all such
1819
- instances connected to the same archive share the same cached directory
1820
- information.
1821
-
1822
- If asked, and the underlying Python implementation allows it, we can fix
1823
- all existing zipimport.zipimporter instances instead of having to track
1824
- them down and remove them one by one, by updating their shared cached zip
1825
- archive directory information. This, of course, assumes that the
1826
- replacement distribution is packaged as a zipped egg.
1827
-
1828
- If not asked to fix existing zipimport.zipimporter instances, we still do
1829
- our best to clear any remaining zipimport.zipimporter related cached data
1830
- that might somehow later get used when attempting to load data from the new
1831
- distribution and thus cause such load operations to fail. Note that when
1832
- tracking down such remaining stale data, we can not catch every conceivable
1833
- usage from here, and we clear only those that we know of and have found to
1834
- cause problems if left alive. Any remaining caches should be updated by
1835
- whomever is in charge of maintaining them, i.e. they should be ready to
1836
- handle us replacing their zip archives with new distributions at runtime.
1837
-
1838
- """
1839
- # There are several other known sources of stale zipimport.zipimporter
1840
- # instances that we do not clear here, but might if ever given a reason to
1841
- # do so:
1842
- # * Global setuptools pkg_resources.working_set (a.k.a. 'master working
1843
- # set') may contain distributions which may in turn contain their
1844
- # zipimport.zipimporter loaders.
1845
- # * Several zipimport.zipimporter loaders held by local variables further
1846
- # up the function call stack when running the setuptools installation.
1847
- # * Already loaded modules may have their __loader__ attribute set to the
1848
- # exact loader instance used when importing them. Python 3.4 docs state
1849
- # that this information is intended mostly for introspection and so is
1850
- # not expected to cause us problems.
1851
- normalized_path = normalize_path(dist_path)
1852
- _uncache(normalized_path, sys.path_importer_cache)
1853
- if fix_zipimporter_caches:
1854
- _replace_zip_directory_cache_data(normalized_path)
1855
- else:
1856
- # Here, even though we do not want to fix existing and now stale
1857
- # zipimporter cache information, we still want to remove it. Related to
1858
- # Python's zip archive directory information cache, we clear each of
1859
- # its stale entries in two phases:
1860
- # 1. Clear the entry so attempting to access zip archive information
1861
- # via any existing stale zipimport.zipimporter instances fails.
1862
- # 2. Remove the entry from the cache so any newly constructed
1863
- # zipimport.zipimporter instances do not end up using old stale
1864
- # zip archive directory information.
1865
- # This whole stale data removal step does not seem strictly necessary,
1866
- # but has been left in because it was done before we started replacing
1867
- # the zip archive directory information cache content if possible, and
1868
- # there are no relevant unit tests that we can depend on to tell us if
1869
- # this is really needed.
1870
- _remove_and_clear_zip_directory_cache_data(normalized_path)
1871
-
1872
-
1873
- def _collect_zipimporter_cache_entries(normalized_path, cache):
1874
- """
1875
- Return zipimporter cache entry keys related to a given normalized path.
1876
-
1877
- Alternative path spellings (e.g. those using different character case or
1878
- those using alternative path separators) related to the same path are
1879
- included. Any sub-path entries are included as well, i.e. those
1880
- corresponding to zip archives embedded in other zip archives.
1881
-
1882
- """
1883
- result = []
1884
- prefix_len = len(normalized_path)
1885
- for p in cache:
1886
- np = normalize_path(p)
1887
- if np.startswith(normalized_path) and np[prefix_len : prefix_len + 1] in (
1888
- os.sep,
1889
- '',
1890
- ):
1891
- result.append(p)
1892
- return result
1893
-
1894
-
1895
- def _update_zipimporter_cache(normalized_path, cache, updater=None):
1896
- """
1897
- Update zipimporter cache data for a given normalized path.
1898
-
1899
- Any sub-path entries are processed as well, i.e. those corresponding to zip
1900
- archives embedded in other zip archives.
1901
-
1902
- Given updater is a callable taking a cache entry key and the original entry
1903
- (after already removing the entry from the cache), and expected to update
1904
- the entry and possibly return a new one to be inserted in its place.
1905
- Returning None indicates that the entry should not be replaced with a new
1906
- one. If no updater is given, the cache entries are simply removed without
1907
- any additional processing, the same as if the updater simply returned None.
1908
-
1909
- """
1910
- for p in _collect_zipimporter_cache_entries(normalized_path, cache):
1911
- # N.B. pypy's custom zipimport._zip_directory_cache implementation does
1912
- # not support the complete dict interface:
1913
- # * Does not support item assignment, thus not allowing this function
1914
- # to be used only for removing existing cache entries.
1915
- # * Does not support the dict.pop() method, forcing us to use the
1916
- # get/del patterns instead. For more detailed information see the
1917
- # following links:
1918
- # https://github.com/pypa/setuptools/issues/202#issuecomment-202913420
1919
- # https://foss.heptapod.net/pypy/pypy/-/blob/144c4e65cb6accb8e592f3a7584ea38265d1873c/pypy/module/zipimport/interp_zipimport.py
1920
- old_entry = cache[p]
1921
- del cache[p]
1922
- new_entry = updater and updater(p, old_entry)
1923
- if new_entry is not None:
1924
- cache[p] = new_entry
1925
-
1926
-
1927
- def _uncache(normalized_path, cache):
1928
- _update_zipimporter_cache(normalized_path, cache)
1929
-
1930
-
1931
- def _remove_and_clear_zip_directory_cache_data(normalized_path):
1932
- def clear_and_remove_cached_zip_archive_directory_data(path, old_entry):
1933
- old_entry.clear()
1934
-
1935
- _update_zipimporter_cache(
1936
- normalized_path,
1937
- zipimport._zip_directory_cache,
1938
- updater=clear_and_remove_cached_zip_archive_directory_data,
24
+ warnings.SetuptoolsDeprecationWarning.emit(
25
+ summary="easy_install module is deprecated",
26
+ details="Avoid accessing attributes of setuptools.command.easy_install.",
27
+ due_date=(2025, 10, 31),
28
+ see_url="https://github.com/pypa/setuptools/issues/4976",
1939
29
  )
1940
-
1941
-
1942
- # PyPy Python implementation does not allow directly writing to the
1943
- # zipimport._zip_directory_cache and so prevents us from attempting to correct
1944
- # its content. The best we can do there is clear the problematic cache content
1945
- # and have PyPy repopulate it as needed. The downside is that if there are any
1946
- # stale zipimport.zipimporter instances laying around, attempting to use them
1947
- # will fail due to not having its zip archive directory information available
1948
- # instead of being automatically corrected to use the new correct zip archive
1949
- # directory information.
1950
- if '__pypy__' in sys.builtin_module_names:
1951
- _replace_zip_directory_cache_data = _remove_and_clear_zip_directory_cache_data
1952
- else:
1953
-
1954
- def _replace_zip_directory_cache_data(normalized_path):
1955
- def replace_cached_zip_archive_directory_data(path, old_entry):
1956
- # N.B. In theory, we could load the zip directory information just
1957
- # once for all updated path spellings, and then copy it locally and
1958
- # update its contained path strings to contain the correct
1959
- # spelling, but that seems like a way too invasive move (this cache
1960
- # structure is not officially documented anywhere and could in
1961
- # theory change with new Python releases) for no significant
1962
- # benefit.
1963
- old_entry.clear()
1964
- zipimport.zipimporter(path)
1965
- old_entry.update(zipimport._zip_directory_cache[path])
1966
- return old_entry
1967
-
1968
- _update_zipimporter_cache(
1969
- normalized_path,
1970
- zipimport._zip_directory_cache,
1971
- updater=replace_cached_zip_archive_directory_data,
1972
- )
1973
-
1974
-
1975
- def is_python(text, filename='<string>'):
1976
- "Is this string a valid Python script?"
1977
- try:
1978
- compile(text, filename, 'exec')
1979
- except (SyntaxError, TypeError):
1980
- return False
1981
- else:
1982
- return True
1983
-
1984
-
1985
- def is_sh(executable):
1986
- """Determine if the specified executable is a .sh (contains a #! line)"""
1987
- try:
1988
- with open(executable, encoding='latin-1') as fp:
1989
- magic = fp.read(2)
1990
- except OSError:
1991
- return executable
1992
- return magic == '#!'
1993
-
1994
-
1995
- def nt_quote_arg(arg):
1996
- """Quote a command line argument according to Windows parsing rules"""
1997
- return subprocess.list2cmdline([arg])
1998
-
1999
-
2000
- def is_python_script(script_text, filename):
2001
- """Is this text, as a whole, a Python script? (as opposed to shell/bat/etc."""
2002
- if filename.endswith('.py') or filename.endswith('.pyw'):
2003
- return True # extension says it's Python
2004
- if is_python(script_text, filename):
2005
- return True # it's syntactically valid Python
2006
- if script_text.startswith('#!'):
2007
- # It begins with a '#!' line, so check if 'python' is in it somewhere
2008
- return 'python' in script_text.splitlines()[0].lower()
2009
-
2010
- return False # Not any Python I can recognize
2011
-
2012
-
2013
- class _SplitArgs(TypedDict, total=False):
2014
- comments: bool
2015
- posix: bool
2016
-
2017
-
2018
- class CommandSpec(list):
2019
- """
2020
- A command spec for a #! header, specified as a list of arguments akin to
2021
- those passed to Popen.
2022
- """
2023
-
2024
- options: list[str] = []
2025
- split_args = _SplitArgs()
2026
-
2027
- @classmethod
2028
- def best(cls):
2029
- """
2030
- Choose the best CommandSpec class based on environmental conditions.
2031
- """
2032
- return cls
2033
-
2034
- @classmethod
2035
- def _sys_executable(cls):
2036
- _default = os.path.normpath(sys.executable)
2037
- return os.environ.get('__PYVENV_LAUNCHER__', _default)
2038
-
2039
- @classmethod
2040
- def from_param(cls, param: Self | str | Iterable[str] | None) -> Self:
2041
- """
2042
- Construct a CommandSpec from a parameter to build_scripts, which may
2043
- be None.
2044
- """
2045
- if isinstance(param, cls):
2046
- return param
2047
- if isinstance(param, str):
2048
- return cls.from_string(param)
2049
- if isinstance(param, Iterable):
2050
- return cls(param)
2051
- if param is None:
2052
- return cls.from_environment()
2053
- raise TypeError(f"Argument has an unsupported type {type(param)}")
2054
-
2055
- @classmethod
2056
- def from_environment(cls):
2057
- return cls([cls._sys_executable()])
2058
-
2059
- @classmethod
2060
- def from_string(cls, string: str) -> Self:
2061
- """
2062
- Construct a command spec from a simple string representing a command
2063
- line parseable by shlex.split.
2064
- """
2065
- items = shlex.split(string, **cls.split_args)
2066
- return cls(items)
2067
-
2068
- def install_options(self, script_text: str):
2069
- self.options = shlex.split(self._extract_options(script_text))
2070
- cmdline = subprocess.list2cmdline(self)
2071
- if not isascii(cmdline):
2072
- self.options[:0] = ['-x']
2073
-
2074
- @staticmethod
2075
- def _extract_options(orig_script):
2076
- """
2077
- Extract any options from the first line of the script.
2078
- """
2079
- first = (orig_script + '\n').splitlines()[0]
2080
- match = _first_line_re().match(first)
2081
- options = match.group(1) or '' if match else ''
2082
- return options.strip()
2083
-
2084
- def as_header(self):
2085
- return self._render(self + list(self.options))
2086
-
2087
- @staticmethod
2088
- def _strip_quotes(item):
2089
- _QUOTES = '"\''
2090
- for q in _QUOTES:
2091
- if item.startswith(q) and item.endswith(q):
2092
- return item[1:-1]
2093
- return item
2094
-
2095
- @staticmethod
2096
- def _render(items):
2097
- cmdline = subprocess.list2cmdline(
2098
- CommandSpec._strip_quotes(item.strip()) for item in items
2099
- )
2100
- return '#!' + cmdline + '\n'
2101
-
2102
-
2103
- # For pbr compat; will be removed in a future version.
2104
- sys_executable = CommandSpec._sys_executable()
2105
-
2106
-
2107
- class WindowsCommandSpec(CommandSpec):
2108
- split_args = _SplitArgs(posix=False)
2109
-
2110
-
2111
- class ScriptWriter:
2112
- """
2113
- Encapsulates behavior around writing entry point scripts for console and
2114
- gui apps.
2115
- """
2116
-
2117
- template = textwrap.dedent(
2118
- r"""
2119
- # EASY-INSTALL-ENTRY-SCRIPT: %(spec)r,%(group)r,%(name)r
2120
- import re
2121
- import sys
2122
-
2123
- # for compatibility with easy_install; see #2198
2124
- __requires__ = %(spec)r
2125
-
2126
- try:
2127
- from importlib.metadata import distribution
2128
- except ImportError:
2129
- try:
2130
- from importlib_metadata import distribution
2131
- except ImportError:
2132
- from pkg_resources import load_entry_point
2133
-
2134
-
2135
- def importlib_load_entry_point(spec, group, name):
2136
- dist_name, _, _ = spec.partition('==')
2137
- matches = (
2138
- entry_point
2139
- for entry_point in distribution(dist_name).entry_points
2140
- if entry_point.group == group and entry_point.name == name
2141
- )
2142
- return next(matches).load()
2143
-
2144
-
2145
- globals().setdefault('load_entry_point', importlib_load_entry_point)
2146
-
2147
-
2148
- if __name__ == '__main__':
2149
- sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
2150
- sys.exit(load_entry_point(%(spec)r, %(group)r, %(name)r)())
2151
- """
2152
- ).lstrip()
2153
-
2154
- command_spec_class = CommandSpec
2155
-
2156
- @classmethod
2157
- def get_args(cls, dist, header=None):
2158
- """
2159
- Yield write_script() argument tuples for a distribution's
2160
- console_scripts and gui_scripts entry points.
2161
- """
2162
- if header is None:
2163
- header = cls.get_header()
2164
- spec = str(dist.as_requirement())
2165
- for type_ in 'console', 'gui':
2166
- group = type_ + '_scripts'
2167
- for name in dist.get_entry_map(group).keys():
2168
- cls._ensure_safe_name(name)
2169
- script_text = cls.template % locals()
2170
- args = cls._get_script_args(type_, name, header, script_text)
2171
- yield from args
2172
-
2173
- @staticmethod
2174
- def _ensure_safe_name(name):
2175
- """
2176
- Prevent paths in *_scripts entry point names.
2177
- """
2178
- has_path_sep = re.search(r'[\\/]', name)
2179
- if has_path_sep:
2180
- raise ValueError("Path separators not allowed in script names")
2181
-
2182
- @classmethod
2183
- def best(cls):
2184
- """
2185
- Select the best ScriptWriter for this environment.
2186
- """
2187
- if sys.platform == 'win32' or (os.name == 'java' and os._name == 'nt'):
2188
- return WindowsScriptWriter.best()
2189
- else:
2190
- return cls
2191
-
2192
- @classmethod
2193
- def _get_script_args(cls, type_, name, header, script_text):
2194
- # Simply write the stub with no extension.
2195
- yield (name, header + script_text)
2196
-
2197
- @classmethod
2198
- def get_header(
2199
- cls,
2200
- script_text: str = "",
2201
- executable: str | CommandSpec | Iterable[str] | None = None,
2202
- ) -> str:
2203
- """Create a #! line, getting options (if any) from script_text"""
2204
- cmd = cls.command_spec_class.best().from_param(executable)
2205
- cmd.install_options(script_text)
2206
- return cmd.as_header()
2207
-
2208
-
2209
- class WindowsScriptWriter(ScriptWriter):
2210
- command_spec_class = WindowsCommandSpec
2211
-
2212
- @classmethod
2213
- def best(cls):
2214
- """
2215
- Select the best ScriptWriter suitable for Windows
2216
- """
2217
- writer_lookup = dict(
2218
- executable=WindowsExecutableLauncherWriter,
2219
- natural=cls,
2220
- )
2221
- # for compatibility, use the executable launcher by default
2222
- launcher = os.environ.get('SETUPTOOLS_LAUNCHER', 'executable')
2223
- return writer_lookup[launcher]
2224
-
2225
- @classmethod
2226
- def _get_script_args(cls, type_, name, header, script_text):
2227
- "For Windows, add a .py extension"
2228
- ext = dict(console='.pya', gui='.pyw')[type_]
2229
- if ext not in os.environ['PATHEXT'].lower().split(';'):
2230
- msg = (
2231
- "{ext} not listed in PATHEXT; scripts will not be "
2232
- "recognized as executables."
2233
- ).format(**locals())
2234
- SetuptoolsWarning.emit(msg)
2235
- old = ['.pya', '.py', '-script.py', '.pyc', '.pyo', '.pyw', '.exe']
2236
- old.remove(ext)
2237
- header = cls._adjust_header(type_, header)
2238
- blockers = [name + x for x in old]
2239
- yield name + ext, header + script_text, 't', blockers
2240
-
2241
- @classmethod
2242
- def _adjust_header(cls, type_, orig_header):
2243
- """
2244
- Make sure 'pythonw' is used for gui and 'python' is used for
2245
- console (regardless of what sys.executable is).
2246
- """
2247
- pattern = 'pythonw.exe'
2248
- repl = 'python.exe'
2249
- if type_ == 'gui':
2250
- pattern, repl = repl, pattern
2251
- pattern_ob = re.compile(re.escape(pattern), re.IGNORECASE)
2252
- new_header = pattern_ob.sub(string=orig_header, repl=repl)
2253
- return new_header if cls._use_header(new_header) else orig_header
2254
-
2255
- @staticmethod
2256
- def _use_header(new_header):
2257
- """
2258
- Should _adjust_header use the replaced header?
2259
-
2260
- On non-windows systems, always use. On
2261
- Windows systems, only use the replaced header if it resolves
2262
- to an executable on the system.
2263
- """
2264
- clean_header = new_header[2:-1].strip('"')
2265
- return sys.platform != 'win32' or shutil.which(clean_header)
2266
-
2267
-
2268
- class WindowsExecutableLauncherWriter(WindowsScriptWriter):
2269
- @classmethod
2270
- def _get_script_args(cls, type_, name, header, script_text):
2271
- """
2272
- For Windows, add a .py extension and an .exe launcher
2273
- """
2274
- if type_ == 'gui':
2275
- launcher_type = 'gui'
2276
- ext = '-script.pyw'
2277
- old = ['.pyw']
2278
- else:
2279
- launcher_type = 'cli'
2280
- ext = '-script.py'
2281
- old = ['.py', '.pyc', '.pyo']
2282
- hdr = cls._adjust_header(type_, header)
2283
- blockers = [name + x for x in old]
2284
- yield (name + ext, hdr + script_text, 't', blockers)
2285
- yield (
2286
- name + '.exe',
2287
- get_win_launcher(launcher_type),
2288
- 'b', # write in binary mode
2289
- )
2290
- if not is_64bit():
2291
- # install a manifest for the launcher to prevent Windows
2292
- # from detecting it as an installer (which it will for
2293
- # launchers like easy_install.exe). Consider only
2294
- # adding a manifest for launchers detected as installers.
2295
- # See Distribute #143 for details.
2296
- m_name = name + '.exe.manifest'
2297
- yield (m_name, load_launcher_manifest(name), 't')
2298
-
2299
-
2300
- def get_win_launcher(type):
2301
- """
2302
- Load the Windows launcher (executable) suitable for launching a script.
2303
-
2304
- `type` should be either 'cli' or 'gui'
2305
-
2306
- Returns the executable as a byte string.
2307
- """
2308
- launcher_fn = f'{type}.exe'
2309
- if is_64bit():
2310
- if get_platform() == "win-arm64":
2311
- launcher_fn = launcher_fn.replace(".", "-arm64.")
2312
- else:
2313
- launcher_fn = launcher_fn.replace(".", "-64.")
2314
- else:
2315
- launcher_fn = launcher_fn.replace(".", "-32.")
2316
- return resource_string('setuptools', launcher_fn)
2317
-
2318
-
2319
- def load_launcher_manifest(name):
2320
- manifest = pkg_resources.resource_string(__name__, 'launcher manifest.xml')
2321
- return manifest.decode('utf-8') % vars()
2322
-
2323
-
2324
- def current_umask():
2325
- tmp = os.umask(0o022)
2326
- os.umask(tmp)
2327
- return tmp
2328
-
2329
-
2330
- def only_strs(values):
2331
- """
2332
- Exclude non-str values. Ref #3063.
2333
- """
2334
- return filter(lambda val: isinstance(val, str), values)
2335
-
2336
-
2337
- def _read_pth(fullname: str) -> str:
2338
- # Python<3.13 require encoding="locale" instead of "utf-8", see python/cpython#77102
2339
- # In the case old versions of setuptools are producing `pth` files with
2340
- # different encodings that might be problematic... So we fallback to "locale".
2341
-
2342
- try:
2343
- with open(fullname, encoding=py312.PTH_ENCODING) as f:
2344
- return f.read()
2345
- except UnicodeDecodeError: # pragma: no cover
2346
- # This error may only happen for Python >= 3.13
2347
- # TODO: Possible deprecation warnings to be added in the future:
2348
- # ``.pth file {fullname!r} is not UTF-8.``
2349
- # Your environment contain {fullname!r} that cannot be read as UTF-8.
2350
- # This is likely to have been produced with an old version of setuptools.
2351
- # Please be mindful that this is deprecated and in the future, non-utf8
2352
- # .pth files may cause setuptools to fail.
2353
- with open(fullname, encoding=py39.LOCALE_ENCODING) as f:
2354
- return f.read()
2355
-
2356
-
2357
- class EasyInstallDeprecationWarning(SetuptoolsDeprecationWarning):
2358
- _SUMMARY = "easy_install command is deprecated."
2359
- _DETAILS = """
2360
- Please avoid running ``setup.py`` and ``easy_install``.
2361
- Instead, use pypa/build, pypa/installer or other
2362
- standards-based tools.
2363
- """
2364
- _SEE_URL = "https://github.com/pypa/setuptools/issues/917"
2365
- # _DUE_DATE not defined yet
30
+ return attr