@btc-vision/bitcoin 6.4.9 → 6.4.11

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 (230) hide show
  1. package/.babelrc +4 -4
  2. package/.mocharc.json +13 -13
  3. package/.prettierrc.json +12 -12
  4. package/CHANGELOG.md +403 -403
  5. package/CONTRIBUTING.md +83 -83
  6. package/LICENSE +21 -21
  7. package/README.md +201 -201
  8. package/browser/index.d.ts +1 -1
  9. package/browser/index.js +1 -1
  10. package/browser/{ops.d.ts → opcodes.d.ts} +2 -3
  11. package/browser/script.d.ts +2 -2
  12. package/build/address.js +2 -1
  13. package/build/index.d.ts +1 -1
  14. package/build/index.js +1 -1
  15. package/build/{ops.d.ts → opcodes.d.ts} +2 -3
  16. package/build/{ops.js → opcodes.js} +4 -5
  17. package/build/payments/embed.js +1 -1
  18. package/build/payments/p2ms.js +1 -1
  19. package/build/payments/p2op.js +1 -1
  20. package/build/payments/p2pk.js +1 -1
  21. package/build/payments/p2pkh.js +1 -1
  22. package/build/payments/p2sh.js +3 -3
  23. package/build/payments/p2tr.js +1 -1
  24. package/build/payments/p2wpkh.js +2 -2
  25. package/build/payments/p2wsh.js +2 -2
  26. package/build/push_data.js +9 -9
  27. package/build/script.d.ts +2 -2
  28. package/build/script.js +12 -12
  29. package/build/transaction.js +1 -1
  30. package/cjs/package.json +3 -3
  31. package/gulpfile.js +42 -42
  32. package/package.json +150 -150
  33. package/src/address.ts +304 -303
  34. package/src/bip66.ts +107 -107
  35. package/src/block.ts +233 -233
  36. package/src/bufferutils.ts +188 -188
  37. package/src/crypto.ts +108 -108
  38. package/src/ecc_lib.ts +94 -94
  39. package/src/hooks/AdvancedSignatureManager.ts +104 -104
  40. package/src/hooks/SignatureManager.ts +84 -84
  41. package/src/index.ts +105 -105
  42. package/src/merkle.ts +31 -31
  43. package/src/{ops.ts → opcodes.ts} +280 -282
  44. package/src/payments/bip341.ts +140 -140
  45. package/src/payments/embed.ts +61 -61
  46. package/src/payments/index.ts +172 -172
  47. package/src/payments/lazy.ts +28 -28
  48. package/src/payments/p2ms.ts +156 -156
  49. package/src/payments/p2op.ts +195 -195
  50. package/src/payments/p2pk.ts +93 -93
  51. package/src/payments/p2pkh.ts +214 -214
  52. package/src/payments/p2sh.ts +210 -210
  53. package/src/payments/p2tr.ts +309 -309
  54. package/src/payments/p2wpkh.ts +144 -144
  55. package/src/payments/p2wsh.ts +217 -217
  56. package/src/psbt/bip371.ts +441 -441
  57. package/src/push_data.ts +97 -97
  58. package/src/script.ts +247 -247
  59. package/src/script_number.ts +72 -72
  60. package/src/script_signature.ts +91 -91
  61. package/src/transaction.ts +656 -656
  62. package/test/address.spec.ts +155 -155
  63. package/test/bitcoin.core.spec.ts +212 -212
  64. package/test/block.spec.ts +171 -171
  65. package/test/bufferutils.spec.ts +450 -450
  66. package/test/crypto.spec.ts +49 -49
  67. package/test/fixtures/address.json +329 -329
  68. package/test/fixtures/block.json +148 -148
  69. package/test/fixtures/bufferutils.json +102 -102
  70. package/test/fixtures/core/README.md +26 -26
  71. package/test/fixtures/core/base58_encode_decode.json +50 -50
  72. package/test/fixtures/core/base58_keys_invalid.json +152 -152
  73. package/test/fixtures/core/base58_keys_valid.json +452 -452
  74. package/test/fixtures/core/blocks.json +27 -27
  75. package/test/fixtures/core/sig_canonical.json +7 -7
  76. package/test/fixtures/core/sig_noncanonical.json +33 -33
  77. package/test/fixtures/core/sighash.json +3505 -3505
  78. package/test/fixtures/core/tx_valid.json +2023 -2023
  79. package/test/fixtures/crypto.json +43 -43
  80. package/test/fixtures/ecdsa.json +217 -217
  81. package/test/fixtures/ecpair.json +141 -141
  82. package/test/fixtures/embed.json +108 -108
  83. package/test/fixtures/p2ms.json +434 -434
  84. package/test/fixtures/p2pk.json +179 -179
  85. package/test/fixtures/p2pkh.json +276 -276
  86. package/test/fixtures/p2sh.json +508 -508
  87. package/test/fixtures/p2tr.json +1198 -1198
  88. package/test/fixtures/p2wpkh.json +290 -290
  89. package/test/fixtures/p2wsh.json +489 -489
  90. package/test/fixtures/psbt.json +924 -924
  91. package/test/fixtures/script.json +465 -465
  92. package/test/fixtures/script_number.json +225 -225
  93. package/test/fixtures/signature.json +140 -140
  94. package/test/fixtures/transaction.json +916 -916
  95. package/test/integration/_regtest.ts +6 -6
  96. package/test/integration/addresses.spec.ts +142 -142
  97. package/test/integration/bip32.spec.ts +130 -130
  98. package/test/integration/blocks.spec.ts +28 -28
  99. package/test/integration/cltv.spec.ts +241 -241
  100. package/test/integration/csv.spec.ts +452 -452
  101. package/test/integration/payments.spec.ts +110 -110
  102. package/test/integration/taproot.spec.ts +663 -663
  103. package/test/integration/transactions.spec.ts +668 -668
  104. package/test/payments.spec.ts +114 -114
  105. package/test/payments.utils.ts +165 -165
  106. package/test/psbt.spec.ts +1285 -1285
  107. package/test/script.spec.ts +186 -186
  108. package/test/script_number.spec.ts +26 -26
  109. package/test/script_signature.spec.ts +66 -66
  110. package/test/transaction.spec.ts +337 -337
  111. package/test/ts-node-register.js +7 -7
  112. package/test/tsconfig.json +48 -48
  113. package/test/types.spec.ts +53 -53
  114. package/tsconfig.base.json +27 -27
  115. package/tsconfig.json +19 -19
  116. package/tsconfig.webpack.json +18 -18
  117. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/.ready +0 -0
  118. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/.release-please-manifest.json +0 -3
  119. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/CHANGELOG.md +0 -962
  120. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/CONTRIBUTING.md +0 -34
  121. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/LICENSE +0 -24
  122. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/README.md +0 -273
  123. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/SECURITY.md +0 -2
  124. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/addon.gypi +0 -204
  125. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/bin/node-gyp.js +0 -138
  126. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/.release-please-manifest.json +0 -3
  127. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/LICENSE +0 -28
  128. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/data/ninja/build.ninja +0 -4
  129. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/data/win/large-pdb-shim.cc +0 -12
  130. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/GypVsCMake.md +0 -116
  131. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/Hacking.md +0 -46
  132. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/InputFormatReference.md +0 -1080
  133. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/LanguageSpecification.md +0 -430
  134. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/README.md +0 -27
  135. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/Testing.md +0 -450
  136. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/UserDocumentation.md +0 -965
  137. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/gyp +0 -8
  138. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/gyp.bat +0 -5
  139. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/gyp_main.py +0 -45
  140. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +0 -365
  141. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSProject.py +0 -206
  142. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py +0 -1272
  143. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py +0 -1547
  144. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSToolFile.py +0 -59
  145. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSUserFile.py +0 -153
  146. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSUtil.py +0 -271
  147. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +0 -574
  148. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/__init__.py +0 -692
  149. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/common.py +0 -711
  150. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/common_test.py +0 -171
  151. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py +0 -169
  152. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py +0 -113
  153. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/flock_tool.py +0 -55
  154. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/__init__.py +0 -0
  155. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/analyzer.py +0 -804
  156. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/android.py +0 -1173
  157. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py +0 -1318
  158. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/compile_commands_json.py +0 -127
  159. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/dump_dependency_json.py +0 -103
  160. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py +0 -461
  161. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/gypd.py +0 -89
  162. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/gypsh.py +0 -57
  163. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +0 -2745
  164. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py +0 -3976
  165. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py +0 -44
  166. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +0 -2964
  167. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py +0 -67
  168. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py +0 -1391
  169. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode_test.py +0 -25
  170. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/input.py +0 -3115
  171. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/input_test.py +0 -98
  172. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/mac_tool.py +0 -771
  173. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py +0 -1260
  174. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/ninja_syntax.py +0 -174
  175. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py +0 -61
  176. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/win_tool.py +0 -373
  177. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py +0 -1938
  178. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation_test.py +0 -53
  179. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcode_ninja.py +0 -302
  180. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +0 -3198
  181. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xml_fix.py +0 -65
  182. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/LICENSE +0 -3
  183. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/LICENSE.APACHE +0 -177
  184. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/LICENSE.BSD +0 -23
  185. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/__init__.py +0 -15
  186. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_elffile.py +0 -108
  187. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_manylinux.py +0 -252
  188. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_musllinux.py +0 -83
  189. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_parser.py +0 -359
  190. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_structures.py +0 -61
  191. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_tokenizer.py +0 -192
  192. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/markers.py +0 -252
  193. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/metadata.py +0 -825
  194. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/py.typed +0 -0
  195. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/requirements.py +0 -90
  196. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/specifiers.py +0 -1030
  197. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/tags.py +0 -553
  198. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/utils.py +0 -172
  199. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/version.py +0 -563
  200. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pyproject.toml +0 -120
  201. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/release-please-config.json +0 -11
  202. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/test_gyp.py +0 -261
  203. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/Find-VisualStudio.cs +0 -250
  204. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/build.js +0 -227
  205. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/clean.js +0 -15
  206. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/configure.js +0 -328
  207. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/create-config-gypi.js +0 -150
  208. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/download.js +0 -39
  209. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/find-node-directory.js +0 -63
  210. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/find-python.js +0 -310
  211. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/find-visualstudio.js +0 -590
  212. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/install.js +0 -415
  213. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/list.js +0 -26
  214. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/log.js +0 -168
  215. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/node-gyp.js +0 -188
  216. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/process-release.js +0 -146
  217. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/rebuild.js +0 -12
  218. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/remove.js +0 -43
  219. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/util.js +0 -81
  220. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/macOS_Catalina_acid_test.sh +0 -21
  221. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/package.json +0 -51
  222. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/release-please-config.json +0 -40
  223. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/src/win_delay_load_hook.cc +0 -39
  224. package/coverage/tmp/coverage-31752-1735543485354-0.json +0 -1
  225. package/coverage/tmp/coverage-59920-1735543484555-0.json +0 -1
  226. package/coverage/tmp/coverage-66252-1735543483919-0.json +0 -1
  227. package/coverage/tmp/coverage-68440-1735543485236-0.json +0 -1
  228. package/coverage/tmp/coverage-70588-1735543484426-0.json +0 -1
  229. package/coverage/tmp/coverage-79292-1735543485296-0.json +0 -1
  230. package/coverage/tmp/coverage-80212-1735543483980-0.json +0 -1
