@pnpm/exe 11.0.0-dev.1005 → 11.0.0-rc.0
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/dist/node-gyp-bin/node-gyp +6 -0
- package/dist/node-gyp-bin/node-gyp.cmd +5 -0
- package/dist/node_modules/@gar/promise-retry/LICENSE +20 -0
- package/dist/node_modules/@gar/promise-retry/lib/index.js +62 -0
- package/dist/node_modules/@gar/promise-retry/lib/retry.js +109 -0
- package/dist/node_modules/@gar/promise-retry/package.json +45 -0
- package/dist/node_modules/@isaacs/fs-minipass/LICENSE +15 -0
- package/dist/node_modules/@isaacs/fs-minipass/dist/commonjs/index.js +430 -0
- package/dist/node_modules/@isaacs/fs-minipass/dist/commonjs/package.json +3 -0
- package/dist/node_modules/@isaacs/fs-minipass/dist/esm/index.js +420 -0
- package/dist/node_modules/@isaacs/fs-minipass/dist/esm/package.json +3 -0
- package/dist/node_modules/@isaacs/fs-minipass/package.json +72 -0
- package/dist/node_modules/@npmcli/agent/lib/agents.js +206 -0
- package/dist/node_modules/@npmcli/agent/lib/dns.js +53 -0
- package/dist/node_modules/@npmcli/agent/lib/errors.js +61 -0
- package/dist/node_modules/@npmcli/agent/lib/index.js +56 -0
- package/dist/node_modules/@npmcli/agent/lib/options.js +86 -0
- package/dist/node_modules/@npmcli/agent/lib/proxy.js +88 -0
- package/dist/node_modules/@npmcli/agent/package.json +60 -0
- package/dist/node_modules/@npmcli/fs/lib/common/get-options.js +20 -0
- package/dist/node_modules/@npmcli/fs/lib/common/node.js +9 -0
- package/dist/node_modules/@npmcli/fs/lib/cp/LICENSE +15 -0
- package/dist/node_modules/@npmcli/fs/lib/cp/errors.js +129 -0
- package/dist/node_modules/@npmcli/fs/lib/cp/index.js +22 -0
- package/dist/node_modules/@npmcli/fs/lib/cp/polyfill.js +428 -0
- package/dist/node_modules/@npmcli/fs/lib/index.js +13 -0
- package/dist/node_modules/@npmcli/fs/lib/move-file.js +78 -0
- package/dist/node_modules/@npmcli/fs/lib/readdir-scoped.js +20 -0
- package/dist/node_modules/@npmcli/fs/lib/with-temp-dir.js +39 -0
- package/dist/node_modules/@npmcli/fs/package.json +54 -0
- package/dist/node_modules/@npmcli/redact/LICENSE +21 -0
- package/dist/node_modules/@npmcli/redact/lib/deep-map.js +71 -0
- package/dist/node_modules/@npmcli/redact/lib/error.js +28 -0
- package/dist/node_modules/@npmcli/redact/lib/index.js +44 -0
- package/dist/node_modules/@npmcli/redact/lib/matchers.js +88 -0
- package/dist/node_modules/@npmcli/redact/lib/server.js +59 -0
- package/dist/node_modules/@npmcli/redact/lib/utils.js +202 -0
- package/dist/node_modules/@npmcli/redact/package.json +52 -0
- package/dist/node_modules/abbrev/LICENSE +46 -0
- package/dist/node_modules/abbrev/lib/index.js +53 -0
- package/dist/node_modules/abbrev/package.json +41 -0
- package/dist/node_modules/agent-base/LICENSE +22 -0
- package/dist/node_modules/agent-base/dist/helpers.js +66 -0
- package/dist/node_modules/agent-base/dist/index.js +178 -0
- package/dist/node_modules/agent-base/package.json +46 -0
- package/dist/node_modules/balanced-match/dist/commonjs/index.js +59 -0
- package/dist/node_modules/balanced-match/dist/commonjs/package.json +3 -0
- package/dist/node_modules/balanced-match/dist/esm/index.js +54 -0
- package/dist/node_modules/balanced-match/dist/esm/package.json +3 -0
- package/dist/node_modules/balanced-match/package.json +68 -0
- package/dist/node_modules/brace-expansion/LICENSE +23 -0
- package/dist/node_modules/brace-expansion/dist/commonjs/index.js +201 -0
- package/dist/node_modules/brace-expansion/dist/commonjs/package.json +3 -0
- package/dist/node_modules/brace-expansion/dist/esm/index.js +197 -0
- package/dist/node_modules/brace-expansion/dist/esm/package.json +3 -0
- package/dist/node_modules/brace-expansion/package.json +64 -0
- package/dist/node_modules/cacache/lib/content/path.js +29 -0
- package/dist/node_modules/cacache/lib/content/read.js +165 -0
- package/dist/node_modules/cacache/lib/content/rm.js +18 -0
- package/dist/node_modules/cacache/lib/content/write.js +206 -0
- package/dist/node_modules/cacache/lib/entry-index.js +336 -0
- package/dist/node_modules/cacache/lib/get.js +170 -0
- package/dist/node_modules/cacache/lib/index.js +42 -0
- package/dist/node_modules/cacache/lib/memoization.js +72 -0
- package/dist/node_modules/cacache/lib/put.js +80 -0
- package/dist/node_modules/cacache/lib/rm.js +31 -0
- package/dist/node_modules/cacache/lib/util/glob.js +7 -0
- package/dist/node_modules/cacache/lib/util/hash-to-segments.js +7 -0
- package/dist/node_modules/cacache/lib/util/tmp.js +32 -0
- package/dist/node_modules/cacache/lib/verify.js +258 -0
- package/dist/node_modules/cacache/package.json +81 -0
- package/dist/node_modules/chownr/dist/commonjs/index.js +93 -0
- package/dist/node_modules/chownr/dist/commonjs/package.json +3 -0
- package/dist/node_modules/chownr/dist/esm/index.js +85 -0
- package/dist/node_modules/chownr/dist/esm/package.json +3 -0
- package/dist/node_modules/chownr/package.json +69 -0
- package/dist/node_modules/debug/LICENSE +20 -0
- package/dist/node_modules/debug/package.json +64 -0
- package/dist/node_modules/debug/src/browser.js +272 -0
- package/dist/node_modules/debug/src/common.js +292 -0
- package/dist/node_modules/debug/src/index.js +10 -0
- package/dist/node_modules/debug/src/node.js +263 -0
- package/dist/node_modules/env-paths/index.js +74 -0
- package/dist/node_modules/env-paths/license +9 -0
- package/dist/node_modules/env-paths/package.json +45 -0
- package/dist/node_modules/exponential-backoff/LICENSE +202 -0
- package/dist/node_modules/exponential-backoff/dist/backoff.js +124 -0
- package/dist/node_modules/exponential-backoff/dist/delay/always/always.delay.js +25 -0
- package/dist/node_modules/exponential-backoff/dist/delay/delay.base.js +45 -0
- package/dist/node_modules/exponential-backoff/dist/delay/delay.factory.js +17 -0
- package/dist/node_modules/exponential-backoff/dist/delay/delay.interface.js +3 -0
- package/dist/node_modules/exponential-backoff/dist/delay/skip-first/skip-first.delay.js +82 -0
- package/dist/node_modules/exponential-backoff/dist/jitter/full/full.jitter.js +8 -0
- package/dist/node_modules/exponential-backoff/dist/jitter/jitter.factory.js +15 -0
- package/dist/node_modules/exponential-backoff/dist/jitter/no/no.jitter.js +7 -0
- package/dist/node_modules/exponential-backoff/dist/options.js +31 -0
- package/dist/node_modules/exponential-backoff/package.json +62 -0
- package/dist/node_modules/fdir/LICENSE +7 -0
- package/dist/node_modules/fdir/dist/index.cjs +588 -0
- package/dist/node_modules/fdir/dist/index.d.cts +155 -0
- package/dist/node_modules/fdir/dist/index.d.mts +155 -0
- package/dist/node_modules/fdir/dist/index.mjs +570 -0
- package/dist/node_modules/fdir/package.json +103 -0
- package/dist/node_modules/fs-minipass/LICENSE +15 -0
- package/dist/node_modules/fs-minipass/lib/index.js +443 -0
- package/dist/node_modules/fs-minipass/package.json +54 -0
- package/dist/node_modules/glob/dist/commonjs/glob.js +248 -0
- package/dist/node_modules/glob/dist/commonjs/has-magic.js +27 -0
- package/dist/node_modules/glob/dist/commonjs/ignore.js +119 -0
- package/dist/node_modules/glob/dist/commonjs/index.js +68 -0
- package/dist/node_modules/glob/dist/commonjs/index.min.js +4 -0
- package/dist/node_modules/glob/dist/commonjs/package.json +3 -0
- package/dist/node_modules/glob/dist/commonjs/pattern.js +223 -0
- package/dist/node_modules/glob/dist/commonjs/processor.js +301 -0
- package/dist/node_modules/glob/dist/commonjs/walker.js +387 -0
- package/dist/node_modules/glob/dist/esm/glob.js +244 -0
- package/dist/node_modules/glob/dist/esm/has-magic.js +23 -0
- package/dist/node_modules/glob/dist/esm/ignore.js +115 -0
- package/dist/node_modules/glob/dist/esm/index.js +55 -0
- package/dist/node_modules/glob/dist/esm/index.min.js +4 -0
- package/dist/node_modules/glob/dist/esm/package.json +3 -0
- package/dist/node_modules/glob/dist/esm/pattern.js +219 -0
- package/dist/node_modules/glob/dist/esm/processor.js +294 -0
- package/dist/node_modules/glob/dist/esm/walker.js +381 -0
- package/dist/node_modules/glob/package.json +98 -0
- package/dist/node_modules/graceful-fs/LICENSE +15 -0
- package/dist/node_modules/graceful-fs/clone.js +23 -0
- package/dist/node_modules/graceful-fs/graceful-fs.js +448 -0
- package/dist/node_modules/graceful-fs/legacy-streams.js +118 -0
- package/dist/node_modules/graceful-fs/package.json +53 -0
- package/dist/node_modules/graceful-fs/polyfills.js +355 -0
- package/dist/node_modules/http-cache-semantics/LICENSE +9 -0
- package/dist/node_modules/http-cache-semantics/index.js +928 -0
- package/dist/node_modules/http-cache-semantics/package.json +22 -0
- package/dist/node_modules/http-proxy-agent/LICENSE +22 -0
- package/dist/node_modules/http-proxy-agent/dist/index.js +148 -0
- package/dist/node_modules/http-proxy-agent/package.json +47 -0
- package/dist/node_modules/https-proxy-agent/LICENSE +22 -0
- package/dist/node_modules/https-proxy-agent/dist/index.js +180 -0
- package/dist/node_modules/https-proxy-agent/dist/parse-proxy-response.js +101 -0
- package/dist/node_modules/https-proxy-agent/package.json +50 -0
- package/dist/node_modules/iconv-lite/LICENSE +21 -0
- package/dist/node_modules/iconv-lite/encodings/dbcs-codec.js +532 -0
- package/dist/node_modules/iconv-lite/encodings/dbcs-data.js +185 -0
- package/dist/node_modules/iconv-lite/encodings/index.js +23 -0
- package/dist/node_modules/iconv-lite/encodings/internal.js +218 -0
- package/dist/node_modules/iconv-lite/encodings/sbcs-codec.js +75 -0
- package/dist/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
- package/dist/node_modules/iconv-lite/encodings/sbcs-data.js +178 -0
- package/dist/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
- package/dist/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
- package/dist/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
- package/dist/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
- package/dist/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
- package/dist/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
- package/dist/node_modules/iconv-lite/encodings/tables/gbk-added.json +56 -0
- package/dist/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
- package/dist/node_modules/iconv-lite/encodings/utf16.js +187 -0
- package/dist/node_modules/iconv-lite/encodings/utf32.js +307 -0
- package/dist/node_modules/iconv-lite/encodings/utf7.js +283 -0
- package/dist/node_modules/iconv-lite/lib/bom-handling.js +48 -0
- package/dist/node_modules/iconv-lite/lib/helpers/merge-exports.js +13 -0
- package/dist/node_modules/iconv-lite/lib/index.js +182 -0
- package/dist/node_modules/iconv-lite/lib/streams.js +105 -0
- package/dist/node_modules/iconv-lite/package.json +70 -0
- package/dist/node_modules/ip-address/LICENSE +19 -0
- package/dist/node_modules/ip-address/dist/address-error.js +12 -0
- package/dist/node_modules/ip-address/dist/common.js +46 -0
- package/dist/node_modules/ip-address/dist/ip-address.js +35 -0
- package/dist/node_modules/ip-address/dist/ipv4.js +360 -0
- package/dist/node_modules/ip-address/dist/ipv6.js +1003 -0
- package/dist/node_modules/ip-address/dist/v4/constants.js +8 -0
- package/dist/node_modules/ip-address/dist/v6/constants.js +76 -0
- package/dist/node_modules/ip-address/dist/v6/helpers.js +45 -0
- package/dist/node_modules/ip-address/dist/v6/regular-expressions.js +95 -0
- package/dist/node_modules/ip-address/package.json +78 -0
- package/dist/node_modules/isexe/dist/commonjs/index.js +56 -0
- package/dist/node_modules/isexe/dist/commonjs/index.min.js +2 -0
- package/dist/node_modules/isexe/dist/commonjs/options.js +3 -0
- package/dist/node_modules/isexe/dist/commonjs/package.json +3 -0
- package/dist/node_modules/isexe/dist/commonjs/posix.js +67 -0
- package/dist/node_modules/isexe/dist/commonjs/win32.js +63 -0
- package/dist/node_modules/isexe/dist/esm/index.js +16 -0
- package/dist/node_modules/isexe/dist/esm/index.min.js +2 -0
- package/dist/node_modules/isexe/dist/esm/options.js +2 -0
- package/dist/node_modules/isexe/dist/esm/package.json +3 -0
- package/dist/node_modules/isexe/dist/esm/posix.js +62 -0
- package/dist/node_modules/isexe/dist/esm/win32.js +58 -0
- package/dist/node_modules/isexe/package.json +78 -0
- package/dist/node_modules/lru-cache/dist/commonjs/index.js +1595 -0
- package/dist/node_modules/lru-cache/dist/commonjs/index.min.js +2 -0
- package/dist/node_modules/lru-cache/dist/commonjs/package.json +3 -0
- package/dist/node_modules/lru-cache/dist/esm/index.js +1591 -0
- package/dist/node_modules/lru-cache/dist/esm/index.min.js +2 -0
- package/dist/node_modules/lru-cache/dist/esm/package.json +3 -0
- package/dist/node_modules/lru-cache/package.json +93 -0
- package/dist/node_modules/make-fetch-happen/LICENSE +16 -0
- package/dist/node_modules/make-fetch-happen/lib/cache/entry.js +471 -0
- package/dist/node_modules/make-fetch-happen/lib/cache/errors.js +11 -0
- package/dist/node_modules/make-fetch-happen/lib/cache/index.js +49 -0
- package/dist/node_modules/make-fetch-happen/lib/cache/key.js +17 -0
- package/dist/node_modules/make-fetch-happen/lib/cache/policy.js +161 -0
- package/dist/node_modules/make-fetch-happen/lib/fetch.js +118 -0
- package/dist/node_modules/make-fetch-happen/lib/index.js +41 -0
- package/dist/node_modules/make-fetch-happen/lib/options.js +59 -0
- package/dist/node_modules/make-fetch-happen/lib/pipeline.js +41 -0
- package/dist/node_modules/make-fetch-happen/lib/remote.js +134 -0
- package/dist/node_modules/make-fetch-happen/package.json +75 -0
- package/dist/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js +14 -0
- package/dist/node_modules/minimatch/dist/commonjs/ast.js +846 -0
- package/dist/node_modules/minimatch/dist/commonjs/brace-expressions.js +150 -0
- package/dist/node_modules/minimatch/dist/commonjs/escape.js +30 -0
- package/dist/node_modules/minimatch/dist/commonjs/index.js +1121 -0
- package/dist/node_modules/minimatch/dist/commonjs/package.json +3 -0
- package/dist/node_modules/minimatch/dist/commonjs/unescape.js +38 -0
- package/dist/node_modules/minimatch/dist/esm/assert-valid-pattern.js +10 -0
- package/dist/node_modules/minimatch/dist/esm/ast.js +842 -0
- package/dist/node_modules/minimatch/dist/esm/brace-expressions.js +146 -0
- package/dist/node_modules/minimatch/dist/esm/escape.js +26 -0
- package/dist/node_modules/minimatch/dist/esm/index.js +1108 -0
- package/dist/node_modules/minimatch/dist/esm/package.json +3 -0
- package/dist/node_modules/minimatch/dist/esm/unescape.js +34 -0
- package/dist/node_modules/minimatch/package.json +67 -0
- package/dist/node_modules/minipass/dist/commonjs/index.js +1038 -0
- package/dist/node_modules/minipass/dist/commonjs/package.json +3 -0
- package/dist/node_modules/minipass/dist/esm/index.js +1020 -0
- package/dist/node_modules/minipass/dist/esm/package.json +3 -0
- package/dist/node_modules/minipass/package.json +77 -0
- package/dist/node_modules/minipass-collect/LICENSE +15 -0
- package/dist/node_modules/minipass-collect/index.js +71 -0
- package/dist/node_modules/minipass-collect/package.json +30 -0
- package/dist/node_modules/minipass-fetch/LICENSE +28 -0
- package/dist/node_modules/minipass-fetch/lib/abort-error.js +17 -0
- package/dist/node_modules/minipass-fetch/lib/blob.js +97 -0
- package/dist/node_modules/minipass-fetch/lib/body.js +360 -0
- package/dist/node_modules/minipass-fetch/lib/fetch-error.js +32 -0
- package/dist/node_modules/minipass-fetch/lib/headers.js +267 -0
- package/dist/node_modules/minipass-fetch/lib/index.js +376 -0
- package/dist/node_modules/minipass-fetch/lib/request.js +282 -0
- package/dist/node_modules/minipass-fetch/lib/response.js +90 -0
- package/dist/node_modules/minipass-fetch/package.json +70 -0
- package/dist/node_modules/minipass-flush/LICENSE +15 -0
- package/dist/node_modules/minipass-flush/index.js +39 -0
- package/dist/node_modules/minipass-flush/node_modules/minipass/LICENSE +15 -0
- package/dist/node_modules/minipass-flush/node_modules/minipass/index.js +649 -0
- package/dist/node_modules/minipass-flush/node_modules/minipass/package.json +56 -0
- package/dist/node_modules/minipass-flush/package.json +39 -0
- package/dist/node_modules/minipass-pipeline/LICENSE +15 -0
- package/dist/node_modules/minipass-pipeline/index.js +128 -0
- package/dist/node_modules/minipass-pipeline/node_modules/minipass/LICENSE +15 -0
- package/dist/node_modules/minipass-pipeline/node_modules/minipass/index.js +649 -0
- package/dist/node_modules/minipass-pipeline/node_modules/minipass/package.json +56 -0
- package/dist/node_modules/minipass-pipeline/package.json +29 -0
- package/dist/node_modules/minipass-sized/LICENSE +15 -0
- package/dist/node_modules/minipass-sized/dist/commonjs/index.js +69 -0
- package/dist/node_modules/minipass-sized/dist/commonjs/package.json +3 -0
- package/dist/node_modules/minipass-sized/dist/esm/index.js +64 -0
- package/dist/node_modules/minipass-sized/dist/esm/package.json +3 -0
- package/dist/node_modules/minipass-sized/package.json +69 -0
- package/dist/node_modules/minizlib/LICENSE +26 -0
- package/dist/node_modules/minizlib/dist/commonjs/constants.js +123 -0
- package/dist/node_modules/minizlib/dist/commonjs/index.js +416 -0
- package/dist/node_modules/minizlib/dist/commonjs/package.json +3 -0
- package/dist/node_modules/minizlib/dist/esm/constants.js +117 -0
- package/dist/node_modules/minizlib/dist/esm/index.js +363 -0
- package/dist/node_modules/minizlib/dist/esm/package.json +3 -0
- package/dist/node_modules/minizlib/package.json +80 -0
- package/dist/node_modules/ms/index.js +162 -0
- package/dist/node_modules/ms/package.json +38 -0
- package/dist/node_modules/negotiator/LICENSE +24 -0
- package/dist/node_modules/negotiator/index.js +83 -0
- package/dist/node_modules/negotiator/lib/charset.js +169 -0
- package/dist/node_modules/negotiator/lib/encoding.js +205 -0
- package/dist/node_modules/negotiator/lib/language.js +179 -0
- package/dist/node_modules/negotiator/lib/mediaType.js +294 -0
- package/dist/node_modules/negotiator/package.json +43 -0
- package/dist/node_modules/node-gyp/.release-please-manifest.json +3 -0
- package/dist/node_modules/node-gyp/LICENSE +24 -0
- package/dist/node_modules/node-gyp/addon.gypi +204 -0
- package/dist/node_modules/node-gyp/bin/node-gyp.js +145 -0
- package/dist/node_modules/node-gyp/eslint.config.js +3 -0
- package/dist/node_modules/node-gyp/gyp/.release-please-manifest.json +3 -0
- package/dist/node_modules/node-gyp/gyp/LICENSE +28 -0
- package/dist/node_modules/node-gyp/gyp/data/ninja/build.ninja +4 -0
- package/dist/node_modules/node-gyp/gyp/data/win/large-pdb-shim.cc +12 -0
- package/dist/node_modules/node-gyp/gyp/gyp +8 -0
- package/dist/node_modules/node-gyp/gyp/gyp.bat +5 -0
- package/dist/node_modules/node-gyp/gyp/gyp_main.py +45 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +365 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSProject.py +206 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py +1283 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py +1545 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSToolFile.py +59 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSUserFile.py +152 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSUtil.py +270 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +599 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/__init__.py +707 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/common.py +725 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/common_test.py +186 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py +170 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py +113 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/flock_tool.py +55 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/__init__.py +0 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/analyzer.py +805 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/android.py +1169 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py +1316 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/compile_commands_json.py +128 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/dump_dependency_json.py +104 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py +461 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/gypd.py +88 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/gypsh.py +55 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +2755 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py +3970 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py +44 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +2956 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py +67 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py +1389 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode_test.py +26 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/input.py +3097 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/input_test.py +99 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/mac_tool.py +765 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py +1255 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/ninja_syntax.py +174 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py +61 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/win_tool.py +371 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py +1936 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation_test.py +54 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/xcode_ninja.py +301 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +3180 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/xml_fix.py +64 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/LICENSE +3 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/LICENSE.APACHE +177 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/LICENSE.BSD +23 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/__init__.py +15 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/_elffile.py +107 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/_manylinux.py +252 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/_musllinux.py +83 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/_parser.py +359 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/_structures.py +61 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/_tokenizer.py +192 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/markers.py +251 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/metadata.py +824 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/py.typed +0 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/requirements.py +90 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/specifiers.py +1030 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/tags.py +553 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/utils.py +172 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/version.py +563 -0
- package/dist/node_modules/node-gyp/gyp/pyproject.toml +114 -0
- package/dist/node_modules/node-gyp/gyp/release-please-config.json +11 -0
- package/dist/node_modules/node-gyp/gyp/test_gyp.py +260 -0
- package/dist/node_modules/node-gyp/lib/Find-VisualStudio.cs +250 -0
- package/dist/node_modules/node-gyp/lib/build.js +230 -0
- package/dist/node_modules/node-gyp/lib/clean.js +15 -0
- package/dist/node_modules/node-gyp/lib/configure.js +328 -0
- package/dist/node_modules/node-gyp/lib/create-config-gypi.js +153 -0
- package/dist/node_modules/node-gyp/lib/download.js +39 -0
- package/dist/node_modules/node-gyp/lib/find-node-directory.js +63 -0
- package/dist/node_modules/node-gyp/lib/find-python.js +304 -0
- package/dist/node_modules/node-gyp/lib/find-visualstudio.js +606 -0
- package/dist/node_modules/node-gyp/lib/install.js +411 -0
- package/dist/node_modules/node-gyp/lib/list.js +26 -0
- package/dist/node_modules/node-gyp/lib/log.js +168 -0
- package/dist/node_modules/node-gyp/lib/node-gyp.js +199 -0
- package/dist/node_modules/node-gyp/lib/process-release.js +146 -0
- package/dist/node_modules/node-gyp/lib/rebuild.js +12 -0
- package/dist/node_modules/node-gyp/lib/remove.js +43 -0
- package/dist/node_modules/node-gyp/lib/util.js +81 -0
- package/dist/node_modules/node-gyp/macOS_Catalina_acid_test.sh +21 -0
- package/dist/node_modules/node-gyp/package.json +52 -0
- package/dist/node_modules/node-gyp/release-please-config.json +40 -0
- package/dist/node_modules/node-gyp/src/win_delay_load_hook.cc +41 -0
- package/dist/node_modules/nopt/LICENSE +15 -0
- package/dist/node_modules/nopt/bin/nopt.js +29 -0
- package/dist/node_modules/nopt/lib/debug.js +5 -0
- package/dist/node_modules/nopt/lib/nopt-lib.js +514 -0
- package/dist/node_modules/nopt/lib/nopt.js +34 -0
- package/dist/node_modules/nopt/lib/type-defs.js +91 -0
- package/dist/node_modules/nopt/package.json +52 -0
- package/dist/node_modules/p-map/index.js +283 -0
- package/dist/node_modules/p-map/license +9 -0
- package/dist/node_modules/p-map/package.json +57 -0
- package/dist/node_modules/path-scurry/dist/commonjs/index.js +2018 -0
- package/dist/node_modules/path-scurry/dist/commonjs/package.json +3 -0
- package/dist/node_modules/path-scurry/dist/esm/index.js +1983 -0
- package/dist/node_modules/path-scurry/dist/esm/package.json +3 -0
- package/dist/node_modules/path-scurry/package.json +72 -0
- package/dist/node_modules/picomatch/LICENSE +21 -0
- package/dist/node_modules/picomatch/index.js +17 -0
- package/dist/node_modules/picomatch/lib/constants.js +184 -0
- package/dist/node_modules/picomatch/lib/parse.js +1386 -0
- package/dist/node_modules/picomatch/lib/picomatch.js +349 -0
- package/dist/node_modules/picomatch/lib/scan.js +391 -0
- package/dist/node_modules/picomatch/lib/utils.js +72 -0
- package/dist/node_modules/picomatch/package.json +82 -0
- package/dist/node_modules/picomatch/posix.js +3 -0
- package/dist/node_modules/proc-log/LICENSE +15 -0
- package/dist/node_modules/proc-log/lib/index.js +158 -0
- package/dist/node_modules/proc-log/package.json +46 -0
- package/dist/node_modules/safer-buffer/LICENSE +21 -0
- package/dist/node_modules/safer-buffer/dangerous.js +58 -0
- package/dist/node_modules/safer-buffer/package.json +34 -0
- package/dist/node_modules/safer-buffer/safer.js +77 -0
- package/dist/node_modules/safer-buffer/tests.js +406 -0
- package/dist/node_modules/semver/LICENSE +15 -0
- package/dist/node_modules/semver/bin/semver.js +191 -0
- package/dist/node_modules/semver/classes/comparator.js +143 -0
- package/dist/node_modules/semver/classes/index.js +7 -0
- package/dist/node_modules/semver/classes/range.js +557 -0
- package/dist/node_modules/semver/classes/semver.js +333 -0
- package/dist/node_modules/semver/functions/clean.js +8 -0
- package/dist/node_modules/semver/functions/cmp.js +54 -0
- package/dist/node_modules/semver/functions/coerce.js +62 -0
- package/dist/node_modules/semver/functions/compare-build.js +9 -0
- package/dist/node_modules/semver/functions/compare-loose.js +5 -0
- package/dist/node_modules/semver/functions/compare.js +7 -0
- package/dist/node_modules/semver/functions/diff.js +60 -0
- package/dist/node_modules/semver/functions/eq.js +5 -0
- package/dist/node_modules/semver/functions/gt.js +5 -0
- package/dist/node_modules/semver/functions/gte.js +5 -0
- package/dist/node_modules/semver/functions/inc.js +21 -0
- package/dist/node_modules/semver/functions/lt.js +5 -0
- package/dist/node_modules/semver/functions/lte.js +5 -0
- package/dist/node_modules/semver/functions/major.js +5 -0
- package/dist/node_modules/semver/functions/minor.js +5 -0
- package/dist/node_modules/semver/functions/neq.js +5 -0
- package/dist/node_modules/semver/functions/parse.js +18 -0
- package/dist/node_modules/semver/functions/patch.js +5 -0
- package/dist/node_modules/semver/functions/prerelease.js +8 -0
- package/dist/node_modules/semver/functions/rcompare.js +5 -0
- package/dist/node_modules/semver/functions/rsort.js +5 -0
- package/dist/node_modules/semver/functions/satisfies.js +12 -0
- package/dist/node_modules/semver/functions/sort.js +5 -0
- package/dist/node_modules/semver/functions/valid.js +8 -0
- package/dist/node_modules/semver/index.js +91 -0
- package/dist/node_modules/semver/internal/constants.js +37 -0
- package/dist/node_modules/semver/internal/debug.js +11 -0
- package/dist/node_modules/semver/internal/identifiers.js +29 -0
- package/dist/node_modules/semver/internal/lrucache.js +42 -0
- package/dist/node_modules/semver/internal/parse-options.js +17 -0
- package/dist/node_modules/semver/internal/re.js +223 -0
- package/dist/node_modules/semver/package.json +78 -0
- package/dist/node_modules/semver/preload.js +4 -0
- package/dist/node_modules/semver/range.bnf +16 -0
- package/dist/node_modules/semver/ranges/gtr.js +6 -0
- package/dist/node_modules/semver/ranges/intersects.js +9 -0
- package/dist/node_modules/semver/ranges/ltr.js +6 -0
- package/dist/node_modules/semver/ranges/max-satisfying.js +27 -0
- package/dist/node_modules/semver/ranges/min-satisfying.js +26 -0
- package/dist/node_modules/semver/ranges/min-version.js +63 -0
- package/dist/node_modules/semver/ranges/outside.js +82 -0
- package/dist/node_modules/semver/ranges/simplify.js +49 -0
- package/dist/node_modules/semver/ranges/subset.js +249 -0
- package/dist/node_modules/semver/ranges/to-comparators.js +10 -0
- package/dist/node_modules/semver/ranges/valid.js +13 -0
- package/dist/node_modules/smart-buffer/.prettierrc.yaml +5 -0
- package/dist/node_modules/smart-buffer/LICENSE +20 -0
- package/dist/node_modules/smart-buffer/build/smartbuffer.js +1233 -0
- package/dist/node_modules/smart-buffer/build/utils.js +108 -0
- package/dist/node_modules/smart-buffer/package.json +79 -0
- package/dist/node_modules/socks/.eslintrc.cjs +11 -0
- package/dist/node_modules/socks/.prettierrc.yaml +7 -0
- package/dist/node_modules/socks/LICENSE +20 -0
- package/dist/node_modules/socks/build/client/socksclient.js +793 -0
- package/dist/node_modules/socks/build/common/constants.js +108 -0
- package/dist/node_modules/socks/build/common/helpers.js +167 -0
- package/dist/node_modules/socks/build/common/receivebuffer.js +43 -0
- package/dist/node_modules/socks/build/common/util.js +25 -0
- package/dist/node_modules/socks/build/index.js +18 -0
- package/dist/node_modules/socks/package.json +58 -0
- package/dist/node_modules/socks-proxy-agent/LICENSE +22 -0
- package/dist/node_modules/socks-proxy-agent/dist/index.js +195 -0
- package/dist/node_modules/socks-proxy-agent/package.json +142 -0
- package/dist/node_modules/ssri/lib/index.js +550 -0
- package/dist/node_modules/ssri/package.json +66 -0
- package/dist/node_modules/tar/dist/commonjs/create.js +82 -0
- package/dist/node_modules/tar/dist/commonjs/cwd-error.js +18 -0
- package/dist/node_modules/tar/dist/commonjs/extract.js +88 -0
- package/dist/node_modules/tar/dist/commonjs/get-write-flag.js +32 -0
- package/dist/node_modules/tar/dist/commonjs/header.js +312 -0
- package/dist/node_modules/tar/dist/commonjs/index.js +64 -0
- package/dist/node_modules/tar/dist/commonjs/index.min.js +4 -0
- package/dist/node_modules/tar/dist/commonjs/large-numbers.js +99 -0
- package/dist/node_modules/tar/dist/commonjs/list.js +145 -0
- package/dist/node_modules/tar/dist/commonjs/make-command.js +52 -0
- package/dist/node_modules/tar/dist/commonjs/mkdir.js +187 -0
- package/dist/node_modules/tar/dist/commonjs/mode-fix.js +29 -0
- package/dist/node_modules/tar/dist/commonjs/normalize-unicode.js +38 -0
- package/dist/node_modules/tar/dist/commonjs/normalize-windows-path.js +12 -0
- package/dist/node_modules/tar/dist/commonjs/options.js +66 -0
- package/dist/node_modules/tar/dist/commonjs/pack.js +511 -0
- package/dist/node_modules/tar/dist/commonjs/package.json +3 -0
- package/dist/node_modules/tar/dist/commonjs/parse.js +610 -0
- package/dist/node_modules/tar/dist/commonjs/path-reservations.js +170 -0
- package/dist/node_modules/tar/dist/commonjs/pax.js +158 -0
- package/dist/node_modules/tar/dist/commonjs/process-umask.js +7 -0
- package/dist/node_modules/tar/dist/commonjs/read-entry.js +136 -0
- package/dist/node_modules/tar/dist/commonjs/replace.js +227 -0
- package/dist/node_modules/tar/dist/commonjs/strip-absolute-path.js +29 -0
- package/dist/node_modules/tar/dist/commonjs/strip-trailing-slashes.js +18 -0
- package/dist/node_modules/tar/dist/commonjs/symlink-error.js +19 -0
- package/dist/node_modules/tar/dist/commonjs/types.js +50 -0
- package/dist/node_modules/tar/dist/commonjs/unpack.js +932 -0
- package/dist/node_modules/tar/dist/commonjs/update.js +33 -0
- package/dist/node_modules/tar/dist/commonjs/warn-method.js +31 -0
- package/dist/node_modules/tar/dist/commonjs/winchars.js +14 -0
- package/dist/node_modules/tar/dist/commonjs/write-entry.js +698 -0
- package/dist/node_modules/tar/dist/esm/create.js +76 -0
- package/dist/node_modules/tar/dist/esm/cwd-error.js +14 -0
- package/dist/node_modules/tar/dist/esm/extract.js +49 -0
- package/dist/node_modules/tar/dist/esm/get-write-flag.js +26 -0
- package/dist/node_modules/tar/dist/esm/header.js +275 -0
- package/dist/node_modules/tar/dist/esm/index.js +20 -0
- package/dist/node_modules/tar/dist/esm/index.min.js +4 -0
- package/dist/node_modules/tar/dist/esm/large-numbers.js +94 -0
- package/dist/node_modules/tar/dist/esm/list.js +105 -0
- package/dist/node_modules/tar/dist/esm/make-command.js +48 -0
- package/dist/node_modules/tar/dist/esm/mkdir.js +179 -0
- package/dist/node_modules/tar/dist/esm/mode-fix.js +25 -0
- package/dist/node_modules/tar/dist/esm/normalize-unicode.js +34 -0
- package/dist/node_modules/tar/dist/esm/normalize-windows-path.js +9 -0
- package/dist/node_modules/tar/dist/esm/options.js +54 -0
- package/dist/node_modules/tar/dist/esm/pack.js +469 -0
- package/dist/node_modules/tar/dist/esm/package.json +3 -0
- package/dist/node_modules/tar/dist/esm/parse.js +606 -0
- package/dist/node_modules/tar/dist/esm/path-reservations.js +166 -0
- package/dist/node_modules/tar/dist/esm/pax.js +154 -0
- package/dist/node_modules/tar/dist/esm/process-umask.js +3 -0
- package/dist/node_modules/tar/dist/esm/read-entry.js +132 -0
- package/dist/node_modules/tar/dist/esm/replace.js +221 -0
- package/dist/node_modules/tar/dist/esm/strip-absolute-path.js +25 -0
- package/dist/node_modules/tar/dist/esm/strip-trailing-slashes.js +14 -0
- package/dist/node_modules/tar/dist/esm/symlink-error.js +15 -0
- package/dist/node_modules/tar/dist/esm/types.js +45 -0
- package/dist/node_modules/tar/dist/esm/unpack.js +891 -0
- package/dist/node_modules/tar/dist/esm/update.js +30 -0
- package/dist/node_modules/tar/dist/esm/warn-method.js +27 -0
- package/dist/node_modules/tar/dist/esm/winchars.js +9 -0
- package/dist/node_modules/tar/dist/esm/write-entry.js +656 -0
- package/dist/node_modules/tar/node_modules/yallist/dist/commonjs/index.js +384 -0
- package/dist/node_modules/tar/node_modules/yallist/dist/commonjs/package.json +3 -0
- package/dist/node_modules/tar/node_modules/yallist/dist/esm/index.js +379 -0
- package/dist/node_modules/tar/node_modules/yallist/dist/esm/package.json +3 -0
- package/dist/node_modules/tar/node_modules/yallist/package.json +68 -0
- package/dist/node_modules/tar/package.json +297 -0
- package/dist/node_modules/tinyglobby/LICENSE +21 -0
- package/dist/node_modules/tinyglobby/dist/index.cjs +350 -0
- package/dist/node_modules/tinyglobby/dist/index.d.cts +147 -0
- package/dist/node_modules/tinyglobby/dist/index.d.mts +147 -0
- package/dist/node_modules/tinyglobby/dist/index.mjs +318 -0
- package/dist/node_modules/tinyglobby/package.json +73 -0
- package/{LICENSE → dist/node_modules/v8-compile-cache/LICENSE} +1 -2
- package/dist/node_modules/v8-compile-cache/package.json +34 -0
- package/dist/node_modules/v8-compile-cache/v8-compile-cache.js +373 -0
- package/dist/node_modules/which/LICENSE +15 -0
- package/dist/node_modules/which/bin/which.js +52 -0
- package/dist/node_modules/which/lib/index.js +111 -0
- package/dist/node_modules/which/package.json +52 -0
- package/dist/node_modules/yallist/LICENSE +15 -0
- package/dist/node_modules/yallist/iterator.js +8 -0
- package/dist/node_modules/yallist/package.json +29 -0
- package/dist/node_modules/yallist/yallist.js +426 -0
- package/dist/pnpm.mjs +266382 -0
- package/dist/pnpmrc +2 -0
- package/dist/templates/completion.bash +31 -0
- package/dist/templates/completion.fish +22 -0
- package/dist/templates/completion.ps1 +193 -0
- package/dist/templates/completion.zsh +27 -0
- package/dist/vendor/fastlist-0.3.0-x64.exe +0 -0
- package/dist/vendor/fastlist-0.3.0-x86.exe +0 -0
- package/dist/worker.js +10958 -0
- package/package.json +34 -11
- package/pn +2 -0
- package/pn.cmd +2 -0
- package/pn.ps1 +1 -0
- package/pnpx +2 -0
- package/pnpx.cmd +2 -0
- package/pnpx.ps1 +1 -0
- package/pnx +2 -0
- package/pnx.cmd +2 -0
- package/pnx.ps1 +1 -0
- package/prepare.js +26 -3
- package/setup.js +22 -11
- package/CHANGELOG.md +0 -15
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""PEP 656 support.
|
|
2
|
+
|
|
3
|
+
This module implements logic to detect if the currently running Python is
|
|
4
|
+
linked against musl, and what musl version is used.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import functools
|
|
8
|
+
import re
|
|
9
|
+
import subprocess
|
|
10
|
+
import sys
|
|
11
|
+
from typing import Iterator, NamedTuple, Optional, Sequence
|
|
12
|
+
|
|
13
|
+
from ._elffile import ELFFile
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class _MuslVersion(NamedTuple):
|
|
17
|
+
major: int
|
|
18
|
+
minor: int
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _parse_musl_version(output: str) -> Optional[_MuslVersion]:
|
|
22
|
+
lines = [n for n in (n.strip() for n in output.splitlines()) if n]
|
|
23
|
+
if len(lines) < 2 or lines[0][:4] != "musl":
|
|
24
|
+
return None
|
|
25
|
+
m = re.match(r"Version (\d+)\.(\d+)", lines[1])
|
|
26
|
+
if not m:
|
|
27
|
+
return None
|
|
28
|
+
return _MuslVersion(major=int(m.group(1)), minor=int(m.group(2)))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@functools.lru_cache()
|
|
32
|
+
def _get_musl_version(executable: str) -> Optional[_MuslVersion]:
|
|
33
|
+
"""Detect currently-running musl runtime version.
|
|
34
|
+
|
|
35
|
+
This is done by checking the specified executable's dynamic linking
|
|
36
|
+
information, and invoking the loader to parse its output for a version
|
|
37
|
+
string. If the loader is musl, the output would be something like::
|
|
38
|
+
|
|
39
|
+
musl libc (x86_64)
|
|
40
|
+
Version 1.2.2
|
|
41
|
+
Dynamic Program Loader
|
|
42
|
+
"""
|
|
43
|
+
try:
|
|
44
|
+
with open(executable, "rb") as f:
|
|
45
|
+
ld = ELFFile(f).interpreter
|
|
46
|
+
except (OSError, TypeError, ValueError):
|
|
47
|
+
return None
|
|
48
|
+
if ld is None or "musl" not in ld:
|
|
49
|
+
return None
|
|
50
|
+
proc = subprocess.run([ld], stderr=subprocess.PIPE, text=True)
|
|
51
|
+
return _parse_musl_version(proc.stderr)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def platform_tags(archs: Sequence[str]) -> Iterator[str]:
|
|
55
|
+
"""Generate musllinux tags compatible to the current platform.
|
|
56
|
+
|
|
57
|
+
:param archs: Sequence of compatible architectures.
|
|
58
|
+
The first one shall be the closest to the actual architecture and be the part of
|
|
59
|
+
platform tag after the ``linux_`` prefix, e.g. ``x86_64``.
|
|
60
|
+
The ``linux_`` prefix is assumed as a prerequisite for the current platform to
|
|
61
|
+
be musllinux-compatible.
|
|
62
|
+
|
|
63
|
+
:returns: An iterator of compatible musllinux tags.
|
|
64
|
+
"""
|
|
65
|
+
sys_musl = _get_musl_version(sys.executable)
|
|
66
|
+
if sys_musl is None: # Python not dynamically linked against musl.
|
|
67
|
+
return
|
|
68
|
+
for arch in archs:
|
|
69
|
+
for minor in range(sys_musl.minor, -1, -1):
|
|
70
|
+
yield f"musllinux_{sys_musl.major}_{minor}_{arch}"
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
if __name__ == "__main__": # pragma: no cover
|
|
74
|
+
import sysconfig
|
|
75
|
+
|
|
76
|
+
plat = sysconfig.get_platform()
|
|
77
|
+
assert plat.startswith("linux-"), "not linux"
|
|
78
|
+
|
|
79
|
+
print("plat:", plat)
|
|
80
|
+
print("musl:", _get_musl_version(sys.executable))
|
|
81
|
+
print("tags:", end=" ")
|
|
82
|
+
for t in platform_tags(re.sub(r"[.-]", "_", plat.split("-", 1)[-1])):
|
|
83
|
+
print(t, end="\n ")
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
"""Handwritten parser of dependency specifiers.
|
|
2
|
+
|
|
3
|
+
The docstring for each __parse_* function contains ENBF-inspired grammar representing
|
|
4
|
+
the implementation.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import ast
|
|
8
|
+
from typing import Any, List, NamedTuple, Optional, Tuple, Union
|
|
9
|
+
|
|
10
|
+
from ._tokenizer import DEFAULT_RULES, Tokenizer
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Node:
|
|
14
|
+
def __init__(self, value: str) -> None:
|
|
15
|
+
self.value = value
|
|
16
|
+
|
|
17
|
+
def __str__(self) -> str:
|
|
18
|
+
return self.value
|
|
19
|
+
|
|
20
|
+
def __repr__(self) -> str:
|
|
21
|
+
return f"<{self.__class__.__name__}('{self}')>"
|
|
22
|
+
|
|
23
|
+
def serialize(self) -> str:
|
|
24
|
+
raise NotImplementedError
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class Variable(Node):
|
|
28
|
+
def serialize(self) -> str:
|
|
29
|
+
return str(self)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class Value(Node):
|
|
33
|
+
def serialize(self) -> str:
|
|
34
|
+
return f'"{self}"'
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class Op(Node):
|
|
38
|
+
def serialize(self) -> str:
|
|
39
|
+
return str(self)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
MarkerVar = Union[Variable, Value]
|
|
43
|
+
MarkerItem = Tuple[MarkerVar, Op, MarkerVar]
|
|
44
|
+
# MarkerAtom = Union[MarkerItem, List["MarkerAtom"]]
|
|
45
|
+
# MarkerList = List[Union["MarkerList", MarkerAtom, str]]
|
|
46
|
+
# mypy does not support recursive type definition
|
|
47
|
+
# https://github.com/python/mypy/issues/731
|
|
48
|
+
MarkerAtom = Any
|
|
49
|
+
MarkerList = List[Any]
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class ParsedRequirement(NamedTuple):
|
|
53
|
+
name: str
|
|
54
|
+
url: str
|
|
55
|
+
extras: List[str]
|
|
56
|
+
specifier: str
|
|
57
|
+
marker: Optional[MarkerList]
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
# --------------------------------------------------------------------------------------
|
|
61
|
+
# Recursive descent parser for dependency specifier
|
|
62
|
+
# --------------------------------------------------------------------------------------
|
|
63
|
+
def parse_requirement(source: str) -> ParsedRequirement:
|
|
64
|
+
return _parse_requirement(Tokenizer(source, rules=DEFAULT_RULES))
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _parse_requirement(tokenizer: Tokenizer) -> ParsedRequirement:
|
|
68
|
+
"""
|
|
69
|
+
requirement = WS? IDENTIFIER WS? extras WS? requirement_details
|
|
70
|
+
"""
|
|
71
|
+
tokenizer.consume("WS")
|
|
72
|
+
|
|
73
|
+
name_token = tokenizer.expect(
|
|
74
|
+
"IDENTIFIER", expected="package name at the start of dependency specifier"
|
|
75
|
+
)
|
|
76
|
+
name = name_token.text
|
|
77
|
+
tokenizer.consume("WS")
|
|
78
|
+
|
|
79
|
+
extras = _parse_extras(tokenizer)
|
|
80
|
+
tokenizer.consume("WS")
|
|
81
|
+
|
|
82
|
+
url, specifier, marker = _parse_requirement_details(tokenizer)
|
|
83
|
+
tokenizer.expect("END", expected="end of dependency specifier")
|
|
84
|
+
|
|
85
|
+
return ParsedRequirement(name, url, extras, specifier, marker)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def _parse_requirement_details(
|
|
89
|
+
tokenizer: Tokenizer,
|
|
90
|
+
) -> Tuple[str, str, Optional[MarkerList]]:
|
|
91
|
+
"""
|
|
92
|
+
requirement_details = AT URL (WS requirement_marker?)?
|
|
93
|
+
| specifier WS? (requirement_marker)?
|
|
94
|
+
"""
|
|
95
|
+
|
|
96
|
+
specifier = ""
|
|
97
|
+
url = ""
|
|
98
|
+
marker = None
|
|
99
|
+
|
|
100
|
+
if tokenizer.check("AT"):
|
|
101
|
+
tokenizer.read()
|
|
102
|
+
tokenizer.consume("WS")
|
|
103
|
+
|
|
104
|
+
url_start = tokenizer.position
|
|
105
|
+
url = tokenizer.expect("URL", expected="URL after @").text
|
|
106
|
+
if tokenizer.check("END", peek=True):
|
|
107
|
+
return (url, specifier, marker)
|
|
108
|
+
|
|
109
|
+
tokenizer.expect("WS", expected="whitespace after URL")
|
|
110
|
+
|
|
111
|
+
# The input might end after whitespace.
|
|
112
|
+
if tokenizer.check("END", peek=True):
|
|
113
|
+
return (url, specifier, marker)
|
|
114
|
+
|
|
115
|
+
marker = _parse_requirement_marker(
|
|
116
|
+
tokenizer, span_start=url_start, after="URL and whitespace"
|
|
117
|
+
)
|
|
118
|
+
else:
|
|
119
|
+
specifier_start = tokenizer.position
|
|
120
|
+
specifier = _parse_specifier(tokenizer)
|
|
121
|
+
tokenizer.consume("WS")
|
|
122
|
+
|
|
123
|
+
if tokenizer.check("END", peek=True):
|
|
124
|
+
return (url, specifier, marker)
|
|
125
|
+
|
|
126
|
+
marker = _parse_requirement_marker(
|
|
127
|
+
tokenizer,
|
|
128
|
+
span_start=specifier_start,
|
|
129
|
+
after=(
|
|
130
|
+
"version specifier"
|
|
131
|
+
if specifier
|
|
132
|
+
else "name and no valid version specifier"
|
|
133
|
+
),
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
return (url, specifier, marker)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def _parse_requirement_marker(
|
|
140
|
+
tokenizer: Tokenizer, *, span_start: int, after: str
|
|
141
|
+
) -> MarkerList:
|
|
142
|
+
"""
|
|
143
|
+
requirement_marker = SEMICOLON marker WS?
|
|
144
|
+
"""
|
|
145
|
+
|
|
146
|
+
if not tokenizer.check("SEMICOLON"):
|
|
147
|
+
tokenizer.raise_syntax_error(
|
|
148
|
+
f"Expected end or semicolon (after {after})",
|
|
149
|
+
span_start=span_start,
|
|
150
|
+
)
|
|
151
|
+
tokenizer.read()
|
|
152
|
+
|
|
153
|
+
marker = _parse_marker(tokenizer)
|
|
154
|
+
tokenizer.consume("WS")
|
|
155
|
+
|
|
156
|
+
return marker
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def _parse_extras(tokenizer: Tokenizer) -> List[str]:
|
|
160
|
+
"""
|
|
161
|
+
extras = (LEFT_BRACKET wsp* extras_list? wsp* RIGHT_BRACKET)?
|
|
162
|
+
"""
|
|
163
|
+
if not tokenizer.check("LEFT_BRACKET", peek=True):
|
|
164
|
+
return []
|
|
165
|
+
|
|
166
|
+
with tokenizer.enclosing_tokens(
|
|
167
|
+
"LEFT_BRACKET",
|
|
168
|
+
"RIGHT_BRACKET",
|
|
169
|
+
around="extras",
|
|
170
|
+
):
|
|
171
|
+
tokenizer.consume("WS")
|
|
172
|
+
extras = _parse_extras_list(tokenizer)
|
|
173
|
+
tokenizer.consume("WS")
|
|
174
|
+
|
|
175
|
+
return extras
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def _parse_extras_list(tokenizer: Tokenizer) -> List[str]:
|
|
179
|
+
"""
|
|
180
|
+
extras_list = identifier (wsp* ',' wsp* identifier)*
|
|
181
|
+
"""
|
|
182
|
+
extras: List[str] = []
|
|
183
|
+
|
|
184
|
+
if not tokenizer.check("IDENTIFIER"):
|
|
185
|
+
return extras
|
|
186
|
+
|
|
187
|
+
extras.append(tokenizer.read().text)
|
|
188
|
+
|
|
189
|
+
while True:
|
|
190
|
+
tokenizer.consume("WS")
|
|
191
|
+
if tokenizer.check("IDENTIFIER", peek=True):
|
|
192
|
+
tokenizer.raise_syntax_error("Expected comma between extra names")
|
|
193
|
+
elif not tokenizer.check("COMMA"):
|
|
194
|
+
break
|
|
195
|
+
|
|
196
|
+
tokenizer.read()
|
|
197
|
+
tokenizer.consume("WS")
|
|
198
|
+
|
|
199
|
+
extra_token = tokenizer.expect("IDENTIFIER", expected="extra name after comma")
|
|
200
|
+
extras.append(extra_token.text)
|
|
201
|
+
|
|
202
|
+
return extras
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def _parse_specifier(tokenizer: Tokenizer) -> str:
|
|
206
|
+
"""
|
|
207
|
+
specifier = LEFT_PARENTHESIS WS? version_many WS? RIGHT_PARENTHESIS
|
|
208
|
+
| WS? version_many WS?
|
|
209
|
+
"""
|
|
210
|
+
with tokenizer.enclosing_tokens(
|
|
211
|
+
"LEFT_PARENTHESIS",
|
|
212
|
+
"RIGHT_PARENTHESIS",
|
|
213
|
+
around="version specifier",
|
|
214
|
+
):
|
|
215
|
+
tokenizer.consume("WS")
|
|
216
|
+
parsed_specifiers = _parse_version_many(tokenizer)
|
|
217
|
+
tokenizer.consume("WS")
|
|
218
|
+
|
|
219
|
+
return parsed_specifiers
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def _parse_version_many(tokenizer: Tokenizer) -> str:
|
|
223
|
+
"""
|
|
224
|
+
version_many = (SPECIFIER (WS? COMMA WS? SPECIFIER)*)?
|
|
225
|
+
"""
|
|
226
|
+
parsed_specifiers = ""
|
|
227
|
+
while tokenizer.check("SPECIFIER"):
|
|
228
|
+
span_start = tokenizer.position
|
|
229
|
+
parsed_specifiers += tokenizer.read().text
|
|
230
|
+
if tokenizer.check("VERSION_PREFIX_TRAIL", peek=True):
|
|
231
|
+
tokenizer.raise_syntax_error(
|
|
232
|
+
".* suffix can only be used with `==` or `!=` operators",
|
|
233
|
+
span_start=span_start,
|
|
234
|
+
span_end=tokenizer.position + 1,
|
|
235
|
+
)
|
|
236
|
+
if tokenizer.check("VERSION_LOCAL_LABEL_TRAIL", peek=True):
|
|
237
|
+
tokenizer.raise_syntax_error(
|
|
238
|
+
"Local version label can only be used with `==` or `!=` operators",
|
|
239
|
+
span_start=span_start,
|
|
240
|
+
span_end=tokenizer.position,
|
|
241
|
+
)
|
|
242
|
+
tokenizer.consume("WS")
|
|
243
|
+
if not tokenizer.check("COMMA"):
|
|
244
|
+
break
|
|
245
|
+
parsed_specifiers += tokenizer.read().text
|
|
246
|
+
tokenizer.consume("WS")
|
|
247
|
+
|
|
248
|
+
return parsed_specifiers
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
# --------------------------------------------------------------------------------------
|
|
252
|
+
# Recursive descent parser for marker expression
|
|
253
|
+
# --------------------------------------------------------------------------------------
|
|
254
|
+
def parse_marker(source: str) -> MarkerList:
|
|
255
|
+
return _parse_full_marker(Tokenizer(source, rules=DEFAULT_RULES))
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def _parse_full_marker(tokenizer: Tokenizer) -> MarkerList:
|
|
259
|
+
retval = _parse_marker(tokenizer)
|
|
260
|
+
tokenizer.expect("END", expected="end of marker expression")
|
|
261
|
+
return retval
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
def _parse_marker(tokenizer: Tokenizer) -> MarkerList:
|
|
265
|
+
"""
|
|
266
|
+
marker = marker_atom (BOOLOP marker_atom)+
|
|
267
|
+
"""
|
|
268
|
+
expression = [_parse_marker_atom(tokenizer)]
|
|
269
|
+
while tokenizer.check("BOOLOP"):
|
|
270
|
+
token = tokenizer.read()
|
|
271
|
+
expr_right = _parse_marker_atom(tokenizer)
|
|
272
|
+
expression.extend((token.text, expr_right))
|
|
273
|
+
return expression
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
def _parse_marker_atom(tokenizer: Tokenizer) -> MarkerAtom:
|
|
277
|
+
"""
|
|
278
|
+
marker_atom = WS? LEFT_PARENTHESIS WS? marker WS? RIGHT_PARENTHESIS WS?
|
|
279
|
+
| WS? marker_item WS?
|
|
280
|
+
"""
|
|
281
|
+
|
|
282
|
+
tokenizer.consume("WS")
|
|
283
|
+
if tokenizer.check("LEFT_PARENTHESIS", peek=True):
|
|
284
|
+
with tokenizer.enclosing_tokens(
|
|
285
|
+
"LEFT_PARENTHESIS",
|
|
286
|
+
"RIGHT_PARENTHESIS",
|
|
287
|
+
around="marker expression",
|
|
288
|
+
):
|
|
289
|
+
tokenizer.consume("WS")
|
|
290
|
+
marker: MarkerAtom = _parse_marker(tokenizer)
|
|
291
|
+
tokenizer.consume("WS")
|
|
292
|
+
else:
|
|
293
|
+
marker = _parse_marker_item(tokenizer)
|
|
294
|
+
tokenizer.consume("WS")
|
|
295
|
+
return marker
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
def _parse_marker_item(tokenizer: Tokenizer) -> MarkerItem:
|
|
299
|
+
"""
|
|
300
|
+
marker_item = WS? marker_var WS? marker_op WS? marker_var WS?
|
|
301
|
+
"""
|
|
302
|
+
tokenizer.consume("WS")
|
|
303
|
+
marker_var_left = _parse_marker_var(tokenizer)
|
|
304
|
+
tokenizer.consume("WS")
|
|
305
|
+
marker_op = _parse_marker_op(tokenizer)
|
|
306
|
+
tokenizer.consume("WS")
|
|
307
|
+
marker_var_right = _parse_marker_var(tokenizer)
|
|
308
|
+
tokenizer.consume("WS")
|
|
309
|
+
return (marker_var_left, marker_op, marker_var_right)
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
def _parse_marker_var(tokenizer: Tokenizer) -> MarkerVar:
|
|
313
|
+
"""
|
|
314
|
+
marker_var = VARIABLE | QUOTED_STRING
|
|
315
|
+
"""
|
|
316
|
+
if tokenizer.check("VARIABLE"):
|
|
317
|
+
return process_env_var(tokenizer.read().text.replace(".", "_"))
|
|
318
|
+
elif tokenizer.check("QUOTED_STRING"):
|
|
319
|
+
return process_python_str(tokenizer.read().text)
|
|
320
|
+
else:
|
|
321
|
+
tokenizer.raise_syntax_error(
|
|
322
|
+
message="Expected a marker variable or quoted string"
|
|
323
|
+
)
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
def process_env_var(env_var: str) -> Variable:
|
|
327
|
+
if (
|
|
328
|
+
env_var == "platform_python_implementation"
|
|
329
|
+
or env_var == "python_implementation"
|
|
330
|
+
):
|
|
331
|
+
return Variable("platform_python_implementation")
|
|
332
|
+
else:
|
|
333
|
+
return Variable(env_var)
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
def process_python_str(python_str: str) -> Value:
|
|
337
|
+
value = ast.literal_eval(python_str)
|
|
338
|
+
return Value(str(value))
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
def _parse_marker_op(tokenizer: Tokenizer) -> Op:
|
|
342
|
+
"""
|
|
343
|
+
marker_op = IN | NOT IN | OP
|
|
344
|
+
"""
|
|
345
|
+
if tokenizer.check("IN"):
|
|
346
|
+
tokenizer.read()
|
|
347
|
+
return Op("in")
|
|
348
|
+
elif tokenizer.check("NOT"):
|
|
349
|
+
tokenizer.read()
|
|
350
|
+
tokenizer.expect("WS", expected="whitespace after 'not'")
|
|
351
|
+
tokenizer.expect("IN", expected="'in' after 'not'")
|
|
352
|
+
return Op("not in")
|
|
353
|
+
elif tokenizer.check("OP"):
|
|
354
|
+
return Op(tokenizer.read().text)
|
|
355
|
+
else:
|
|
356
|
+
return tokenizer.raise_syntax_error(
|
|
357
|
+
"Expected marker operator, one of "
|
|
358
|
+
"<=, <, !=, ==, >=, >, ~=, ===, in, not in"
|
|
359
|
+
)
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
|
|
6
|
+
class InfinityType:
|
|
7
|
+
def __repr__(self) -> str:
|
|
8
|
+
return "Infinity"
|
|
9
|
+
|
|
10
|
+
def __hash__(self) -> int:
|
|
11
|
+
return hash(repr(self))
|
|
12
|
+
|
|
13
|
+
def __lt__(self, other: object) -> bool:
|
|
14
|
+
return False
|
|
15
|
+
|
|
16
|
+
def __le__(self, other: object) -> bool:
|
|
17
|
+
return False
|
|
18
|
+
|
|
19
|
+
def __eq__(self, other: object) -> bool:
|
|
20
|
+
return isinstance(other, self.__class__)
|
|
21
|
+
|
|
22
|
+
def __gt__(self, other: object) -> bool:
|
|
23
|
+
return True
|
|
24
|
+
|
|
25
|
+
def __ge__(self, other: object) -> bool:
|
|
26
|
+
return True
|
|
27
|
+
|
|
28
|
+
def __neg__(self: object) -> "NegativeInfinityType":
|
|
29
|
+
return NegativeInfinity
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
Infinity = InfinityType()
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class NegativeInfinityType:
|
|
36
|
+
def __repr__(self) -> str:
|
|
37
|
+
return "-Infinity"
|
|
38
|
+
|
|
39
|
+
def __hash__(self) -> int:
|
|
40
|
+
return hash(repr(self))
|
|
41
|
+
|
|
42
|
+
def __lt__(self, other: object) -> bool:
|
|
43
|
+
return True
|
|
44
|
+
|
|
45
|
+
def __le__(self, other: object) -> bool:
|
|
46
|
+
return True
|
|
47
|
+
|
|
48
|
+
def __eq__(self, other: object) -> bool:
|
|
49
|
+
return isinstance(other, self.__class__)
|
|
50
|
+
|
|
51
|
+
def __gt__(self, other: object) -> bool:
|
|
52
|
+
return False
|
|
53
|
+
|
|
54
|
+
def __ge__(self, other: object) -> bool:
|
|
55
|
+
return False
|
|
56
|
+
|
|
57
|
+
def __neg__(self: object) -> InfinityType:
|
|
58
|
+
return Infinity
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
NegativeInfinity = NegativeInfinityType()
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import contextlib
|
|
2
|
+
import re
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from typing import Dict, Iterator, NoReturn, Optional, Tuple, Union
|
|
5
|
+
|
|
6
|
+
from .specifiers import Specifier
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass
|
|
10
|
+
class Token:
|
|
11
|
+
name: str
|
|
12
|
+
text: str
|
|
13
|
+
position: int
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class ParserSyntaxError(Exception):
|
|
17
|
+
"""The provided source text could not be parsed correctly."""
|
|
18
|
+
|
|
19
|
+
def __init__(
|
|
20
|
+
self,
|
|
21
|
+
message: str,
|
|
22
|
+
*,
|
|
23
|
+
source: str,
|
|
24
|
+
span: Tuple[int, int],
|
|
25
|
+
) -> None:
|
|
26
|
+
self.span = span
|
|
27
|
+
self.message = message
|
|
28
|
+
self.source = source
|
|
29
|
+
|
|
30
|
+
super().__init__()
|
|
31
|
+
|
|
32
|
+
def __str__(self) -> str:
|
|
33
|
+
marker = " " * self.span[0] + "~" * (self.span[1] - self.span[0]) + "^"
|
|
34
|
+
return "\n ".join([self.message, self.source, marker])
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
DEFAULT_RULES: "Dict[str, Union[str, re.Pattern[str]]]" = {
|
|
38
|
+
"LEFT_PARENTHESIS": r"\(",
|
|
39
|
+
"RIGHT_PARENTHESIS": r"\)",
|
|
40
|
+
"LEFT_BRACKET": r"\[",
|
|
41
|
+
"RIGHT_BRACKET": r"\]",
|
|
42
|
+
"SEMICOLON": r";",
|
|
43
|
+
"COMMA": r",",
|
|
44
|
+
"QUOTED_STRING": re.compile(
|
|
45
|
+
r"""
|
|
46
|
+
(
|
|
47
|
+
('[^']*')
|
|
48
|
+
|
|
|
49
|
+
("[^"]*")
|
|
50
|
+
)
|
|
51
|
+
""",
|
|
52
|
+
re.VERBOSE,
|
|
53
|
+
),
|
|
54
|
+
"OP": r"(===|==|~=|!=|<=|>=|<|>)",
|
|
55
|
+
"BOOLOP": r"\b(or|and)\b",
|
|
56
|
+
"IN": r"\bin\b",
|
|
57
|
+
"NOT": r"\bnot\b",
|
|
58
|
+
"VARIABLE": re.compile(
|
|
59
|
+
r"""
|
|
60
|
+
\b(
|
|
61
|
+
python_version
|
|
62
|
+
|python_full_version
|
|
63
|
+
|os[._]name
|
|
64
|
+
|sys[._]platform
|
|
65
|
+
|platform_(release|system)
|
|
66
|
+
|platform[._](version|machine|python_implementation)
|
|
67
|
+
|python_implementation
|
|
68
|
+
|implementation_(name|version)
|
|
69
|
+
|extra
|
|
70
|
+
)\b
|
|
71
|
+
""",
|
|
72
|
+
re.VERBOSE,
|
|
73
|
+
),
|
|
74
|
+
"SPECIFIER": re.compile(
|
|
75
|
+
Specifier._operator_regex_str + Specifier._version_regex_str,
|
|
76
|
+
re.VERBOSE | re.IGNORECASE,
|
|
77
|
+
),
|
|
78
|
+
"AT": r"\@",
|
|
79
|
+
"URL": r"[^ \t]+",
|
|
80
|
+
"IDENTIFIER": r"\b[a-zA-Z0-9][a-zA-Z0-9._-]*\b",
|
|
81
|
+
"VERSION_PREFIX_TRAIL": r"\.\*",
|
|
82
|
+
"VERSION_LOCAL_LABEL_TRAIL": r"\+[a-z0-9]+(?:[-_\.][a-z0-9]+)*",
|
|
83
|
+
"WS": r"[ \t]+",
|
|
84
|
+
"END": r"$",
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class Tokenizer:
|
|
89
|
+
"""Context-sensitive token parsing.
|
|
90
|
+
|
|
91
|
+
Provides methods to examine the input stream to check whether the next token
|
|
92
|
+
matches.
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
def __init__(
|
|
96
|
+
self,
|
|
97
|
+
source: str,
|
|
98
|
+
*,
|
|
99
|
+
rules: "Dict[str, Union[str, re.Pattern[str]]]",
|
|
100
|
+
) -> None:
|
|
101
|
+
self.source = source
|
|
102
|
+
self.rules: Dict[str, re.Pattern[str]] = {
|
|
103
|
+
name: re.compile(pattern) for name, pattern in rules.items()
|
|
104
|
+
}
|
|
105
|
+
self.next_token: Optional[Token] = None
|
|
106
|
+
self.position = 0
|
|
107
|
+
|
|
108
|
+
def consume(self, name: str) -> None:
|
|
109
|
+
"""Move beyond provided token name, if at current position."""
|
|
110
|
+
if self.check(name):
|
|
111
|
+
self.read()
|
|
112
|
+
|
|
113
|
+
def check(self, name: str, *, peek: bool = False) -> bool:
|
|
114
|
+
"""Check whether the next token has the provided name.
|
|
115
|
+
|
|
116
|
+
By default, if the check succeeds, the token *must* be read before
|
|
117
|
+
another check. If `peek` is set to `True`, the token is not loaded and
|
|
118
|
+
would need to be checked again.
|
|
119
|
+
"""
|
|
120
|
+
assert (
|
|
121
|
+
self.next_token is None
|
|
122
|
+
), f"Cannot check for {name!r}, already have {self.next_token!r}"
|
|
123
|
+
assert name in self.rules, f"Unknown token name: {name!r}"
|
|
124
|
+
|
|
125
|
+
expression = self.rules[name]
|
|
126
|
+
|
|
127
|
+
match = expression.match(self.source, self.position)
|
|
128
|
+
if match is None:
|
|
129
|
+
return False
|
|
130
|
+
if not peek:
|
|
131
|
+
self.next_token = Token(name, match[0], self.position)
|
|
132
|
+
return True
|
|
133
|
+
|
|
134
|
+
def expect(self, name: str, *, expected: str) -> Token:
|
|
135
|
+
"""Expect a certain token name next, failing with a syntax error otherwise.
|
|
136
|
+
|
|
137
|
+
The token is *not* read.
|
|
138
|
+
"""
|
|
139
|
+
if not self.check(name):
|
|
140
|
+
raise self.raise_syntax_error(f"Expected {expected}")
|
|
141
|
+
return self.read()
|
|
142
|
+
|
|
143
|
+
def read(self) -> Token:
|
|
144
|
+
"""Consume the next token and return it."""
|
|
145
|
+
token = self.next_token
|
|
146
|
+
assert token is not None
|
|
147
|
+
|
|
148
|
+
self.position += len(token.text)
|
|
149
|
+
self.next_token = None
|
|
150
|
+
|
|
151
|
+
return token
|
|
152
|
+
|
|
153
|
+
def raise_syntax_error(
|
|
154
|
+
self,
|
|
155
|
+
message: str,
|
|
156
|
+
*,
|
|
157
|
+
span_start: Optional[int] = None,
|
|
158
|
+
span_end: Optional[int] = None,
|
|
159
|
+
) -> NoReturn:
|
|
160
|
+
"""Raise ParserSyntaxError at the given position."""
|
|
161
|
+
span = (
|
|
162
|
+
self.position if span_start is None else span_start,
|
|
163
|
+
self.position if span_end is None else span_end,
|
|
164
|
+
)
|
|
165
|
+
raise ParserSyntaxError(
|
|
166
|
+
message,
|
|
167
|
+
source=self.source,
|
|
168
|
+
span=span,
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
@contextlib.contextmanager
|
|
172
|
+
def enclosing_tokens(
|
|
173
|
+
self, open_token: str, close_token: str, *, around: str
|
|
174
|
+
) -> Iterator[None]:
|
|
175
|
+
if self.check(open_token):
|
|
176
|
+
open_position = self.position
|
|
177
|
+
self.read()
|
|
178
|
+
else:
|
|
179
|
+
open_position = None
|
|
180
|
+
|
|
181
|
+
yield
|
|
182
|
+
|
|
183
|
+
if open_position is None:
|
|
184
|
+
return
|
|
185
|
+
|
|
186
|
+
if not self.check(close_token):
|
|
187
|
+
self.raise_syntax_error(
|
|
188
|
+
f"Expected matching {close_token} for {open_token}, after {around}",
|
|
189
|
+
span_start=open_position,
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
self.read()
|