@btc-vision/bitcoin 6.4.10 → 6.5.1
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.
- package/.babelrc +13 -4
- package/.mocharc.json +13 -13
- package/.prettierrc.json +12 -12
- package/CHANGELOG.md +403 -403
- package/CONTRIBUTING.md +83 -83
- package/LICENSE +21 -21
- package/README.md +201 -201
- package/browser/chunks/crypto-C6FlKKmp.js +2006 -0
- package/browser/chunks/payments-BE4vwHhV.js +1045 -0
- package/browser/chunks/psbt-Dlosf9CT.js +3853 -0
- package/browser/chunks/script-COWGdiOo.js +318 -0
- package/browser/chunks/transaction-BiXwH2v4.js +421 -0
- package/browser/chunks/utils-BKmkTzNZ.js +759 -0
- package/browser/crypto/crypto.d.ts +1 -1
- package/browser/index.d.ts +7 -27
- package/browser/index.js +92 -2
- package/build/index.d.ts +7 -27
- package/build/index.js +2 -2
- package/cjs/package.json +3 -3
- package/gulpfile.js +42 -42
- package/package.json +153 -150
- package/src/bip66.ts +107 -107
- package/src/block.ts +233 -233
- package/src/bufferutils.ts +188 -188
- package/src/crypto.ts +108 -108
- package/src/ecc_lib.ts +94 -94
- package/src/hooks/AdvancedSignatureManager.ts +104 -104
- package/src/hooks/SignatureManager.ts +84 -84
- package/src/index.ts +83 -105
- package/src/merkle.ts +31 -31
- package/src/opcodes.ts +280 -280
- package/src/payments/bip341.ts +140 -140
- package/src/payments/embed.ts +61 -61
- package/src/payments/index.ts +172 -172
- package/src/payments/lazy.ts +28 -28
- package/src/payments/p2ms.ts +156 -156
- package/src/payments/p2op.ts +195 -195
- package/src/payments/p2pk.ts +93 -93
- package/src/payments/p2pkh.ts +214 -214
- package/src/payments/p2tr.ts +309 -309
- package/src/psbt/bip371.ts +441 -441
- package/src/push_data.ts +97 -97
- package/src/script.ts +247 -247
- package/src/script_number.ts +72 -72
- package/src/script_signature.ts +91 -91
- package/src/transaction.ts +656 -656
- package/test/address.spec.ts +155 -155
- package/test/bitcoin.core.spec.ts +212 -212
- package/test/block.spec.ts +171 -171
- package/test/bufferutils.spec.ts +450 -450
- package/test/crypto.spec.ts +49 -49
- package/test/fixtures/address.json +329 -329
- package/test/fixtures/block.json +148 -148
- package/test/fixtures/bufferutils.json +102 -102
- package/test/fixtures/core/README.md +26 -26
- package/test/fixtures/core/base58_encode_decode.json +50 -50
- package/test/fixtures/core/base58_keys_invalid.json +152 -152
- package/test/fixtures/core/base58_keys_valid.json +452 -452
- package/test/fixtures/core/blocks.json +27 -27
- package/test/fixtures/core/sig_canonical.json +7 -7
- package/test/fixtures/core/sig_noncanonical.json +33 -33
- package/test/fixtures/core/sighash.json +3505 -3505
- package/test/fixtures/core/tx_valid.json +2023 -2023
- package/test/fixtures/crypto.json +43 -43
- package/test/fixtures/ecdsa.json +217 -217
- package/test/fixtures/ecpair.json +141 -141
- package/test/fixtures/embed.json +108 -108
- package/test/fixtures/p2ms.json +434 -434
- package/test/fixtures/p2pk.json +179 -179
- package/test/fixtures/p2pkh.json +276 -276
- package/test/fixtures/p2sh.json +508 -508
- package/test/fixtures/p2tr.json +1198 -1198
- package/test/fixtures/p2wpkh.json +290 -290
- package/test/fixtures/p2wsh.json +489 -489
- package/test/fixtures/psbt.json +924 -924
- package/test/fixtures/script.json +465 -465
- package/test/fixtures/script_number.json +225 -225
- package/test/fixtures/signature.json +140 -140
- package/test/fixtures/transaction.json +916 -916
- package/test/integration/_regtest.ts +6 -6
- package/test/integration/addresses.spec.ts +142 -142
- package/test/integration/bip32.spec.ts +130 -130
- package/test/integration/blocks.spec.ts +28 -28
- package/test/integration/cltv.spec.ts +241 -241
- package/test/integration/csv.spec.ts +452 -452
- package/test/integration/payments.spec.ts +110 -110
- package/test/integration/taproot.spec.ts +663 -663
- package/test/integration/transactions.spec.ts +668 -668
- package/test/payments.spec.ts +114 -114
- package/test/payments.utils.ts +165 -165
- package/test/psbt.spec.ts +1285 -1285
- package/test/script.spec.ts +186 -186
- package/test/script_number.spec.ts +26 -26
- package/test/script_signature.spec.ts +66 -66
- package/test/transaction.spec.ts +337 -337
- package/test/ts-node-register.js +7 -7
- package/test/tsconfig.json +48 -48
- package/test/types.spec.ts +53 -53
- package/tsconfig.base.json +27 -27
- package/tsconfig.json +19 -19
- package/tsconfig.webpack.json +18 -18
- package/vite.config.browser.ts +93 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/.ready +0 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/.release-please-manifest.json +0 -3
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/CHANGELOG.md +0 -962
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/CONTRIBUTING.md +0 -34
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/LICENSE +0 -24
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/README.md +0 -273
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/SECURITY.md +0 -2
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/addon.gypi +0 -204
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/bin/node-gyp.js +0 -138
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/.release-please-manifest.json +0 -3
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/LICENSE +0 -28
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/data/ninja/build.ninja +0 -4
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/data/win/large-pdb-shim.cc +0 -12
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/GypVsCMake.md +0 -116
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/Hacking.md +0 -46
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/InputFormatReference.md +0 -1080
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/LanguageSpecification.md +0 -430
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/README.md +0 -27
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/Testing.md +0 -450
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/UserDocumentation.md +0 -965
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/gyp +0 -8
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/gyp.bat +0 -5
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/gyp_main.py +0 -45
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +0 -365
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSProject.py +0 -206
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py +0 -1272
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py +0 -1547
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSToolFile.py +0 -59
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSUserFile.py +0 -153
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSUtil.py +0 -271
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +0 -574
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/__init__.py +0 -692
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/common.py +0 -711
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/common_test.py +0 -171
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py +0 -169
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py +0 -113
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/flock_tool.py +0 -55
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/__init__.py +0 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/analyzer.py +0 -804
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/android.py +0 -1173
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py +0 -1318
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/compile_commands_json.py +0 -127
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/dump_dependency_json.py +0 -103
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py +0 -461
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/gypd.py +0 -89
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/gypsh.py +0 -57
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +0 -2745
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py +0 -3976
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py +0 -44
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +0 -2964
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py +0 -67
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py +0 -1391
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode_test.py +0 -25
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/input.py +0 -3115
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/input_test.py +0 -98
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/mac_tool.py +0 -771
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py +0 -1260
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/ninja_syntax.py +0 -174
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py +0 -61
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/win_tool.py +0 -373
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py +0 -1938
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation_test.py +0 -53
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcode_ninja.py +0 -302
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +0 -3198
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xml_fix.py +0 -65
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/LICENSE +0 -3
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/LICENSE.APACHE +0 -177
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/LICENSE.BSD +0 -23
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/__init__.py +0 -15
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_elffile.py +0 -108
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_manylinux.py +0 -252
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_musllinux.py +0 -83
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_parser.py +0 -359
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_structures.py +0 -61
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_tokenizer.py +0 -192
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/markers.py +0 -252
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/metadata.py +0 -825
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/py.typed +0 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/requirements.py +0 -90
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/specifiers.py +0 -1030
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/tags.py +0 -553
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/utils.py +0 -172
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/version.py +0 -563
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pyproject.toml +0 -120
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/release-please-config.json +0 -11
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/test_gyp.py +0 -261
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/Find-VisualStudio.cs +0 -250
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/build.js +0 -227
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/clean.js +0 -15
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/configure.js +0 -328
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/create-config-gypi.js +0 -150
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/download.js +0 -39
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/find-node-directory.js +0 -63
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/find-python.js +0 -310
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/find-visualstudio.js +0 -590
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/install.js +0 -415
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/list.js +0 -26
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/log.js +0 -168
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/node-gyp.js +0 -188
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/process-release.js +0 -146
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/rebuild.js +0 -12
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/remove.js +0 -43
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/util.js +0 -81
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/macOS_Catalina_acid_test.sh +0 -21
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/package.json +0 -51
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/release-please-config.json +0 -40
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/src/win_delay_load_hook.cc +0 -39
- package/browser/index.js.LICENSE.txt +0 -14
- package/browser/ops.d.ts +0 -126
- package/build/ops.d.ts +0 -126
- package/build/ops.js +0 -127
- package/coverage/tmp/coverage-31752-1735543485354-0.json +0 -1
- package/coverage/tmp/coverage-59920-1735543484555-0.json +0 -1
- package/coverage/tmp/coverage-66252-1735543483919-0.json +0 -1
- package/coverage/tmp/coverage-68440-1735543485236-0.json +0 -1
- package/coverage/tmp/coverage-70588-1735543484426-0.json +0 -1
- package/coverage/tmp/coverage-79292-1735543485296-0.json +0 -1
- package/coverage/tmp/coverage-80212-1735543483980-0.json +0 -1
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2011 Google Inc. All rights reserved.
|
|
2
|
-
# Use of this source code is governed by a BSD-style license that can be
|
|
3
|
-
# found in the LICENSE file.
|
|
4
|
-
|
|
5
|
-
"""Applies a fix to CR LF TAB handling in xml.dom.
|
|
6
|
-
|
|
7
|
-
Fixes this: http://code.google.com/p/chromium/issues/detail?id=76293
|
|
8
|
-
Working around this: http://bugs.python.org/issue5752
|
|
9
|
-
TODO(bradnelson): Consider dropping this when we drop XP support.
|
|
10
|
-
"""
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import xml.dom.minidom
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def _Replacement_write_data(writer, data, is_attrib=False):
|
|
17
|
-
"""Writes datachars to writer."""
|
|
18
|
-
data = data.replace("&", "&").replace("<", "<")
|
|
19
|
-
data = data.replace('"', """).replace(">", ">")
|
|
20
|
-
if is_attrib:
|
|
21
|
-
data = data.replace("\r", "
").replace("\n", "
").replace("\t", "	")
|
|
22
|
-
writer.write(data)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def _Replacement_writexml(self, writer, indent="", addindent="", newl=""):
|
|
26
|
-
# indent = current indentation
|
|
27
|
-
# addindent = indentation to add to higher levels
|
|
28
|
-
# newl = newline string
|
|
29
|
-
writer.write(indent + "<" + self.tagName)
|
|
30
|
-
|
|
31
|
-
attrs = self._get_attributes()
|
|
32
|
-
a_names = sorted(attrs.keys())
|
|
33
|
-
|
|
34
|
-
for a_name in a_names:
|
|
35
|
-
writer.write(' %s="' % a_name)
|
|
36
|
-
_Replacement_write_data(writer, attrs[a_name].value, is_attrib=True)
|
|
37
|
-
writer.write('"')
|
|
38
|
-
if self.childNodes:
|
|
39
|
-
writer.write(">%s" % newl)
|
|
40
|
-
for node in self.childNodes:
|
|
41
|
-
node.writexml(writer, indent + addindent, addindent, newl)
|
|
42
|
-
writer.write(f"{indent}</{self.tagName}>{newl}")
|
|
43
|
-
else:
|
|
44
|
-
writer.write("/>%s" % newl)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
class XmlFix:
|
|
48
|
-
"""Object to manage temporary patching of xml.dom.minidom."""
|
|
49
|
-
|
|
50
|
-
def __init__(self):
|
|
51
|
-
# Preserve current xml.dom.minidom functions.
|
|
52
|
-
self.write_data = xml.dom.minidom._write_data
|
|
53
|
-
self.writexml = xml.dom.minidom.Element.writexml
|
|
54
|
-
# Inject replacement versions of a function and a method.
|
|
55
|
-
xml.dom.minidom._write_data = _Replacement_write_data
|
|
56
|
-
xml.dom.minidom.Element.writexml = _Replacement_writexml
|
|
57
|
-
|
|
58
|
-
def Cleanup(self):
|
|
59
|
-
if self.write_data:
|
|
60
|
-
xml.dom.minidom._write_data = self.write_data
|
|
61
|
-
xml.dom.minidom.Element.writexml = self.writexml
|
|
62
|
-
self.write_data = None
|
|
63
|
-
|
|
64
|
-
def __del__(self):
|
|
65
|
-
self.Cleanup()
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
Apache License
|
|
3
|
-
Version 2.0, January 2004
|
|
4
|
-
http://www.apache.org/licenses/
|
|
5
|
-
|
|
6
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
-
|
|
8
|
-
1. Definitions.
|
|
9
|
-
|
|
10
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
-
|
|
13
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
-
the copyright owner that is granting the License.
|
|
15
|
-
|
|
16
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
-
other entities that control, are controlled by, or are under common
|
|
18
|
-
control with that entity. For the purposes of this definition,
|
|
19
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
-
direction or management of such entity, whether by contract or
|
|
21
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
-
|
|
24
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
-
exercising permissions granted by this License.
|
|
26
|
-
|
|
27
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
-
including but not limited to software source code, documentation
|
|
29
|
-
source, and configuration files.
|
|
30
|
-
|
|
31
|
-
"Object" form shall mean any form resulting from mechanical
|
|
32
|
-
transformation or translation of a Source form, including but
|
|
33
|
-
not limited to compiled object code, generated documentation,
|
|
34
|
-
and conversions to other media types.
|
|
35
|
-
|
|
36
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
-
Object form, made available under the License, as indicated by a
|
|
38
|
-
copyright notice that is included in or attached to the work
|
|
39
|
-
(an example is provided in the Appendix below).
|
|
40
|
-
|
|
41
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
-
form, that is based on (or derived from) the Work and for which the
|
|
43
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
-
of this License, Derivative Works shall not include works that remain
|
|
46
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
-
the Work and Derivative Works thereof.
|
|
48
|
-
|
|
49
|
-
"Contribution" shall mean any work of authorship, including
|
|
50
|
-
the original version of the Work and any modifications or additions
|
|
51
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
-
means any form of electronic, verbal, or written communication sent
|
|
56
|
-
to the Licensor or its representatives, including but not limited to
|
|
57
|
-
communication on electronic mailing lists, source code control systems,
|
|
58
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
-
excluding communication that is conspicuously marked or otherwise
|
|
61
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
-
|
|
63
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
-
subsequently incorporated within the Work.
|
|
66
|
-
|
|
67
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
-
Work and such Derivative Works in Source or Object form.
|
|
73
|
-
|
|
74
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
-
(except as stated in this section) patent license to make, have made,
|
|
78
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
-
where such license applies only to those patent claims licensable
|
|
80
|
-
by such Contributor that are necessarily infringed by their
|
|
81
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
-
institute patent litigation against any entity (including a
|
|
84
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
-
or contributory patent infringement, then any patent licenses
|
|
87
|
-
granted to You under this License for that Work shall terminate
|
|
88
|
-
as of the date such litigation is filed.
|
|
89
|
-
|
|
90
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
-
modifications, and in Source or Object form, provided that You
|
|
93
|
-
meet the following conditions:
|
|
94
|
-
|
|
95
|
-
(a) You must give any other recipients of the Work or
|
|
96
|
-
Derivative Works a copy of this License; and
|
|
97
|
-
|
|
98
|
-
(b) You must cause any modified files to carry prominent notices
|
|
99
|
-
stating that You changed the files; and
|
|
100
|
-
|
|
101
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
-
that You distribute, all copyright, patent, trademark, and
|
|
103
|
-
attribution notices from the Source form of the Work,
|
|
104
|
-
excluding those notices that do not pertain to any part of
|
|
105
|
-
the Derivative Works; and
|
|
106
|
-
|
|
107
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
-
distribution, then any Derivative Works that You distribute must
|
|
109
|
-
include a readable copy of the attribution notices contained
|
|
110
|
-
within such NOTICE file, excluding those notices that do not
|
|
111
|
-
pertain to any part of the Derivative Works, in at least one
|
|
112
|
-
of the following places: within a NOTICE text file distributed
|
|
113
|
-
as part of the Derivative Works; within the Source form or
|
|
114
|
-
documentation, if provided along with the Derivative Works; or,
|
|
115
|
-
within a display generated by the Derivative Works, if and
|
|
116
|
-
wherever such third-party notices normally appear. The contents
|
|
117
|
-
of the NOTICE file are for informational purposes only and
|
|
118
|
-
do not modify the License. You may add Your own attribution
|
|
119
|
-
notices within Derivative Works that You distribute, alongside
|
|
120
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
-
that such additional attribution notices cannot be construed
|
|
122
|
-
as modifying the License.
|
|
123
|
-
|
|
124
|
-
You may add Your own copyright statement to Your modifications and
|
|
125
|
-
may provide additional or different license terms and conditions
|
|
126
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
-
the conditions stated in this License.
|
|
130
|
-
|
|
131
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
-
this License, without any additional terms or conditions.
|
|
135
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
-
the terms of any separate license agreement you may have executed
|
|
137
|
-
with Licensor regarding such Contributions.
|
|
138
|
-
|
|
139
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
-
except as required for reasonable and customary use in describing the
|
|
142
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
-
|
|
144
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
-
implied, including, without limitation, any warranties or conditions
|
|
149
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
-
appropriateness of using or redistributing the Work and assume any
|
|
152
|
-
risks associated with Your exercise of permissions under this License.
|
|
153
|
-
|
|
154
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
-
unless required by applicable law (such as deliberate and grossly
|
|
157
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
-
liable to You for damages, including any direct, indirect, special,
|
|
159
|
-
incidental, or consequential damages of any character arising as a
|
|
160
|
-
result of this License or out of the use or inability to use the
|
|
161
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
-
other commercial damages or losses), even if such Contributor
|
|
164
|
-
has been advised of the possibility of such damages.
|
|
165
|
-
|
|
166
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
-
or other liability obligations and/or rights consistent with this
|
|
170
|
-
License. However, in accepting such obligations, You may act only
|
|
171
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
-
defend, and hold each Contributor harmless for any liability
|
|
174
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
-
of your accepting any such warranty or additional liability.
|
|
176
|
-
|
|
177
|
-
END OF TERMS AND CONDITIONS
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
Copyright (c) Donald Stufft and individual contributors.
|
|
2
|
-
All rights reserved.
|
|
3
|
-
|
|
4
|
-
Redistribution and use in source and binary forms, with or without
|
|
5
|
-
modification, are permitted provided that the following conditions are met:
|
|
6
|
-
|
|
7
|
-
1. Redistributions of source code must retain the above copyright notice,
|
|
8
|
-
this list of conditions and the following disclaimer.
|
|
9
|
-
|
|
10
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
11
|
-
notice, this list of conditions and the following disclaimer in the
|
|
12
|
-
documentation and/or other materials provided with the distribution.
|
|
13
|
-
|
|
14
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
15
|
-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
16
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
17
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
18
|
-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
19
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
20
|
-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
21
|
-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
22
|
-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
23
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -1,15 +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
|
-
__title__ = "packaging"
|
|
6
|
-
__summary__ = "Core utilities for Python packages"
|
|
7
|
-
__uri__ = "https://github.com/pypa/packaging"
|
|
8
|
-
|
|
9
|
-
__version__ = "23.3.dev0"
|
|
10
|
-
|
|
11
|
-
__author__ = "Donald Stufft and individual contributors"
|
|
12
|
-
__email__ = "donald@stufft.io"
|
|
13
|
-
|
|
14
|
-
__license__ = "BSD-2-Clause or Apache-2.0"
|
|
15
|
-
__copyright__ = "2014 %s" % __author__
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
ELF file parser.
|
|
3
|
-
|
|
4
|
-
This provides a class ``ELFFile`` that parses an ELF executable in a similar
|
|
5
|
-
interface to ``ZipFile``. Only the read interface is implemented.
|
|
6
|
-
|
|
7
|
-
Based on: https://gist.github.com/lyssdod/f51579ae8d93c8657a5564aefc2ffbca
|
|
8
|
-
ELF header: https://refspecs.linuxfoundation.org/elf/gabi4+/ch4.eheader.html
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
import enum
|
|
12
|
-
import os
|
|
13
|
-
import struct
|
|
14
|
-
from typing import IO, Optional, Tuple
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class ELFInvalid(ValueError):
|
|
18
|
-
pass
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class EIClass(enum.IntEnum):
|
|
22
|
-
C32 = 1
|
|
23
|
-
C64 = 2
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
class EIData(enum.IntEnum):
|
|
27
|
-
Lsb = 1
|
|
28
|
-
Msb = 2
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
class EMachine(enum.IntEnum):
|
|
32
|
-
I386 = 3
|
|
33
|
-
S390 = 22
|
|
34
|
-
Arm = 40
|
|
35
|
-
X8664 = 62
|
|
36
|
-
AArc64 = 183
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
class ELFFile:
|
|
40
|
-
"""
|
|
41
|
-
Representation of an ELF executable.
|
|
42
|
-
"""
|
|
43
|
-
|
|
44
|
-
def __init__(self, f: IO[bytes]) -> None:
|
|
45
|
-
self._f = f
|
|
46
|
-
|
|
47
|
-
try:
|
|
48
|
-
ident = self._read("16B")
|
|
49
|
-
except struct.error:
|
|
50
|
-
raise ELFInvalid("unable to parse identification")
|
|
51
|
-
magic = bytes(ident[:4])
|
|
52
|
-
if magic != b"\x7fELF":
|
|
53
|
-
raise ELFInvalid(f"invalid magic: {magic!r}")
|
|
54
|
-
|
|
55
|
-
self.capacity = ident[4] # Format for program header (bitness).
|
|
56
|
-
self.encoding = ident[5] # Data structure encoding (endianness).
|
|
57
|
-
|
|
58
|
-
try:
|
|
59
|
-
# e_fmt: Format for program header.
|
|
60
|
-
# p_fmt: Format for section header.
|
|
61
|
-
# p_idx: Indexes to find p_type, p_offset, and p_filesz.
|
|
62
|
-
e_fmt, self._p_fmt, self._p_idx = {
|
|
63
|
-
(1, 1): ("<HHIIIIIHHH", "<IIIIIIII", (0, 1, 4)), # 32-bit LSB.
|
|
64
|
-
(1, 2): (">HHIIIIIHHH", ">IIIIIIII", (0, 1, 4)), # 32-bit MSB.
|
|
65
|
-
(2, 1): ("<HHIQQQIHHH", "<IIQQQQQQ", (0, 2, 5)), # 64-bit LSB.
|
|
66
|
-
(2, 2): (">HHIQQQIHHH", ">IIQQQQQQ", (0, 2, 5)), # 64-bit MSB.
|
|
67
|
-
}[(self.capacity, self.encoding)]
|
|
68
|
-
except KeyError:
|
|
69
|
-
raise ELFInvalid(
|
|
70
|
-
f"unrecognized capacity ({self.capacity}) or "
|
|
71
|
-
f"encoding ({self.encoding})"
|
|
72
|
-
)
|
|
73
|
-
|
|
74
|
-
try:
|
|
75
|
-
(
|
|
76
|
-
_,
|
|
77
|
-
self.machine, # Architecture type.
|
|
78
|
-
_,
|
|
79
|
-
_,
|
|
80
|
-
self._e_phoff, # Offset of program header.
|
|
81
|
-
_,
|
|
82
|
-
self.flags, # Processor-specific flags.
|
|
83
|
-
_,
|
|
84
|
-
self._e_phentsize, # Size of section.
|
|
85
|
-
self._e_phnum, # Number of sections.
|
|
86
|
-
) = self._read(e_fmt)
|
|
87
|
-
except struct.error as e:
|
|
88
|
-
raise ELFInvalid("unable to parse machine and section information") from e
|
|
89
|
-
|
|
90
|
-
def _read(self, fmt: str) -> Tuple[int, ...]:
|
|
91
|
-
return struct.unpack(fmt, self._f.read(struct.calcsize(fmt)))
|
|
92
|
-
|
|
93
|
-
@property
|
|
94
|
-
def interpreter(self) -> Optional[str]:
|
|
95
|
-
"""
|
|
96
|
-
The path recorded in the ``PT_INTERP`` section header.
|
|
97
|
-
"""
|
|
98
|
-
for index in range(self._e_phnum):
|
|
99
|
-
self._f.seek(self._e_phoff + self._e_phentsize * index)
|
|
100
|
-
try:
|
|
101
|
-
data = self._read(self._p_fmt)
|
|
102
|
-
except struct.error:
|
|
103
|
-
continue
|
|
104
|
-
if data[self._p_idx[0]] != 3: # Not PT_INTERP.
|
|
105
|
-
continue
|
|
106
|
-
self._f.seek(data[self._p_idx[1]])
|
|
107
|
-
return os.fsdecode(self._f.read(data[self._p_idx[2]])).strip("\0")
|
|
108
|
-
return None
|
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import collections
|
|
2
|
-
import contextlib
|
|
3
|
-
import functools
|
|
4
|
-
import os
|
|
5
|
-
import re
|
|
6
|
-
import sys
|
|
7
|
-
import warnings
|
|
8
|
-
from typing import Dict, Generator, Iterator, NamedTuple, Optional, Sequence, Tuple
|
|
9
|
-
|
|
10
|
-
from ._elffile import EIClass, EIData, ELFFile, EMachine
|
|
11
|
-
|
|
12
|
-
EF_ARM_ABIMASK = 0xFF000000
|
|
13
|
-
EF_ARM_ABI_VER5 = 0x05000000
|
|
14
|
-
EF_ARM_ABI_FLOAT_HARD = 0x00000400
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
# `os.PathLike` not a generic type until Python 3.9, so sticking with `str`
|
|
18
|
-
# as the type for `path` until then.
|
|
19
|
-
@contextlib.contextmanager
|
|
20
|
-
def _parse_elf(path: str) -> Generator[Optional[ELFFile], None, None]:
|
|
21
|
-
try:
|
|
22
|
-
with open(path, "rb") as f:
|
|
23
|
-
yield ELFFile(f)
|
|
24
|
-
except (OSError, TypeError, ValueError):
|
|
25
|
-
yield None
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def _is_linux_armhf(executable: str) -> bool:
|
|
29
|
-
# hard-float ABI can be detected from the ELF header of the running
|
|
30
|
-
# process
|
|
31
|
-
# https://static.docs.arm.com/ihi0044/g/aaelf32.pdf
|
|
32
|
-
with _parse_elf(executable) as f:
|
|
33
|
-
return (
|
|
34
|
-
f is not None
|
|
35
|
-
and f.capacity == EIClass.C32
|
|
36
|
-
and f.encoding == EIData.Lsb
|
|
37
|
-
and f.machine == EMachine.Arm
|
|
38
|
-
and f.flags & EF_ARM_ABIMASK == EF_ARM_ABI_VER5
|
|
39
|
-
and f.flags & EF_ARM_ABI_FLOAT_HARD == EF_ARM_ABI_FLOAT_HARD
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
def _is_linux_i686(executable: str) -> bool:
|
|
44
|
-
with _parse_elf(executable) as f:
|
|
45
|
-
return (
|
|
46
|
-
f is not None
|
|
47
|
-
and f.capacity == EIClass.C32
|
|
48
|
-
and f.encoding == EIData.Lsb
|
|
49
|
-
and f.machine == EMachine.I386
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
def _have_compatible_abi(executable: str, archs: Sequence[str]) -> bool:
|
|
54
|
-
if "armv7l" in archs:
|
|
55
|
-
return _is_linux_armhf(executable)
|
|
56
|
-
if "i686" in archs:
|
|
57
|
-
return _is_linux_i686(executable)
|
|
58
|
-
allowed_archs = {"x86_64", "aarch64", "ppc64", "ppc64le", "s390x", "loongarch64"}
|
|
59
|
-
return any(arch in allowed_archs for arch in archs)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
# If glibc ever changes its major version, we need to know what the last
|
|
63
|
-
# minor version was, so we can build the complete list of all versions.
|
|
64
|
-
# For now, guess what the highest minor version might be, assume it will
|
|
65
|
-
# be 50 for testing. Once this actually happens, update the dictionary
|
|
66
|
-
# with the actual value.
|
|
67
|
-
_LAST_GLIBC_MINOR: Dict[int, int] = collections.defaultdict(lambda: 50)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
class _GLibCVersion(NamedTuple):
|
|
71
|
-
major: int
|
|
72
|
-
minor: int
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
def _glibc_version_string_confstr() -> Optional[str]:
|
|
76
|
-
"""
|
|
77
|
-
Primary implementation of glibc_version_string using os.confstr.
|
|
78
|
-
"""
|
|
79
|
-
# os.confstr is quite a bit faster than ctypes.DLL. It's also less likely
|
|
80
|
-
# to be broken or missing. This strategy is used in the standard library
|
|
81
|
-
# platform module.
|
|
82
|
-
# https://github.com/python/cpython/blob/fcf1d003bf4f0100c/Lib/platform.py#L175-L183
|
|
83
|
-
try:
|
|
84
|
-
# Should be a string like "glibc 2.17".
|
|
85
|
-
version_string: str = getattr(os, "confstr")("CS_GNU_LIBC_VERSION")
|
|
86
|
-
assert version_string is not None
|
|
87
|
-
_, version = version_string.rsplit()
|
|
88
|
-
except (AssertionError, AttributeError, OSError, ValueError):
|
|
89
|
-
# os.confstr() or CS_GNU_LIBC_VERSION not available (or a bad value)...
|
|
90
|
-
return None
|
|
91
|
-
return version
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
def _glibc_version_string_ctypes() -> Optional[str]:
|
|
95
|
-
"""
|
|
96
|
-
Fallback implementation of glibc_version_string using ctypes.
|
|
97
|
-
"""
|
|
98
|
-
try:
|
|
99
|
-
import ctypes
|
|
100
|
-
except ImportError:
|
|
101
|
-
return None
|
|
102
|
-
|
|
103
|
-
# ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen
|
|
104
|
-
# manpage says, "If filename is NULL, then the returned handle is for the
|
|
105
|
-
# main program". This way we can let the linker do the work to figure out
|
|
106
|
-
# which libc our process is actually using.
|
|
107
|
-
#
|
|
108
|
-
# We must also handle the special case where the executable is not a
|
|
109
|
-
# dynamically linked executable. This can occur when using musl libc,
|
|
110
|
-
# for example. In this situation, dlopen() will error, leading to an
|
|
111
|
-
# OSError. Interestingly, at least in the case of musl, there is no
|
|
112
|
-
# errno set on the OSError. The single string argument used to construct
|
|
113
|
-
# OSError comes from libc itself and is therefore not portable to
|
|
114
|
-
# hard code here. In any case, failure to call dlopen() means we
|
|
115
|
-
# can proceed, so we bail on our attempt.
|
|
116
|
-
try:
|
|
117
|
-
process_namespace = ctypes.CDLL(None)
|
|
118
|
-
except OSError:
|
|
119
|
-
return None
|
|
120
|
-
|
|
121
|
-
try:
|
|
122
|
-
gnu_get_libc_version = process_namespace.gnu_get_libc_version
|
|
123
|
-
except AttributeError:
|
|
124
|
-
# Symbol doesn't exist -> therefore, we are not linked to
|
|
125
|
-
# glibc.
|
|
126
|
-
return None
|
|
127
|
-
|
|
128
|
-
# Call gnu_get_libc_version, which returns a string like "2.5"
|
|
129
|
-
gnu_get_libc_version.restype = ctypes.c_char_p
|
|
130
|
-
version_str: str = gnu_get_libc_version()
|
|
131
|
-
# py2 / py3 compatibility:
|
|
132
|
-
if not isinstance(version_str, str):
|
|
133
|
-
version_str = version_str.decode("ascii")
|
|
134
|
-
|
|
135
|
-
return version_str
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
def _glibc_version_string() -> Optional[str]:
|
|
139
|
-
"""Returns glibc version string, or None if not using glibc."""
|
|
140
|
-
return _glibc_version_string_confstr() or _glibc_version_string_ctypes()
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
def _parse_glibc_version(version_str: str) -> Tuple[int, int]:
|
|
144
|
-
"""Parse glibc version.
|
|
145
|
-
|
|
146
|
-
We use a regexp instead of str.split because we want to discard any
|
|
147
|
-
random junk that might come after the minor version -- this might happen
|
|
148
|
-
in patched/forked versions of glibc (e.g. Linaro's version of glibc
|
|
149
|
-
uses version strings like "2.20-2014.11"). See gh-3588.
|
|
150
|
-
"""
|
|
151
|
-
m = re.match(r"(?P<major>[0-9]+)\.(?P<minor>[0-9]+)", version_str)
|
|
152
|
-
if not m:
|
|
153
|
-
warnings.warn(
|
|
154
|
-
f"Expected glibc version with 2 components major.minor,"
|
|
155
|
-
f" got: {version_str}",
|
|
156
|
-
RuntimeWarning,
|
|
157
|
-
)
|
|
158
|
-
return -1, -1
|
|
159
|
-
return int(m.group("major")), int(m.group("minor"))
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
@functools.lru_cache()
|
|
163
|
-
def _get_glibc_version() -> Tuple[int, int]:
|
|
164
|
-
version_str = _glibc_version_string()
|
|
165
|
-
if version_str is None:
|
|
166
|
-
return (-1, -1)
|
|
167
|
-
return _parse_glibc_version(version_str)
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
# From PEP 513, PEP 600
|
|
171
|
-
def _is_compatible(arch: str, version: _GLibCVersion) -> bool:
|
|
172
|
-
sys_glibc = _get_glibc_version()
|
|
173
|
-
if sys_glibc < version:
|
|
174
|
-
return False
|
|
175
|
-
# Check for presence of _manylinux module.
|
|
176
|
-
try:
|
|
177
|
-
import _manylinux # noqa
|
|
178
|
-
except ImportError:
|
|
179
|
-
return True
|
|
180
|
-
if hasattr(_manylinux, "manylinux_compatible"):
|
|
181
|
-
result = _manylinux.manylinux_compatible(version[0], version[1], arch)
|
|
182
|
-
if result is not None:
|
|
183
|
-
return bool(result)
|
|
184
|
-
return True
|
|
185
|
-
if version == _GLibCVersion(2, 5):
|
|
186
|
-
if hasattr(_manylinux, "manylinux1_compatible"):
|
|
187
|
-
return bool(_manylinux.manylinux1_compatible)
|
|
188
|
-
if version == _GLibCVersion(2, 12):
|
|
189
|
-
if hasattr(_manylinux, "manylinux2010_compatible"):
|
|
190
|
-
return bool(_manylinux.manylinux2010_compatible)
|
|
191
|
-
if version == _GLibCVersion(2, 17):
|
|
192
|
-
if hasattr(_manylinux, "manylinux2014_compatible"):
|
|
193
|
-
return bool(_manylinux.manylinux2014_compatible)
|
|
194
|
-
return True
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
_LEGACY_MANYLINUX_MAP = {
|
|
198
|
-
# CentOS 7 w/ glibc 2.17 (PEP 599)
|
|
199
|
-
(2, 17): "manylinux2014",
|
|
200
|
-
# CentOS 6 w/ glibc 2.12 (PEP 571)
|
|
201
|
-
(2, 12): "manylinux2010",
|
|
202
|
-
# CentOS 5 w/ glibc 2.5 (PEP 513)
|
|
203
|
-
(2, 5): "manylinux1",
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
def platform_tags(archs: Sequence[str]) -> Iterator[str]:
|
|
208
|
-
"""Generate manylinux tags compatible to the current platform.
|
|
209
|
-
|
|
210
|
-
:param archs: Sequence of compatible architectures.
|
|
211
|
-
The first one shall be the closest to the actual architecture and be the part of
|
|
212
|
-
platform tag after the ``linux_`` prefix, e.g. ``x86_64``.
|
|
213
|
-
The ``linux_`` prefix is assumed as a prerequisite for the current platform to
|
|
214
|
-
be manylinux-compatible.
|
|
215
|
-
|
|
216
|
-
:returns: An iterator of compatible manylinux tags.
|
|
217
|
-
"""
|
|
218
|
-
if not _have_compatible_abi(sys.executable, archs):
|
|
219
|
-
return
|
|
220
|
-
# Oldest glibc to be supported regardless of architecture is (2, 17).
|
|
221
|
-
too_old_glibc2 = _GLibCVersion(2, 16)
|
|
222
|
-
if set(archs) & {"x86_64", "i686"}:
|
|
223
|
-
# On x86/i686 also oldest glibc to be supported is (2, 5).
|
|
224
|
-
too_old_glibc2 = _GLibCVersion(2, 4)
|
|
225
|
-
current_glibc = _GLibCVersion(*_get_glibc_version())
|
|
226
|
-
glibc_max_list = [current_glibc]
|
|
227
|
-
# We can assume compatibility across glibc major versions.
|
|
228
|
-
# https://sourceware.org/bugzilla/show_bug.cgi?id=24636
|
|
229
|
-
#
|
|
230
|
-
# Build a list of maximum glibc versions so that we can
|
|
231
|
-
# output the canonical list of all glibc from current_glibc
|
|
232
|
-
# down to too_old_glibc2, including all intermediary versions.
|
|
233
|
-
for glibc_major in range(current_glibc.major - 1, 1, -1):
|
|
234
|
-
glibc_minor = _LAST_GLIBC_MINOR[glibc_major]
|
|
235
|
-
glibc_max_list.append(_GLibCVersion(glibc_major, glibc_minor))
|
|
236
|
-
for arch in archs:
|
|
237
|
-
for glibc_max in glibc_max_list:
|
|
238
|
-
if glibc_max.major == too_old_glibc2.major:
|
|
239
|
-
min_minor = too_old_glibc2.minor
|
|
240
|
-
else:
|
|
241
|
-
# For other glibc major versions oldest supported is (x, 0).
|
|
242
|
-
min_minor = -1
|
|
243
|
-
for glibc_minor in range(glibc_max.minor, min_minor, -1):
|
|
244
|
-
glibc_version = _GLibCVersion(glibc_max.major, glibc_minor)
|
|
245
|
-
tag = "manylinux_{}_{}".format(*glibc_version)
|
|
246
|
-
if _is_compatible(arch, glibc_version):
|
|
247
|
-
yield f"{tag}_{arch}"
|
|
248
|
-
# Handle the legacy manylinux1, manylinux2010, manylinux2014 tags.
|
|
249
|
-
if glibc_version in _LEGACY_MANYLINUX_MAP:
|
|
250
|
-
legacy_tag = _LEGACY_MANYLINUX_MAP[glibc_version]
|
|
251
|
-
if _is_compatible(arch, glibc_version):
|
|
252
|
-
yield f"{legacy_tag}_{arch}"
|