@@ -1,553 +0,0 @@
1
- # This file is dual licensed under the terms of the Apache License, Version
2
- # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
- # for complete details.
4
-
5
- import logging
6
- import platform
7
- import struct
8
- import subprocess
9
- import sys
10
- import sysconfig
11
- from importlib.machinery import EXTENSION_SUFFIXES
12
- from typing import (
13
- Dict,
14
- FrozenSet,
15
- Iterable,
16
- Iterator,
17
- List,
18
- Optional,
19
- Sequence,
20
- Tuple,
21
- Union,
22
- cast,
23
- )
24
-
25
- from . import _manylinux, _musllinux
26
-
27
- logger = logging.getLogger(__name__)
28
-
29
- PythonVersion = Sequence[int]
30
- MacVersion = Tuple[int, int]
31
-
32
- INTERPRETER_SHORT_NAMES: Dict[str, str] = {
33
- "python": "py", # Generic.
34
- "cpython": "cp",
35
- "pypy": "pp",
36
- "ironpython": "ip",
37
- "jython": "jy",
38
- }
39
-
40
-
41
- _32_BIT_INTERPRETER = struct.calcsize("P") == 4
42
-
43
-
44
- class Tag:
45
- """
46
- A representation of the tag triple for a wheel.
47
-
48
- Instances are considered immutable and thus are hashable. Equality checking
49
- is also supported.
50
- """
51
-
52
- __slots__ = ["_interpreter", "_abi", "_platform", "_hash"]
53
-
54
- def __init__(self, interpreter: str, abi: str, platform: str) -> None:
55
- self._interpreter = interpreter.lower()
56
- self._abi = abi.lower()
57
- self._platform = platform.lower()
58
- # The __hash__ of every single element in a Set[Tag] will be evaluated each time
59
- # that a set calls its `.disjoint()` method, which may be called hundreds of
60
- # times when scanning a page of links for packages with tags matching that
61
- # Set[Tag]. Pre-computing the value here produces significant speedups for
62
- # downstream consumers.
63
- self._hash = hash((self._interpreter, self._abi, self._platform))
64
-
65
- @property
66
- def interpreter(self) -> str:
67
- return self._interpreter
68
-
69
- @property
70
- def abi(self) -> str:
71
- return self._abi
72
-
73
- @property
74
- def platform(self) -> str:
75
- return self._platform
76
-
77
- def __eq__(self, other: object) -> bool:
78
- if not isinstance(other, Tag):
79
- return NotImplemented
80
-
81
- return (
82
- (self._hash == other._hash) # Short-circuit ASAP for perf reasons.
83
- and (self._platform == other._platform)
84
- and (self._abi == other._abi)
85
- and (self._interpreter == other._interpreter)
86
- )
87
-
88
- def __hash__(self) -> int:
89
- return self._hash
90
-
91
- def __str__(self) -> str:
92
- return f"{self._interpreter}-{self._abi}-{self._platform}"
93
-
94
- def __repr__(self) -> str:
95
- return f"<{self} @ {id(self)}>"
96
-
97
-
98
- def parse_tag(tag: str) -> FrozenSet[Tag]:
99
- """
100
- Parses the provided tag (e.g. `py3-none-any`) into a frozenset of Tag instances.
101
-
102
- Returning a set is required due to the possibility that the tag is a
103
- compressed tag set.
104
- """
105
- tags = set()
106
- interpreters, abis, platforms = tag.split("-")
107
- for interpreter in interpreters.split("."):
108
- for abi in abis.split("."):
109
- for platform_ in platforms.split("."):
110
- tags.add(Tag(interpreter, abi, platform_))
111
- return frozenset(tags)
112
-
113
-
114
- def _get_config_var(name: str, warn: bool = False) -> Union[int, str, None]:
115
- value: Union[int, str, None] = sysconfig.get_config_var(name)
116
- if value is None and warn:
117
- logger.debug(
118
- "Config variable '%s' is unset, Python ABI tag may be incorrect", name
119
- )
120
- return value
121
-
122
-
123
- def _normalize_string(string: str) -> str:
124
- return string.replace(".", "_").replace("-", "_").replace(" ", "_")
125
-
126
-
127
- def _abi3_applies(python_version: PythonVersion) -> bool:
128
- """
129
- Determine if the Python version supports abi3.
130
-
131
- PEP 384 was first implemented in Python 3.2.
132
- """
133
- return len(python_version) > 1 and tuple(python_version) >= (3, 2)
134
-
135
-
136
- def _cpython_abis(py_version: PythonVersion, warn: bool = False) -> List[str]:
137
- py_version = tuple(py_version) # To allow for version comparison.
138
- abis = []
139
- version = _version_nodot(py_version[:2])
140
- debug = pymalloc = ucs4 = ""
141
- with_debug = _get_config_var("Py_DEBUG", warn)
142
- has_refcount = hasattr(sys, "gettotalrefcount")
143
- # Windows doesn't set Py_DEBUG, so checking for support of debug-compiled
144
- # extension modules is the best option.
145
- # https://github.com/pypa/pip/issues/3383#issuecomment-173267692
146
- has_ext = "_d.pyd" in EXTENSION_SUFFIXES
147
- if with_debug or (with_debug is None and (has_refcount or has_ext)):
148
- debug = "d"
149
- if py_version < (3, 8):
150
- with_pymalloc = _get_config_var("WITH_PYMALLOC", warn)
151
- if with_pymalloc or with_pymalloc is None:
152
- pymalloc = "m"
153
- if py_version < (3, 3):
154
- unicode_size = _get_config_var("Py_UNICODE_SIZE", warn)
155
- if unicode_size == 4 or (
156
- unicode_size is None and sys.maxunicode == 0x10FFFF
157
- ):
158
- ucs4 = "u"
159
- elif debug:
160
- # Debug builds can also load "normal" extension modules.
161
- # We can also assume no UCS-4 or pymalloc requirement.
162
- abis.append(f"cp{version}")
163
- abis.insert(
164
- 0,
165
- "cp{version}{debug}{pymalloc}{ucs4}".format(
166
- version=version, debug=debug, pymalloc=pymalloc, ucs4=ucs4
167
- ),
168
- )
169
- return abis
170
-
171
-
172
- def cpython_tags(
173
- python_version: Optional[PythonVersion] = None,
174
- abis: Optional[Iterable[str]] = None,
175
- platforms: Optional[Iterable[str]] = None,
176
- *,
177
- warn: bool = False,
178
- ) -> Iterator[Tag]:
179
- """
180
- Yields the tags for a CPython interpreter.
181
-
182
- The tags consist of:
183
- - cp<python_version>-<abi>-<platform>
184
- - cp<python_version>-abi3-<platform>
185
- - cp<python_version>-none-<platform>
186
- - cp<less than python_version>-abi3-<platform> # Older Python versions down to 3.2.
187
-
188
- If python_version only specifies a major version then user-provided ABIs and
189
- the 'none' ABItag will be used.
190
-
191
- If 'abi3' or 'none' are specified in 'abis' then they will be yielded at
192
- their normal position and not at the beginning.
193
- """
194
- if not python_version:
195
- python_version = sys.version_info[:2]
196
-
197
- interpreter = f"cp{_version_nodot(python_version[:2])}"
198
-
199
- if abis is None:
200
- if len(python_version) > 1:
201
- abis = _cpython_abis(python_version, warn)
202
- else:
203
- abis = []
204
- abis = list(abis)
205
- # 'abi3' and 'none' are explicitly handled later.
206
- for explicit_abi in ("abi3", "none"):
207
- try:
208
- abis.remove(explicit_abi)
209
- except ValueError:
210
- pass
211
-
212
- platforms = list(platforms or platform_tags())
213
- for abi in abis:
214
- for platform_ in platforms:
215
- yield Tag(interpreter, abi, platform_)
216
- if _abi3_applies(python_version):
217
- yield from (Tag(interpreter, "abi3", platform_) for platform_ in platforms)
218
- yield from (Tag(interpreter, "none", platform_) for platform_ in platforms)
219
-
220
- if _abi3_applies(python_version):
221
- for minor_version in range(python_version[1] - 1, 1, -1):
222
- for platform_ in platforms:
223
- interpreter = "cp{version}".format(
224
- version=_version_nodot((python_version[0], minor_version))
225
- )
226
- yield Tag(interpreter, "abi3", platform_)
227
-
228
-
229
- def _generic_abi() -> List[str]:
230
- """
231
- Return the ABI tag based on EXT_SUFFIX.
232
- """
233
- # The following are examples of `EXT_SUFFIX`.
234
- # We want to keep the parts which are related to the ABI and remove the
235
- # parts which are related to the platform:
236
- # - linux: '.cpython-310-x86_64-linux-gnu.so' => cp310
237
- # - mac: '.cpython-310-darwin.so' => cp310
238
- # - win: '.cp310-win_amd64.pyd' => cp310
239
- # - win: '.pyd' => cp37 (uses _cpython_abis())
240
- # - pypy: '.pypy38-pp73-x86_64-linux-gnu.so' => pypy38_pp73
241
- # - graalpy: '.graalpy-38-native-x86_64-darwin.dylib'
242
- # => graalpy_38_native
243
-
244
- ext_suffix = _get_config_var("EXT_SUFFIX", warn=True)
245
- if not isinstance(ext_suffix, str) or ext_suffix[0] != ".":
246
- raise SystemError("invalid sysconfig.get_config_var('EXT_SUFFIX')")
247
- parts = ext_suffix.split(".")
248
- if len(parts) < 3:
249
- # CPython3.7 and earlier uses ".pyd" on Windows.
250
- return _cpython_abis(sys.version_info[:2])
251
- soabi = parts[1]
252
- if soabi.startswith("cpython"):
253
- # non-windows
254
- abi = "cp" + soabi.split("-")[1]
255
- elif soabi.startswith("cp"):
256
- # windows
257
- abi = soabi.split("-")[0]
258
- elif soabi.startswith("pypy"):
259
- abi = "-".join(soabi.split("-")[:2])
260
- elif soabi.startswith("graalpy"):
261
- abi = "-".join(soabi.split("-")[:3])
262
- elif soabi:
263
- # pyston, ironpython, others?
264
- abi = soabi
265
- else:
266
- return []
267
- return [_normalize_string(abi)]
268
-
269
-
270
- def generic_tags(
271
- interpreter: Optional[str] = None,
272
- abis: Optional[Iterable[str]] = None,
273
- platforms: Optional[Iterable[str]] = None,
274
- *,
275
- warn: bool = False,
276
- ) -> Iterator[Tag]:
277
- """
278
- Yields the tags for a generic interpreter.
279
-
280
- The tags consist of:
281
- - <interpreter>-<abi>-<platform>
282
-
283
- The "none" ABI will be added if it was not explicitly provided.
284
- """
285
- if not interpreter:
286
- interp_name = interpreter_name()
287
- interp_version = interpreter_version(warn=warn)
288
- interpreter = "".join([interp_name, interp_version])
289
- if abis is None:
290
- abis = _generic_abi()
291
- else:
292
- abis = list(abis)
293
- platforms = list(platforms or platform_tags())
294
- if "none" not in abis:
295
- abis.append("none")
296
- for abi in abis:
297
- for platform_ in platforms:
298
- yield Tag(interpreter, abi, platform_)
299
-
300
-
301
- def _py_interpreter_range(py_version: PythonVersion) -> Iterator[str]:
302
- """
303
- Yields Python versions in descending order.
304
-
305
- After the latest version, the major-only version will be yielded, and then
306
- all previous versions of that major version.
307
- """
308
- if len(py_version) > 1:
309
- yield f"py{_version_nodot(py_version[:2])}"
310
- yield f"py{py_version[0]}"
311
- if len(py_version) > 1:
312
- for minor in range(py_version[1] - 1, -1, -1):
313
- yield f"py{_version_nodot((py_version[0], minor))}"
314
-
315
-
316
- def compatible_tags(
317
- python_version: Optional[PythonVersion] = None,
318
- interpreter: Optional[str] = None,
319
- platforms: Optional[Iterable[str]] = None,
320
- ) -> Iterator[Tag]:
321
- """
322
- Yields the sequence of tags that are compatible with a specific version of Python.
323
-
324
- The tags consist of:
325
- - py*-none-<platform>
326
- - <interpreter>-none-any # ... if `interpreter` is provided.
327
- - py*-none-any
328
- """
329
- if not python_version:
330
- python_version = sys.version_info[:2]
331
- platforms = list(platforms or platform_tags())
332
- for version in _py_interpreter_range(python_version):
333
- for platform_ in platforms:
334
- yield Tag(version, "none", platform_)
335
- if interpreter:
336
- yield Tag(interpreter, "none", "any")
337
- for version in _py_interpreter_range(python_version):
338
- yield Tag(version, "none", "any")
339
-
340
-
341
- def _mac_arch(arch: str, is_32bit: bool = _32_BIT_INTERPRETER) -> str:
342
- if not is_32bit:
343
- return arch
344
-
345
- if arch.startswith("ppc"):
346
- return "ppc"
347
-
348
- return "i386"
349
-
350
-
351
- def _mac_binary_formats(version: MacVersion, cpu_arch: str) -> List[str]:
352
- formats = [cpu_arch]
353
- if cpu_arch == "x86_64":
354
- if version < (10, 4):
355
- return []
356
- formats.extend(["intel", "fat64", "fat32"])
357
-
358
- elif cpu_arch == "i386":
359
- if version < (10, 4):
360
- return []
361
- formats.extend(["intel", "fat32", "fat"])
362
-
363
- elif cpu_arch == "ppc64":
364
- # TODO: Need to care about 32-bit PPC for ppc64 through 10.2?
365
- if version > (10, 5) or version < (10, 4):
366
- return []
367
- formats.append("fat64")
368
-
369
- elif cpu_arch == "ppc":
370
- if version > (10, 6):
371
- return []
372
- formats.extend(["fat32", "fat"])
373
-
374
- if cpu_arch in {"arm64", "x86_64"}:
375
- formats.append("universal2")
376
-
377
- if cpu_arch in {"x86_64", "i386", "ppc64", "ppc", "intel"}:
378
- formats.append("universal")
379
-
380
- return formats
381
-
382
-
383
- def mac_platforms(
384
- version: Optional[MacVersion] = None, arch: Optional[str] = None
385
- ) -> Iterator[str]:
386
- """
387
- Yields the platform tags for a macOS system.
388
-
389
- The `version` parameter is a two-item tuple specifying the macOS version to
390
- generate platform tags for. The `arch` parameter is the CPU architecture to
391
- generate platform tags for. Both parameters default to the appropriate value
392
- for the current system.
393
- """
394
- version_str, _, cpu_arch = platform.mac_ver()
395
- if version is None:
396
- version = cast("MacVersion", tuple(map(int, version_str.split(".")[:2])))
397
- if version == (10, 16):
398
- # When built against an older macOS SDK, Python will report macOS 10.16
399
- # instead of the real version.
400
- version_str = subprocess.run(
401
- [
402
- sys.executable,
403
- "-sS",
404
- "-c",
405
- "import platform; print(platform.mac_ver()[0])",
406
- ],
407
- check=True,
408
- env={"SYSTEM_VERSION_COMPAT": "0"},
409
- stdout=subprocess.PIPE,
410
- text=True,
411
- ).stdout
412
- version = cast("MacVersion", tuple(map(int, version_str.split(".")[:2])))
413
- else:
414
- version = version
415
- if arch is None:
416
- arch = _mac_arch(cpu_arch)
417
- else:
418
- arch = arch
419
-
420
- if (10, 0) <= version and version < (11, 0):
421
- # Prior to Mac OS 11, each yearly release of Mac OS bumped the
422
- # "minor" version number. The major version was always 10.
423
- for minor_version in range(version[1], -1, -1):
424
- compat_version = 10, minor_version
425
- binary_formats = _mac_binary_formats(compat_version, arch)
426
- for binary_format in binary_formats:
427
- yield "macosx_{major}_{minor}_{binary_format}".format(
428
- major=10, minor=minor_version, binary_format=binary_format
429
- )
430
-
431
- if version >= (11, 0):
432
- # Starting with Mac OS 11, each yearly release bumps the major version
433
- # number. The minor versions are now the midyear updates.
434
- for major_version in range(version[0], 10, -1):
435
- compat_version = major_version, 0
436
- binary_formats = _mac_binary_formats(compat_version, arch)
437
- for binary_format in binary_formats:
438
- yield "macosx_{major}_{minor}_{binary_format}".format(
439
- major=major_version, minor=0, binary_format=binary_format
440
- )
441
-
442
- if version >= (11, 0):
443
- # Mac OS 11 on x86_64 is compatible with binaries from previous releases.
444
- # Arm64 support was introduced in 11.0, so no Arm binaries from previous
445
- # releases exist.
446
- #
447
- # However, the "universal2" binary format can have a
448
- # macOS version earlier than 11.0 when the x86_64 part of the binary supports
449
- # that version of macOS.
450
- if arch == "x86_64":
451
- for minor_version in range(16, 3, -1):
452
- compat_version = 10, minor_version
453
- binary_formats = _mac_binary_formats(compat_version, arch)
454
- for binary_format in binary_formats:
455
- yield "macosx_{major}_{minor}_{binary_format}".format(
456
- major=compat_version[0],
457
- minor=compat_version[1],
458
- binary_format=binary_format,
459
- )
460
- else:
461
- for minor_version in range(16, 3, -1):
462
- compat_version = 10, minor_version
463
- binary_format = "universal2"
464
- yield "macosx_{major}_{minor}_{binary_format}".format(
465
- major=compat_version[0],
466
- minor=compat_version[1],
467
- binary_format=binary_format,
468
- )
469
-
470
-
471
- def _linux_platforms(is_32bit: bool = _32_BIT_INTERPRETER) -> Iterator[str]:
472
- linux = _normalize_string(sysconfig.get_platform())
473
- if not linux.startswith("linux_"):
474
- # we should never be here, just yield the sysconfig one and return
475
- yield linux
476
- return
477
- if is_32bit:
478
- if linux == "linux_x86_64":
479
- linux = "linux_i686"
480
- elif linux == "linux_aarch64":
481
- linux = "linux_armv8l"
482
- _, arch = linux.split("_", 1)
483
- archs = {"armv8l": ["armv8l", "armv7l"]}.get(arch, [arch])
484
- yield from _manylinux.platform_tags(archs)
485
- yield from _musllinux.platform_tags(archs)
486
- for arch in archs:
487
- yield f"linux_{arch}"
488
-
489
-
490
- def _generic_platforms() -> Iterator[str]:
491
- yield _normalize_string(sysconfig.get_platform())
492
-
493
-
494
- def platform_tags() -> Iterator[str]:
495
- """
496
- Provides the platform tags for this installation.
497
- """
498
- if platform.system() == "Darwin":
499
- return mac_platforms()
500
- elif platform.system() == "Linux":
501
- return _linux_platforms()
502
- else:
503
- return _generic_platforms()
504
-
505
-
506
- def interpreter_name() -> str:
507
- """
508
- Returns the name of the running interpreter.
509
-
510
- Some implementations have a reserved, two-letter abbreviation which will
511
- be returned when appropriate.
512
- """
513
- name = sys.implementation.name
514
- return INTERPRETER_SHORT_NAMES.get(name) or name
515
-
516
-
517
- def interpreter_version(*, warn: bool = False) -> str:
518
- """
519
- Returns the version of the running interpreter.
520
- """
521
- version = _get_config_var("py_version_nodot", warn=warn)
522
- if version:
523
- version = str(version)
524
- else:
525
- version = _version_nodot(sys.version_info[:2])
526
- return version
527
-
528
-
529
- def _version_nodot(version: PythonVersion) -> str:
530
- return "".join(map(str, version))
531
-
532
-
533
- def sys_tags(*, warn: bool = False) -> Iterator[Tag]:
534
- """
535
- Returns the sequence of tag triples for the running interpreter.
536
-
537
- The order of the sequence corresponds to priority order for the
538
- interpreter, from most to least important.
539
- """
540
-
541
- interp_name = interpreter_name()
542
- if interp_name == "cp":
543
- yield from cpython_tags(warn=warn)
544
- else:
545
- yield from generic_tags()
546
-
547
- if interp_name == "pp":
548
- interp = "pp3"
549
- elif interp_name == "cp":
550
- interp = "cp" + interpreter_version(warn=warn)
551
- else:
552
- interp = None
553
- yield from compatible_tags(interpreter=interp)