@poe-platform/safe-bash 0.1.823 → 0.1.825
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/safe-bash/command-chunks/{chunk-LDR3PPM3.js → chunk-22QEL76N.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-BSLXS4PE.js → chunk-3DH5QBZC.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-KQE2D7PX.js → chunk-3HUCLYKJ.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-PLVFJ6FF.js → chunk-4EA7WI3L.js} +9 -1
- package/dist/safe-bash/command-chunks/{chunk-J4I7KCQQ.js → chunk-4JABZEDO.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-PVKSBXHB.js → chunk-4M6D4IUB.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-UVM6QG2H.js → chunk-4MVQE6CT.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-QWQHLMDX.js → chunk-4VTB4DGE.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-JQPDVCBU.js → chunk-565AAQTV.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-JSW6YH6T.js → chunk-5PRXCH54.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-42OQIFPW.js → chunk-5RLK2QSY.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-PYYAX5FB.js → chunk-63WEGFLL.js} +16 -16
- package/dist/safe-bash/command-chunks/{chunk-5QR4LTAK.js → chunk-6KZXFPOT.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-LJLB7TBN.js → chunk-6YTXU3NF.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-NNYOPI7K.js → chunk-7NF44M2V.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-ZRHKXN6W.js → chunk-7RQGRFHJ.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-QGSY4ZAU.js → chunk-7UYBNOOM.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-6REH56FL.js → chunk-AA254KE5.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-2VSNIHIW.js → chunk-APUXNXXQ.js} +11 -11
- package/dist/safe-bash/command-chunks/{chunk-XE75H5ZZ.js → chunk-AVXSR5MO.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-22D6Q6SW.js → chunk-BKCVCMUX.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-UDRJKA3P.js → chunk-C23L4HZB.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-PAEAEFK3.js → chunk-C3EEMMQL.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-NDJPULBE.js → chunk-CEKBIZGU.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-75OUKYCM.js → chunk-CH5JDE3C.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-XNVL6AOV.js → chunk-CIYGC7WU.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-RUXY7GN5.js → chunk-CMJBRGU2.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-DGFMOT4O.js → chunk-CO4HYNPS.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-TMJG745A.js → chunk-CQLZM75U.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-T2LZWXWF.js → chunk-DBCTHLB5.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-6RE4MZYM.js → chunk-DBEJMI7J.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-XXUMECE4.js → chunk-DEEZYCOQ.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-YJMS5Q4Y.js → chunk-DHTTI7CE.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-D3WMD32B.js → chunk-DLLGOC4Q.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-HVLF3Y4B.js → chunk-DYCYAIET.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-5NC2IQMQ.js → chunk-EV7A5FNN.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-2YC6MWQB.js → chunk-EY3UE26F.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-ZQ4NQ24M.js → chunk-FJLVISSD.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-WOO3YO2X.js → chunk-HTMGN3KL.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-2E53ZL5D.js → chunk-HU72CZBN.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-AH3ZEPAN.js → chunk-IGHFIRXK.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-3UDJYSAF.js → chunk-IX3B4HCD.js} +34 -2
- package/dist/safe-bash/command-chunks/{chunk-J3ISXTYB.js → chunk-JTEAYB72.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-NR7POLKP.js → chunk-KCS25XUJ.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-EO3RYGUZ.js → chunk-LFTGMUAV.js} +465 -121
- package/dist/safe-bash/command-chunks/chunk-LKAFLJ5L.js +123 -0
- package/dist/safe-bash/command-chunks/{chunk-EU5SR3LS.js → chunk-LSH6UKCT.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-WV3C6BRD.js → chunk-MHZ7UTRX.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-K6J3KFQ2.js → chunk-MSA5BQFK.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-OMD45J52.js → chunk-MW3L6JB7.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-AR65HNNX.js → chunk-N2TN7IBE.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-NWA7ZJDV.js → chunk-NU64GWGN.js} +3 -3
- package/dist/safe-bash/command-chunks/chunk-NXCJNPL3.js +47 -0
- package/dist/safe-bash/command-chunks/{chunk-GAYTDZPP.js → chunk-ORWYNKKL.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-FCGMSOF6.js → chunk-P6YTNXRV.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-3RDEX4AF.js → chunk-PAS4YSNN.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-TTPT3OME.js → chunk-PSNTCRL5.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-FGK6HLSY.js → chunk-QC2RWSYM.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-HCZITM4C.js → chunk-QPY3NCMC.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-3TXPZLFI.js → chunk-R6RVR6ZZ.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-HQFX5XKV.js → chunk-RB7XAYO2.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-6PDXNY3T.js → chunk-RF5VEKFU.js} +9 -9
- package/dist/safe-bash/command-chunks/{chunk-VAMBWXDV.js → chunk-RUAGHZNF.js} +18 -18
- package/dist/safe-bash/command-chunks/{chunk-WDTWJFPK.js → chunk-RZOHZGEZ.js} +160 -85
- package/dist/safe-bash/command-chunks/{chunk-3MFYCMQU.js → chunk-S2T7DDGY.js} +16 -16
- package/dist/safe-bash/command-chunks/{chunk-LZHFVNEV.js → chunk-S3QYSI5E.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-ZLMCWAAU.js → chunk-STTXZKR6.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-AXUHORS3.js → chunk-SUYSZJI3.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-C5SLY3RB.js → chunk-U2C6A3QO.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-HCJWEB6P.js → chunk-U6IEK2CI.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-NN6OWOJG.js → chunk-UC6DUY3K.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-64L57DEI.js → chunk-UQTU7H6T.js} +9 -9
- package/dist/safe-bash/command-chunks/{chunk-ARA57PMC.js → chunk-V5PVNBOS.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-ZZ6EIACJ.js → chunk-VGHRMAI4.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-DZTT5SLG.js → chunk-VP7R7HKY.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-TP5MZHCB.js → chunk-W5Y7Y7PS.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-ZTW2E5OT.js → chunk-WAE3OCOU.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-DBYY7IDI.js → chunk-WCM47S5A.js} +10 -10
- package/dist/safe-bash/command-chunks/{chunk-U6VSRO6E.js → chunk-WNVBS4GV.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-CXOAMPOV.js → chunk-WUIS2INH.js} +13 -13
- package/dist/safe-bash/command-chunks/{chunk-64HIOP7Q.js → chunk-WY6THI6J.js} +33 -353
- package/dist/safe-bash/command-chunks/{chunk-RGKHTSUY.js → chunk-XSZNL3GV.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-4HJEZGYN.js → chunk-YODHIRPW.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-C3FERGHU.js → chunk-YRMTOLG5.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-YXIJOYT6.js → chunk-ZUOCXDYW.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-LBBJ5S3W.js → chunk-ZZKJPLIH.js} +1 -1
- package/dist/safe-bash/command-chunks/{engine-UPLVIV72-IGXUDNO5.js → engine-UPLVIV72-MSSFJLK4.js} +1 -1
- package/dist/safe-bash/commands/llm/collections.browser.js +4 -2
- package/dist/safe-bash/commands/llm/collections.js +1 -1
- package/dist/safe-bash/commands/python/source-archive.d.ts +2 -0
- package/dist/safe-bash/commands/python/source-archive.js +2 -0
- package/dist/safe-bash/commands/python/source-zip.d.ts +2 -0
- package/dist/safe-bash/commands/python/source-zip.js +2 -0
- package/dist/safe-bash-command-exiftool/index.js +41 -0
- package/dist/safe-bash-command-git/git_rust.wasm +0 -0
- package/dist/safe-bash-command-llm/collections.d.ts +2 -0
- package/dist/safe-bash-command-llm/collections.js +146 -22
- package/dist/safe-bash-command-llm/command.js +1 -1
- package/dist/safe-bash-command-llm/import-sql.d.ts +9 -0
- package/dist/safe-bash-command-llm/index.js +1 -1
- package/dist/safe-bash-command-playwright-cli/index.js +36 -36
- package/dist/safe-bash-command-playwright-cli/playwright/abilities.js +7 -7
- package/dist/safe-bash-command-playwright-cli/playwright/adapter.js +3 -3
- package/dist/safe-bash-command-playwright-cli/playwright/capability-events.js +1 -1
- package/dist/safe-bash-command-playwright-cli/playwright/capability-result.js +1 -1
- package/dist/safe-bash-command-playwright-cli/playwright/controller.js +15 -15
- package/dist/safe-bash-command-playwright-cli/playwright/download-capabilities.js +1 -1
- package/dist/safe-bash-command-playwright-cli/playwright/drop-capability.js +1 -1
- package/dist/safe-bash-command-playwright-cli/playwright/index.js +35 -35
- package/dist/safe-bash-command-playwright-cli/playwright/modal-capabilities.js +1 -1
- package/dist/safe-bash-command-playwright-cli/playwright/native-evaluation.js +1 -1
- package/dist/safe-bash-command-playwright-cli/playwright/native-json-snapshot.js +1 -1
- package/dist/safe-bash-command-playwright-cli/playwright/native-snapshot.js +1 -1
- package/dist/safe-bash-command-playwright-cli/playwright/native-storage-replacement.js +2 -2
- package/dist/safe-bash-command-playwright-cli/playwright/profile.js +3 -3
- package/dist/safe-bash-command-playwright-cli/playwright/recording-capabilities.js +1 -1
- package/dist/safe-bash-command-playwright-cli/playwright/route-capabilities.js +1 -1
- package/dist/safe-bash-command-playwright-cli/playwright/snapshot.js +1 -1
- package/dist/safe-bash-command-playwright-cli/playwright/standard-capabilities.js +6 -6
- package/dist/safe-bash-command-playwright-cli/playwright/storage-capabilities.js +5 -5
- package/dist/safe-bash-command-playwright-cli/playwright/tracing-capabilities.js +1 -1
- package/dist/safe-bash-command-playwright-cli/playwright/webmcp-capabilities.js +1 -1
- package/dist/safe-bash-command-python/build-backend.d.ts +45 -3
- package/dist/safe-bash-command-python/build-dependencies.d.ts +2 -1
- package/dist/safe-bash-command-python/build-wheel.d.ts +11 -2
- package/dist/safe-bash-command-python/executor.d.ts +1 -1
- package/dist/safe-bash-command-python/executor.js +6 -5
- package/dist/safe-bash-command-python/index.js +6 -5
- package/dist/safe-bash-command-python/jspi.js +2 -2
- package/dist/safe-bash-command-python/manifest.d.ts +5 -1
- package/dist/safe-bash-command-python/provisioning.d.ts +8 -4
- package/dist/safe-bash-command-python/provisioning.js +2 -1
- package/dist/safe-bash-command-python/source-archive.d.ts +4 -0
- package/dist/safe-bash-command-python/source-archive.js +136 -0
- package/dist/safe-bash-command-python/source-environment.d.ts +4 -1
- package/dist/safe-bash-command-python/source-zip.d.ts +8 -0
- package/dist/safe-bash-command-python/source-zip.js +8 -0
- package/dist/safe-bash-command-python/worker.js +1 -1
- package/dist/safe-bash-command-safejs/index.js +5 -5
- package/dist/safe-bash-command-safejs/runtime.js +3 -3
- package/dist/safe-bash-command-ssconvert/index.js +8 -8
- package/dist/safe-bash-compression-engine/bounded-codec.js +2 -2
- package/dist/safe-bash-compression-engine/codec-loader.js +1 -1
- package/dist/safe-bash-compression-engine/files.js +5 -5
- package/dist/safe-bash-compression-engine/index.js +4 -4
- package/dist/safe-bash-compression-engine/operand.js +5 -5
- package/dist/safe-bash-compression-engine/stream.js +4 -4
- package/dist/safe-bash-compression-engine/zstd-decode.js +3 -3
- package/dist/safe-bash-presentation-engine/accessibility.js +15 -15
- package/dist/safe-bash-presentation-engine/animation-editing.js +5 -5
- package/dist/safe-bash-presentation-engine/animations.js +5 -5
- package/dist/safe-bash-presentation-engine/backgrounds.js +6 -6
- package/dist/safe-bash-presentation-engine/chart-editing.js +18 -18
- package/dist/safe-bash-presentation-engine/chart-object-operations.js +12 -12
- package/dist/safe-bash-presentation-engine/charts.js +15 -15
- package/dist/safe-bash-presentation-engine/command-placeholder.js +39 -39
- package/dist/safe-bash-presentation-engine/comments.js +6 -6
- package/dist/safe-bash-presentation-engine/connector-operations.js +16 -16
- package/dist/safe-bash-presentation-engine/connectors.js +13 -13
- package/dist/safe-bash-presentation-engine/diff.js +21 -21
- package/dist/safe-bash-presentation-engine/drawing-format.js +7 -7
- package/dist/safe-bash-presentation-engine/drawing-operations.js +15 -15
- package/dist/safe-bash-presentation-engine/drawing-schema.js +8 -8
- package/dist/safe-bash-presentation-engine/equations.js +6 -6
- package/dist/safe-bash-presentation-engine/fields.js +6 -6
- package/dist/safe-bash-presentation-engine/image-extraction.js +7 -7
- package/dist/safe-bash-presentation-engine/image-formatting.js +16 -16
- package/dist/safe-bash-presentation-engine/image-insertion.js +6 -6
- package/dist/safe-bash-presentation-engine/image-replacement.js +7 -7
- package/dist/safe-bash-presentation-engine/images.js +6 -6
- package/dist/safe-bash-presentation-engine/index.js +104 -104
- package/dist/safe-bash-presentation-engine/layouts.js +5 -5
- package/dist/safe-bash-presentation-engine/links.js +5 -5
- package/dist/safe-bash-presentation-engine/masters.js +4 -4
- package/dist/safe-bash-presentation-engine/media-editing.js +13 -13
- package/dist/safe-bash-presentation-engine/media-extraction.js +7 -7
- package/dist/safe-bash-presentation-engine/media.js +6 -6
- package/dist/safe-bash-presentation-engine/memberships.js +5 -5
- package/dist/safe-bash-presentation-engine/notes.js +6 -6
- package/dist/safe-bash-presentation-engine/ole-insertion.js +6 -6
- package/dist/safe-bash-presentation-engine/opaque-objects.js +2 -2
- package/dist/safe-bash-presentation-engine/package-tools.js +6 -6
- package/dist/safe-bash-presentation-engine/presentation-model.js +38 -38
- package/dist/safe-bash-presentation-engine/presentation-settings.js +5 -5
- package/dist/safe-bash-presentation-engine/properties.js +6 -6
- package/dist/safe-bash-presentation-engine/retained-inspection.js +3 -3
- package/dist/safe-bash-presentation-engine/retained-text.js +16 -16
- package/dist/safe-bash-presentation-engine/sanitize.js +7 -7
- package/dist/safe-bash-presentation-engine/selectors.js +2 -2
- package/dist/safe-bash-presentation-engine/shape-groups.js +15 -15
- package/dist/safe-bash-presentation-engine/shape-operations.js +14 -14
- package/dist/safe-bash-presentation-engine/shape-path-operations.js +16 -16
- package/dist/safe-bash-presentation-engine/shape-paths.js +5 -5
- package/dist/safe-bash-presentation-engine/shape-selection.js +15 -15
- package/dist/safe-bash-presentation-engine/shape-transforms.js +5 -5
- package/dist/safe-bash-presentation-engine/shapes.js +11 -11
- package/dist/safe-bash-presentation-engine/slide-copy.js +7 -7
- package/dist/safe-bash-presentation-engine/slide-import.js +6 -6
- package/dist/safe-bash-presentation-engine/slide-merge-split.js +8 -8
- package/dist/safe-bash-presentation-engine/slide-model.js +25 -25
- package/dist/safe-bash-presentation-engine/slide-removal.js +7 -7
- package/dist/safe-bash-presentation-engine/slide-transfer-budget.js +2 -2
- package/dist/safe-bash-presentation-engine/slides.js +5 -5
- package/dist/safe-bash-presentation-engine/table-operations.js +17 -17
- package/dist/safe-bash-presentation-engine/table-spans.js +16 -16
- package/dist/safe-bash-presentation-engine/tables.js +15 -15
- package/dist/safe-bash-presentation-engine/tags.js +6 -6
- package/dist/safe-bash-presentation-engine/template-bindings.js +16 -16
- package/dist/safe-bash-presentation-engine/template-repeat.js +26 -26
- package/dist/safe-bash-presentation-engine/text-fitting.js +11 -11
- package/dist/safe-bash-presentation-engine/text-frames.js +11 -11
- package/dist/safe-bash-presentation-engine/text-paragraphs.js +11 -11
- package/dist/safe-bash-presentation-engine/text-reading.js +3 -3
- package/dist/safe-bash-presentation-engine/text-replacement.js +6 -6
- package/dist/safe-bash-presentation-engine/text-runs.js +8 -8
- package/dist/safe-bash-presentation-engine/themes.js +5 -5
- package/dist/safe-bash-presentation-engine/transitions.js +6 -6
- package/dist/safe-bash-presentation-engine/validation.js +2 -2
- package/dist/safe-bash-presentation-engine/xml-parts.js +5 -5
- package/dist/safe-bash-sqlite-engine/safe-fs.d.ts +6 -0
- package/dist/safe-bash-sqlite-engine/safe-fs.js +1 -1
- package/dist/safe-bash-sqlite-engine/sqlite-attachments.d.ts +5 -0
- package/dist/safe-bash-sqlite-engine/sqlite-input-snapshots.d.ts +20 -0
- package/dist/safe-bash-sqlite-engine/sqlite-query-records.d.ts +9 -0
- package/dist/safe-bash-sqlite-engine/sqlite-read-session.d.ts +3 -16
- package/dist/safe-bash-sqlite-engine/sqlite-session.d.ts +4 -0
- package/dist/safe-bash-sqlite-engine/sqlite-statement.d.ts +4 -0
- package/dist/safe-bash-sqlite-engine/storage.d.ts +2 -0
- package/dist/safe-bash-sqlite-engine/storage.js +324 -31
- package/dist/safe-bash-sqlite-engine/types.d.ts +1 -0
- package/package.json +12 -2
- package/dist/safe-bash/command-chunks/{biff-AYJZR2YV-YFF3BK43.js → biff-AYJZR2YV-2BK47I2W.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-SKDJCMGI.js → chunk-ATUZ7J3B.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-4Q4R3VZU.js → chunk-ETFJ4L7F.js} +0 -0
- package/dist/safe-bash/command-chunks/{chunk-QWHBQBPB.js → chunk-EXDMIGZY.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-SKF6PGA5.js → chunk-I2OKE2NI.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-2H6RJPCQ.js → chunk-JDDZRKC4.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-3TP4SSPS.js → chunk-SRXARACJ.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-D54L2IOZ.js → chunk-Y7UXJ77P.js} +3 -3
- package/dist/safe-bash/command-chunks/{dif-BXKPQOCO-FVJYYGYB.js → dif-BXKPQOCO-4KB3RC6G.js} +4 -4
- package/dist/safe-bash/command-chunks/{sylk-25D7TL2Y-NJKBZZTF.js → sylk-25D7TL2Y-RU6ANKGT.js} +4 -4
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createPythonPackageEnvironment,
|
|
3
3
|
createPythonPackageManifestStore,
|
|
4
|
-
|
|
5
|
-
pythonDocumentPackages
|
|
6
|
-
|
|
7
|
-
} from "./chunk-WDTWJFPK.js";
|
|
4
|
+
publishPythonBuildWheel,
|
|
5
|
+
pythonDocumentPackages
|
|
6
|
+
} from "./chunk-RZOHZGEZ.js";
|
|
8
7
|
import {
|
|
9
8
|
pythonShellDispatchActive
|
|
10
9
|
} from "./chunk-NHAG4DWL.js";
|
|
10
|
+
import {
|
|
11
|
+
openPythonPackageFile
|
|
12
|
+
} from "./chunk-NXCJNPL3.js";
|
|
11
13
|
import {
|
|
12
14
|
PythonInvocationError,
|
|
13
|
-
parsePythonInvocation
|
|
14
|
-
|
|
15
|
+
parsePythonInvocation,
|
|
16
|
+
pythonPackageUrlHash
|
|
17
|
+
} from "./chunk-WY6THI6J.js";
|
|
15
18
|
import {
|
|
16
19
|
pythonLlmProvider
|
|
17
20
|
} from "./chunk-YYRVGXJH.js";
|
|
@@ -113,11 +116,13 @@ function encodePythonReply(value, maxBytes) {
|
|
|
113
116
|
}
|
|
114
117
|
|
|
115
118
|
// packages/safe-bash-command-python/src/installation.ts
|
|
116
|
-
var
|
|
119
|
+
var PythonInstallationError = class extends Error {
|
|
120
|
+
};
|
|
121
|
+
var pythonInstallationHelp = `Usage: python -m pip install [OPTIONS] PACKAGE ...
|
|
117
122
|
python -m pip uninstall [-y/--yes] PACKAGE ...
|
|
118
|
-
Install
|
|
119
|
-
|
|
120
|
-
Both accept -h/--help and --.
|
|
123
|
+
Install: -r/--requirement FILE, -e/--editable PATH, --pre, -U/--upgrade,
|
|
124
|
+
--force-reinstall, --no-cache-dir
|
|
125
|
+
Both accept -h/--help and --.
|
|
121
126
|
`;
|
|
122
127
|
function parsePythonInstallation(pipArgs) {
|
|
123
128
|
const controls = {};
|
|
@@ -138,12 +143,9 @@ function parsePythonInstallation(pipArgs) {
|
|
|
138
143
|
packages.push(option);
|
|
139
144
|
continue;
|
|
140
145
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
if (!uninstall && (option === "-U" || option === "--upgrade" || option === "--force-reinstall")) {
|
|
146
|
-
controls[option === "--force-reinstall" ? "forceReinstall" : "upgrade"] = true;
|
|
146
|
+
const flag = { "--pre": "pre", "--no-cache-dir": "noCache", "-U": "upgrade", "--upgrade": "upgrade", "--force-reinstall": "forceReinstall" }[option];
|
|
147
|
+
if (!uninstall && flag) {
|
|
148
|
+
controls[flag] = true;
|
|
147
149
|
continue;
|
|
148
150
|
}
|
|
149
151
|
if (option === "--") {
|
|
@@ -158,15 +160,19 @@ function parsePythonInstallation(pipArgs) {
|
|
|
158
160
|
yes = true;
|
|
159
161
|
continue;
|
|
160
162
|
}
|
|
161
|
-
if (!uninstall
|
|
162
|
-
const
|
|
163
|
-
if (
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
if (!uninstall) {
|
|
164
|
+
const kind = ["requirement", "editable"].find((name) => option.startsWith("-" + name[0]) || option.split("=", 1)[0] === "--" + name);
|
|
165
|
+
if (kind) {
|
|
166
|
+
const prefix = "--" + kind;
|
|
167
|
+
const path = option.startsWith(prefix + "=") ? option.slice(prefix.length + 1) : option === prefix || option.length === 2 ? pipArgs[++index] : option.slice(2);
|
|
168
|
+
if (!path || path.startsWith("-")) throw new PythonInvocationError(option + " requires a path");
|
|
169
|
+
(kind === "editable" ? controls.editable ??= [] : requirements).push(path);
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
166
172
|
}
|
|
167
173
|
throw new PythonInvocationError("unsupported pip option " + option);
|
|
168
174
|
}
|
|
169
|
-
if (!help && packages.length === 0 && requirements.length === 0) throw new PythonInvocationError("pip " + pipArgs[0] + " requires at least one package or requirements file");
|
|
175
|
+
if (!help && packages.length === 0 && requirements.length === 0 && !controls.editable?.length) throw new PythonInvocationError("pip " + pipArgs[0] + " requires at least one package or requirements file");
|
|
170
176
|
return { packages, requirements, help, controls, ...uninstall ? { uninstall, yes } : {} };
|
|
171
177
|
}
|
|
172
178
|
|
|
@@ -845,7 +851,7 @@ function createPythonLlmToolLoader(options) {
|
|
|
845
851
|
const queue = [];
|
|
846
852
|
let waiter;
|
|
847
853
|
let serial3 = 0, controls = 0, loaded = false, initializationFailed = false, closed = false, closing;
|
|
848
|
-
const
|
|
854
|
+
const encoder2 = new TextEncoder();
|
|
849
855
|
const fail = (error) => {
|
|
850
856
|
ready.reject(error);
|
|
851
857
|
queue.length = 0;
|
|
@@ -930,7 +936,7 @@ function createPythonLlmToolLoader(options) {
|
|
|
930
936
|
return null;
|
|
931
937
|
}
|
|
932
938
|
if (message.op === "register" || message.op === "toolbox" || message.op === "plugins") {
|
|
933
|
-
controls +=
|
|
939
|
+
controls += encoder2.encode(JSON.stringify(message)).length;
|
|
934
940
|
if (controls > maxInputBytes) throw new RangeError("Python tool definition byte limit exceeded");
|
|
935
941
|
}
|
|
936
942
|
if (message.op === "plugins") {
|
|
@@ -1000,7 +1006,7 @@ function createPythonLlmToolLoader(options) {
|
|
|
1000
1006
|
let bytes, target = job.output;
|
|
1001
1007
|
if (message.op === "text") {
|
|
1002
1008
|
if (typeof message.text !== "string" || message.text.length > 8192) throw new TypeError("Invalid Python tool output window");
|
|
1003
|
-
bytes =
|
|
1009
|
+
bytes = encoder2.encode(message.text);
|
|
1004
1010
|
if (bytes.length > 16384) throw new TypeError("Invalid Python tool output window");
|
|
1005
1011
|
} else {
|
|
1006
1012
|
if (!Array.isArray(message.bytes) || message.bytes.length > 4096 || message.bytes.some((value2) => typeof value2 !== "number" || !Number.isInteger(value2) || value2 < 0 || value2 > 255)) throw new TypeError("Invalid Python attachment window");
|
|
@@ -1016,7 +1022,7 @@ function createPythonLlmToolLoader(options) {
|
|
|
1016
1022
|
if (message.op === "attachment") {
|
|
1017
1023
|
const metadata = record(message.descriptor);
|
|
1018
1024
|
if (typeof metadata.mimeType !== "string" || typeof metadata.id !== "string" || metadata.url !== void 0 && typeof metadata.url !== "string") throw new TypeError("Invalid Python tool attachment");
|
|
1019
|
-
const size =
|
|
1025
|
+
const size = encoder2.encode(JSON.stringify(metadata)).length;
|
|
1020
1026
|
if (size > job.limit - job.bytes) throw new RangeError("Python tool attachment metadata limit exceeded");
|
|
1021
1027
|
job.bytes += size;
|
|
1022
1028
|
const index = job.attachments.length;
|
|
@@ -1097,6 +1103,7 @@ function createPythonLlmToolLoader(options) {
|
|
|
1097
1103
|
function createPythonBuildEnvironment(options = {}) {
|
|
1098
1104
|
const manifestStore = createPythonPackageManifestStore({ maxEntries: 1, ...options.maxManifestBytes === void 0 ? {} : { maxBytes: options.maxManifestBytes } });
|
|
1099
1105
|
const isolated = { ...options, manifestStore, scope: "build" };
|
|
1106
|
+
delete isolated.editable;
|
|
1100
1107
|
delete isolated.requirements;
|
|
1101
1108
|
delete isolated.requirementFiles;
|
|
1102
1109
|
delete isolated.profile;
|
|
@@ -1110,14 +1117,58 @@ function createPythonBuildEnvironment(options = {}) {
|
|
|
1110
1117
|
// packages/safe-bash-command-python/src/build-dependencies.ts
|
|
1111
1118
|
import { toByteSource as toByteSource6 } from "../../safe-bash-contracts/index.js";
|
|
1112
1119
|
|
|
1120
|
+
// packages/safe-bash-command-python/src/source-origin-program.generated.ts
|
|
1121
|
+
var pythonSourceOriginProgram = "def read_source_origin(request):\n import re, json\n from urllib.parse import urlsplit, urlunsplit\n source = request['source']\n if source.startswith('/'):\n from pathlib import Path\n source = Path(source).as_uri()\n url = urlsplit(source)\n netloc = url.netloc\n if '@' in netloc:\n credentials, host = netloc.split('@', 1)\n if not re.match(r'^\\$\\{[A-Za-z0-9-_]+\\}(:\\$\\{[A-Za-z0-9-_]+\\})?$', credentials): netloc = host\n result = {'url': urlunsplit((url.scheme, netloc, url.path, url.query, ''))}\n subdirectory = re.search(r'[#&]subdirectory=([^&]*)', source)\n if subdirectory: result['subdirectory'] = subdirectory.group(1)\n info = {}\n if not request['directory']:\n hashed = re.search(r'(sha1|sha224|sha384|sha256|sha512|md5)=([a-f0-9]+)', source)\n if hashed: info['hash'] = hashed.group(1) + '=' + hashed.group(2)\n result['dir_info' if request['directory'] else 'archive_info'] = info\n return json.dumps(result, sort_keys=True)\n";
|
|
1122
|
+
|
|
1123
|
+
// packages/safe-bash-command-python/src/source-filename-program.ts
|
|
1124
|
+
var pythonDownloadFilenameProgram = /* @__PURE__ */ (() => String.raw`
|
|
1125
|
+
MIME_PREFERENCES = {"application/andrew-inset":".ez","application/applixware":".aw","application/atom+xml":".atom","application/atomcat+xml":".atomcat","application/atomsvc+xml":".atomsvc","application/ccxml+xml":".ccxml","application/cdmi-capability":".cdmia","application/cdmi-container":".cdmic","application/cdmi-domain":".cdmid","application/cdmi-object":".cdmio","application/cdmi-queue":".cdmiq","application/cu-seeme":".cu","application/davmount+xml":".davmount","application/docbook+xml":".dbk","application/dssc+der":".dssc","application/dssc+xml":".xdssc","application/ecmascript":".ecma","application/emma+xml":".emma","application/epub+zip":".epub","application/exi":".exi","application/font-tdpfr":".pfr","application/gml+xml":".gml","application/gpx+xml":".gpx","application/gxf":".gxf","application/hyperstudio":".stk","application/inkml+xml":".ink","application/ipfix":".ipfix","application/java-archive":".jar","application/java-serialized-object":".ser","application/java-vm":".class","application/json":".json","application/jsonml+json":".jsonml","application/lost+xml":".lostxml","application/mac-binhex40":".hqx","application/mac-compactpro":".cpt","application/mads+xml":".mads","application/manifest+json":".webmanifest","application/marc":".mrc","application/marcxml+xml":".mrcx","application/mathematica":".ma","application/mathml+xml":".mathml","application/mbox":".mbox","application/mediaservercontrol+xml":".mscml","application/metalink+xml":".metalink","application/metalink4+xml":".meta4","application/mets+xml":".mets","application/mods+xml":".mods","application/mp21":".m21","application/mp4":".mp4s","application/msword":".doc","application/mxf":".mxf","application/octet-stream":".bin","application/oda":".oda","application/oebps-package+xml":".opf","application/ogg":".ogx","application/omdoc+xml":".omdoc","application/onenote":".onetoc","application/oxps":".oxps","application/patch-ops-error+xml":".xer","application/pdf":".pdf","application/pgp-encrypted":".pgp","application/pgp-signature":".asc","application/pics-rules":".prf","application/pkcs10":".p10","application/pkcs7-mime":".p7c","application/pkcs7-signature":".p7s","application/pkcs8":".p8","application/pkix-attr-cert":".ac","application/pkix-cert":".cer","application/pkix-crl":".crl","application/pkix-pkipath":".pkipath","application/pkixcmp":".pki","application/pls+xml":".pls","application/postscript":".ps","application/prs.cww":".cww","application/pskc+xml":".pskcxml","application/rdf+xml":".rdf","application/reginfo+xml":".rif","application/relax-ng-compact-syntax":".rnc","application/resource-lists+xml":".rl","application/resource-lists-diff+xml":".rld","application/rls-services+xml":".rs","application/rpki-ghostbusters":".gbr","application/rpki-manifest":".mft","application/rpki-roa":".roa","application/rsd+xml":".rsd","application/rss+xml":".rss","application/rtf":".rtf","application/sbml+xml":".sbml","application/scvp-cv-request":".scq","application/scvp-cv-response":".scs","application/scvp-vp-request":".spq","application/scvp-vp-response":".spp","application/sdp":".sdp","application/set-payment-initiation":".setpay","application/set-registration-initiation":".setreg","application/shf+xml":".shf","application/smil+xml":".smi","application/sparql-query":".rq","application/sparql-results+xml":".srx","application/srgs":".gram","application/srgs+xml":".grxml","application/sru+xml":".sru","application/ssdl+xml":".ssdl","application/ssml+xml":".ssml","application/tei+xml":".tei","application/thraud+xml":".tfi","application/timestamped-data":".tsd","application/vnd.3gpp.pic-bw-large":".plb","application/vnd.3gpp.pic-bw-small":".psb","application/vnd.3gpp.pic-bw-var":".pvb","application/vnd.3gpp2.tcap":".tcap","application/vnd.3m.post-it-notes":".pwn","application/vnd.accpac.simply.aso":".aso","application/vnd.accpac.simply.imp":".imp","application/vnd.acucobol":".acu","application/vnd.acucorp":".atc","application/vnd.adobe.air-application-installer-package+zip":".air","application/vnd.adobe.formscentral.fcdt":".fcdt","application/vnd.adobe.fxp":".fxp","application/vnd.adobe.xdp+xml":".xdp","application/vnd.adobe.xfdf":".xfdf","application/vnd.ahead.space":".ahead","application/vnd.airzip.filesecure.azf":".azf","application/vnd.airzip.filesecure.azs":".azs","application/vnd.amazon.ebook":".azw","application/vnd.americandynamics.acc":".acc","application/vnd.amiga.ami":".ami","application/vnd.android.package-archive":".apk","application/vnd.anser-web-certificate-issue-initiation":".cii","application/vnd.anser-web-funds-transfer-initiation":".fti","application/vnd.antix.game-component":".atx","application/vnd.apple.installer+xml":".mpkg","application/vnd.aristanetworks.swi":".swi","application/vnd.astraea-software.iota":".iota","application/vnd.audiograph":".aep","application/vnd.blueice.multipass":".mpm","application/vnd.bmi":".bmi","application/vnd.businessobjects":".rep","application/vnd.chemdraw+xml":".cdxml","application/vnd.chipnuts.karaoke-mmd":".mmd","application/vnd.cinderella":".cdy","application/vnd.claymore":".cla","application/vnd.cloanto.rp9":".rp9","application/vnd.clonk.c4group":".c4g","application/vnd.cluetrust.cartomobile-config":".c11amc","application/vnd.cluetrust.cartomobile-config-pkg":".c11amz","application/vnd.commonspace":".csp","application/vnd.contact.cmsg":".cdbcmsg","application/vnd.cosmocaller":".cmc","application/vnd.crick.clicker":".clkx","application/vnd.crick.clicker.keyboard":".clkk","application/vnd.crick.clicker.palette":".clkp","application/vnd.crick.clicker.template":".clkt","application/vnd.crick.clicker.wordbank":".clkw","application/vnd.criticaltools.wbs+xml":".wbs","application/vnd.ctc-posml":".pml","application/vnd.cups-ppd":".ppd","application/vnd.curl.car":".car","application/vnd.curl.pcurl":".pcurl","application/vnd.dart":".dart","application/vnd.data-vision.rdz":".rdz","application/vnd.dece.data":".uvf","application/vnd.dece.ttml+xml":".uvt","application/vnd.dece.unspecified":".uvx","application/vnd.dece.zip":".uvz","application/vnd.denovo.fcselayout-link":".fe_launch","application/vnd.dna":".dna","application/vnd.dolby.mlp":".mlp","application/vnd.dpgraph":".dpg","application/vnd.dreamfactory":".dfac","application/vnd.ds-keypoint":".kpxx","application/vnd.dvb.ait":".ait","application/vnd.dvb.service":".svc","application/vnd.dynageo":".geo","application/vnd.ecowin.chart":".mag","application/vnd.enliven":".nml","application/vnd.epson.esf":".esf","application/vnd.epson.msf":".msf","application/vnd.epson.quickanime":".qam","application/vnd.epson.salt":".slt","application/vnd.epson.ssf":".ssf","application/vnd.eszigno3+xml":".es3","application/vnd.ezpix-album":".ez2","application/vnd.ezpix-package":".ez3","application/vnd.fdf":".fdf","application/vnd.fdsn.mseed":".mseed","application/vnd.fdsn.seed":".seed","application/vnd.flographit":".gph","application/vnd.fluxtime.clip":".ftc","application/vnd.framemaker":".fm","application/vnd.frogans.fnc":".fnc","application/vnd.frogans.ltf":".ltf","application/vnd.fsc.weblaunch":".fsc","application/vnd.fujitsu.oasys":".oas","application/vnd.fujitsu.oasys2":".oa2","application/vnd.fujitsu.oasys3":".oa3","application/vnd.fujitsu.oasysgp":".fg5","application/vnd.fujitsu.oasysprs":".bh2","application/vnd.fujixerox.ddd":".ddd","application/vnd.fujixerox.docuworks":".xdw","application/vnd.fujixerox.docuworks.binder":".xbd","application/vnd.fuzzysheet":".fzs","application/vnd.genomatix.tuxedo":".txd","application/vnd.geogebra.file":".ggb","application/vnd.geogebra.slides":".ggs","application/vnd.geogebra.tool":".ggt","application/vnd.geometry-explorer":".gex","application/vnd.geonext":".gxt","application/vnd.geoplan":".g2w","application/vnd.geospace":".g3w","application/vnd.gmx":".gmx","application/vnd.google-earth.kml+xml":".kml","application/vnd.google-earth.kmz":".kmz","application/vnd.grafeq":".gqf","application/vnd.groove-account":".gac","application/vnd.groove-help":".ghf","application/vnd.groove-identity-message":".gim","application/vnd.groove-injector":".grv","application/vnd.groove-tool-message":".gtm","application/vnd.groove-tool-template":".tpl","application/vnd.groove-vcard":".vcg","application/vnd.hal+xml":".hal","application/vnd.handheld-entertainment+xml":".zmm","application/vnd.hbci":".hbci","application/vnd.hhe.lesson-player":".les","application/vnd.hp-hpgl":".hpgl","application/vnd.hp-hpid":".hpid","application/vnd.hp-hps":".hps","application/vnd.hp-jlyt":".jlt","application/vnd.hp-pcl":".pcl","application/vnd.hp-pclxl":".pclxl","application/vnd.hydrostatix.sof-data":".sfd-hdstx","application/vnd.ibm.minipay":".mpy","application/vnd.ibm.modcap":".afp","application/vnd.ibm.rights-management":".irm","application/vnd.ibm.secure-container":".sc","application/vnd.iccprofile":".icc","application/vnd.igloader":".igl","application/vnd.immervision-ivp":".ivp","application/vnd.immervision-ivu":".ivu","application/vnd.insors.igm":".igm","application/vnd.intercon.formnet":".xpw","application/vnd.intergeo":".i2g","application/vnd.intu.qbo":".qbo","application/vnd.intu.qfx":".qfx","application/vnd.ipunplugged.rcprofile":".rcprofile","application/vnd.irepository.package+xml":".irp","application/vnd.is-xpr":".xpr","application/vnd.isac.fcs":".fcs","application/vnd.jam":".jam","application/vnd.jcp.javame.midlet-rms":".rms","application/vnd.jisp":".jisp","application/vnd.joost.joda-archive":".joda","application/vnd.kahootz":".ktz","application/vnd.kde.karbon":".karbon","application/vnd.kde.kchart":".chrt","application/vnd.kde.kformula":".kfo","application/vnd.kde.kivio":".flw","application/vnd.kde.kontour":".kon","application/vnd.kde.kpresenter":".kpr","application/vnd.kde.kspread":".ksp","application/vnd.kde.kword":".kwd","application/vnd.kenameaapp":".htke","application/vnd.kidspiration":".kia","application/vnd.kinar":".kne","application/vnd.koan":".skp","application/vnd.kodak-descriptor":".sse","application/vnd.las.las+xml":".lasxml","application/vnd.llamagraphics.life-balance.desktop":".lbd","application/vnd.llamagraphics.life-balance.exchange+xml":".lbe","application/vnd.lotus-1-2-3":".123","application/vnd.lotus-approach":".apr","application/vnd.lotus-freelance":".pre","application/vnd.lotus-notes":".nsf","application/vnd.lotus-organizer":".org","application/vnd.lotus-screencam":".scm","application/vnd.lotus-wordpro":".lwp","application/vnd.macports.portpkg":".portpkg","application/vnd.mcd":".mcd","application/vnd.medcalcdata":".mc1","application/vnd.mediastation.cdkey":".cdkey","application/vnd.mfer":".mwf","application/vnd.mfmp":".mfm","application/vnd.micrografx.flo":".flo","application/vnd.micrografx.igx":".igx","application/vnd.mif":".mif","application/vnd.mobius.daf":".daf","application/vnd.mobius.dis":".dis","application/vnd.mobius.mbk":".mbk","application/vnd.mobius.mqy":".mqy","application/vnd.mobius.msl":".msl","application/vnd.mobius.plc":".plc","application/vnd.mobius.txf":".txf","application/vnd.mophun.application":".mpn","application/vnd.mophun.certificate":".mpc","application/vnd.mozilla.xul+xml":".xul","application/vnd.ms-artgalry":".cil","application/vnd.ms-cab-compressed":".cab","application/vnd.ms-excel":".xls","application/vnd.ms-excel.addin.macroenabled.12":".xlam","application/vnd.ms-excel.sheet.binary.macroenabled.12":".xlsb","application/vnd.ms-excel.sheet.macroenabled.12":".xlsm","application/vnd.ms-excel.template.macroenabled.12":".xltm","application/vnd.ms-fontobject":".eot","application/vnd.ms-htmlhelp":".chm","application/vnd.ms-ims":".ims","application/vnd.ms-lrm":".lrm","application/vnd.ms-officetheme":".thmx","application/vnd.ms-pki.seccat":".cat","application/vnd.ms-pki.stl":".stl","application/vnd.ms-powerpoint":".ppt","application/vnd.ms-powerpoint.addin.macroenabled.12":".ppam","application/vnd.ms-powerpoint.presentation.macroenabled.12":".pptm","application/vnd.ms-powerpoint.slide.macroenabled.12":".sldm","application/vnd.ms-powerpoint.slideshow.macroenabled.12":".ppsm","application/vnd.ms-powerpoint.template.macroenabled.12":".potm","application/vnd.ms-project":".mpp","application/vnd.ms-word.document.macroenabled.12":".docm","application/vnd.ms-word.template.macroenabled.12":".dotm","application/vnd.ms-works":".wps","application/vnd.ms-wpl":".wpl","application/vnd.ms-xpsdocument":".xps","application/vnd.mseq":".mseq","application/vnd.musician":".mus","application/vnd.muvee.style":".msty","application/vnd.mynfc":".taglet","application/vnd.neurolanguage.nlu":".nlu","application/vnd.nitf":".ntf","application/vnd.noblenet-directory":".nnd","application/vnd.noblenet-sealer":".nns","application/vnd.noblenet-web":".nnw","application/vnd.nokia.n-gage.data":".ngdat","application/vnd.nokia.n-gage.symbian.install":".n-gage","application/vnd.nokia.radio-preset":".rpst","application/vnd.nokia.radio-presets":".rpss","application/vnd.novadigm.edm":".edm","application/vnd.novadigm.edx":".edx","application/vnd.novadigm.ext":".ext","application/vnd.oasis.opendocument.chart":".odc","application/vnd.oasis.opendocument.chart-template":".otc","application/vnd.oasis.opendocument.database":".odb","application/vnd.oasis.opendocument.formula":".odf","application/vnd.oasis.opendocument.formula-template":".odft","application/vnd.oasis.opendocument.graphics":".odg","application/vnd.oasis.opendocument.graphics-template":".otg","application/vnd.oasis.opendocument.image":".odi","application/vnd.oasis.opendocument.image-template":".oti","application/vnd.oasis.opendocument.presentation":".odp","application/vnd.oasis.opendocument.presentation-template":".otp","application/vnd.oasis.opendocument.spreadsheet":".ods","application/vnd.oasis.opendocument.spreadsheet-template":".ots","application/vnd.oasis.opendocument.text":".odt","application/vnd.oasis.opendocument.text-master":".odm","application/vnd.oasis.opendocument.text-template":".ott","application/vnd.oasis.opendocument.text-web":".oth","application/vnd.olpc-sugar":".xo","application/vnd.oma.dd2+xml":".dd2","application/vnd.openofficeorg.extension":".oxt","application/vnd.openxmlformats-officedocument.presentationml.presentation":".pptx","application/vnd.openxmlformats-officedocument.presentationml.slide":".sldx","application/vnd.openxmlformats-officedocument.presentationml.slideshow":".ppsx","application/vnd.openxmlformats-officedocument.presentationml.template":".potx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":".xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.template":".xltx","application/vnd.openxmlformats-officedocument.wordprocessingml.document":".docx","application/vnd.openxmlformats-officedocument.wordprocessingml.template":".dotx","application/vnd.osgeo.mapguide.package":".mgp","application/vnd.osgi.dp":".dp","application/vnd.osgi.subsystem":".esa","application/vnd.palm":".pdb","application/vnd.pawaafile":".paw","application/vnd.pg.format":".str","application/vnd.pg.osasli":".ei6","application/vnd.picsel":".efif","application/vnd.pmi.widget":".wg","application/vnd.pocketlearn":".plf","application/vnd.powerbuilder6":".pbd","application/vnd.previewsystems.box":".box","application/vnd.proteus.magazine":".mgz","application/vnd.publishare-delta-tree":".qps","application/vnd.pvi.ptid1":".ptid","application/vnd.quark.quarkxpress":".qxd","application/vnd.realvnc.bed":".bed","application/vnd.recordare.musicxml":".mxl","application/vnd.recordare.musicxml+xml":".musicxml","application/vnd.rig.cryptonote":".cryptonote","application/vnd.rim.cod":".cod","application/vnd.rn-realmedia":".rm","application/vnd.rn-realmedia-vbr":".rmvb","application/vnd.route66.link66+xml":".link66","application/vnd.sailingtracker.track":".st","application/vnd.seemail":".see","application/vnd.sema":".sema","application/vnd.semd":".semd","application/vnd.semf":".semf","application/vnd.shana.informed.formdata":".ifm","application/vnd.shana.informed.formtemplate":".itp","application/vnd.shana.informed.interchange":".iif","application/vnd.shana.informed.package":".ipk","application/vnd.simtech-mindmapper":".twd","application/vnd.smaf":".mmf","application/vnd.smart.teacher":".teacher","application/vnd.solent.sdkm+xml":".sdkm","application/vnd.spotfire.dxp":".dxp","application/vnd.spotfire.sfs":".sfs","application/vnd.stardivision.calc":".sdc","application/vnd.stardivision.draw":".sda","application/vnd.stardivision.impress":".sdd","application/vnd.stardivision.math":".smf","application/vnd.stardivision.writer":".sdw","application/vnd.stardivision.writer-global":".sgl","application/vnd.stepmania.package":".smzip","application/vnd.stepmania.stepchart":".sm","application/vnd.sun.xml.calc":".sxc","application/vnd.sun.xml.calc.template":".stc","application/vnd.sun.xml.draw":".sxd","application/vnd.sun.xml.draw.template":".std","application/vnd.sun.xml.impress":".sxi","application/vnd.sun.xml.impress.template":".sti","application/vnd.sun.xml.math":".sxm","application/vnd.sun.xml.writer":".sxw","application/vnd.sun.xml.writer.global":".sxg","application/vnd.sun.xml.writer.template":".stw","application/vnd.sus-calendar":".sus","application/vnd.svd":".svd","application/vnd.symbian.install":".sis","application/vnd.syncml+xml":".xsm","application/vnd.syncml.dm+wbxml":".bdm","application/vnd.syncml.dm+xml":".xdm","application/vnd.tao.intent-module-archive":".tao","application/vnd.tcpdump.pcap":".pcap","application/vnd.tmobile-livetv":".tmo","application/vnd.trid.tpt":".tpt","application/vnd.triscape.mxs":".mxs","application/vnd.trueapp":".tra","application/vnd.ufdl":".ufd","application/vnd.uiq.theme":".utz","application/vnd.umajin":".umj","application/vnd.unity":".unityweb","application/vnd.uoml+xml":".uoml","application/vnd.vcx":".vcx","application/vnd.visio":".vsd","application/vnd.visionary":".vis","application/vnd.vsf":".vsf","application/vnd.wap.wbxml":".wbxml","application/vnd.wap.wmlc":".wmlc","application/vnd.wap.wmlscriptc":".wmlsc","application/vnd.webturbo":".wtb","application/vnd.wolfram.player":".nbp","application/vnd.wordperfect":".wpd","application/vnd.wqd":".wqd","application/vnd.wt.stf":".stf","application/vnd.xara":".xar","application/vnd.xfdl":".xfdl","application/vnd.yamaha.hv-dic":".hvd","application/vnd.yamaha.hv-script":".hvs","application/vnd.yamaha.hv-voice":".hvp","application/vnd.yamaha.openscoreformat":".osf","application/vnd.yamaha.openscoreformat.osfpvg+xml":".osfpvg","application/vnd.yamaha.smaf-audio":".saf","application/vnd.yamaha.smaf-phrase":".spf","application/vnd.yellowriver-custom-menu":".cmp","application/vnd.zul":".zir","application/vnd.zzazz.deck+xml":".zaz","application/voicexml+xml":".vxml","application/wasm":".wasm","application/widget":".wgt","application/winhlp":".hlp","application/wsdl+xml":".wsdl","application/wspolicy+xml":".wspolicy","application/x-7z-compressed":".7z","application/x-abiword":".abw","application/x-ace-compressed":".ace","application/x-apple-diskimage":".dmg","application/x-authorware-bin":".aab","application/x-authorware-map":".aam","application/x-authorware-seg":".aas","application/x-bcpio":".bcpio","application/x-bittorrent":".torrent","application/x-blorb":".blb","application/x-bzip":".bz","application/x-bzip2":".bz2","application/x-cbr":".cbr","application/x-cdlink":".vcd","application/x-cfs-compressed":".cfs","application/x-chat":".chat","application/x-chess-pgn":".pgn","application/x-conference":".nsc","application/x-cpio":".cpio","application/x-csh":".csh","application/x-debian-package":".deb","application/x-dgc-compressed":".dgc","application/x-director":".dir","application/x-doom":".wad","application/x-dtbncx+xml":".ncx","application/x-dtbook+xml":".dtb","application/x-dtbresource+xml":".res","application/x-dvi":".dvi","application/x-envoy":".evy","application/x-eva":".eva","application/x-font-bdf":".bdf","application/x-font-ghostscript":".gsf","application/x-font-linux-psf":".psf","application/x-font-pcf":".pcf","application/x-font-snf":".snf","application/x-font-type1":".pfa","application/x-freearc":".arc","application/x-futuresplash":".spl","application/x-gca-compressed":".gca","application/x-glulx":".ulx","application/x-gnumeric":".gnumeric","application/x-gramps-xml":".gramps","application/x-gtar":".gtar","application/x-hdf":".hdf","application/x-install-instructions":".install","application/x-iso9660-image":".iso","application/x-java-jnlp-file":".jnlp","application/x-latex":".latex","application/x-lzh-compressed":".lzh","application/x-mie":".mie","application/x-mobipocket-ebook":".prc","application/x-mpegurl":".m3u8","application/x-ms-application":".application","application/x-ms-shortcut":".lnk","application/x-ms-wmd":".wmd","application/x-ms-xbap":".xbap","application/x-msaccess":".mdb","application/x-msbinder":".obd","application/x-mscardfile":".crd","application/x-msclip":".clp","application/x-msdownload":".exe","application/x-msmediaview":".mvb","application/x-msmetafile":".wmf","application/x-msmoney":".mny","application/x-mspublisher":".pub","application/x-msschedule":".scd","application/x-msterminal":".trm","application/x-mswrite":".wri","application/x-netcdf":".cdf","application/x-nzb":".nzb","application/x-pkcs12":".p12","application/x-pkcs7-certificates":".p7b","application/x-pkcs7-certreqresp":".p7r","application/x-python-code":".pyc","application/x-rar-compressed":".rar","application/x-research-info-systems":".ris","application/x-sh":".sh","application/x-shar":".shar","application/x-shockwave-flash":".swf","application/x-silverlight-app":".xap","application/x-sql":".sql","application/x-stuffit":".sit","application/x-stuffitx":".sitx","application/x-subrip":".srt","application/x-sv4cpio":".sv4cpio","application/x-sv4crc":".sv4crc","application/x-t3vm-image":".t3","application/x-tads":".gam","application/x-tar":".tar","application/x-tcl":".tcl","application/x-tex":".tex","application/x-tex-tfm":".tfm","application/x-texinfo":".texi","application/x-tgif":".obj","application/x-ustar":".ustar","application/x-wais-source":".src","application/x-x509-ca-cert":".der","application/x-xfig":".fig","application/x-xliff+xml":".xlf","application/x-xpinstall":".xpi","application/x-xz":".xz","application/x-zmachine":".z1","application/xaml+xml":".xaml","application/xcap-diff+xml":".xdf","application/xenc+xml":".xenc","application/xhtml+xml":".xhtml","application/xml":".xsl","application/xml-dtd":".dtd","application/xop+xml":".xop","application/xproc+xml":".xpl","application/xslt+xml":".xslt","application/xspf+xml":".xspf","application/xv+xml":".mxml","application/yang":".yang","application/yin+xml":".yin","application/zip":".zip","audio/adpcm":".adp","audio/basic":".au","audio/midi":".mid","audio/mp4":".m4a","audio/mp4a-latm":".m4a","audio/mpeg":".mp3","audio/ogg":".oga","audio/s3m":".s3m","audio/silk":".sil","audio/vnd.dece.audio":".uva","audio/vnd.digital-winds":".eol","audio/vnd.dra":".dra","audio/vnd.dts":".dts","audio/vnd.dts.hd":".dtshd","audio/vnd.lucent.voice":".lvp","audio/vnd.ms-playready.media.pya":".pya","audio/vnd.nuera.ecelp4800":".ecelp4800","audio/vnd.nuera.ecelp7470":".ecelp7470","audio/vnd.nuera.ecelp9600":".ecelp9600","audio/vnd.rip":".rip","audio/webm":".weba","audio/x-aac":".aac","audio/x-aiff":".aif","audio/x-caf":".caf","audio/x-flac":".flac","audio/x-matroska":".mka","audio/x-mpegurl":".m3u","audio/x-ms-wax":".wax","audio/x-ms-wma":".wma","audio/x-pn-realaudio":".ra","audio/x-pn-realaudio-plugin":".rmp","audio/x-wav":".wav","audio/xm":".xm","chemical/x-cdx":".cdx","chemical/x-cif":".cif","chemical/x-cmdf":".cmdf","chemical/x-cml":".cml","chemical/x-csml":".csml","chemical/x-xyz":".xyz","font/collection":".ttc","font/otf":".otf","font/ttf":".ttf","font/woff":".woff","font/woff2":".woff2","image/avif":".avif","image/bmp":".bmp","image/cgm":".cgm","image/g3fax":".g3","image/gif":".gif","image/ief":".ief","image/jp2":".jp2","image/jpeg":".jpg","image/jxl":".jxl","image/ktx":".ktx","image/pict":".pict","image/png":".png","image/prs.btif":".btif","image/sgi":".sgi","image/svg+xml":".svg","image/tiff":".tiff","image/vnd.adobe.photoshop":".psd","image/vnd.dece.graphic":".uvi","image/vnd.djvu":".djvu","image/vnd.dwg":".dwg","image/vnd.dxf":".dxf","image/vnd.fastbidsheet":".fbs","image/vnd.fpx":".fpx","image/vnd.fst":".fst","image/vnd.fujixerox.edmics-mmr":".mmr","image/vnd.fujixerox.edmics-rlc":".rlc","image/vnd.ms-modi":".mdi","image/vnd.ms-photo":".wdp","image/vnd.net-fpx":".npx","image/vnd.wap.wbmp":".wbmp","image/vnd.xiff":".xif","image/webp":".webp","image/x-3ds":".3ds","image/x-cmu-raster":".ras","image/x-cmx":".cmx","image/x-freehand":".fh","image/x-icon":".ico","image/x-macpaint":".pntg","image/x-mrsid-image":".sid","image/x-pcx":".pcx","image/x-pict":".pic","image/x-portable-anymap":".pnm","image/x-portable-bitmap":".pbm","image/x-portable-graymap":".pgm","image/x-portable-pixmap":".ppm","image/x-quicktime":".qtif","image/x-rgb":".rgb","image/x-tga":".tga","image/x-xbitmap":".xbm","image/x-xpixmap":".xpm","image/x-xwindowdump":".xwd","message/rfc822":".eml","model/iges":".igs","model/mesh":".msh","model/vnd.collada+xml":".dae","model/vnd.dwf":".dwf","model/vnd.gdl":".gdl","model/vnd.gtw":".gtw","model/vnd.vtu":".vtu","model/vrml":".wrl","model/x3d+binary":".x3db","model/x3d+vrml":".x3dv","model/x3d+xml":".x3d","text/cache-manifest":".manifest","text/calendar":".ics","text/css":".css","text/csv":".csv","text/html":".html","text/javascript":".js","text/n3":".n3","text/plain":".txt","text/prs.lines.tag":".dsc","text/richtext":".rtx","text/sgml":".sgml","text/tab-separated-values":".tsv","text/troff":".t","text/turtle":".ttl","text/uri-list":".uri","text/vcard":".vcard","text/vnd.curl":".curl","text/vnd.curl.dcurl":".dcurl","text/vnd.curl.mcurl":".mcurl","text/vnd.curl.scurl":".scurl","text/vnd.dvb.subtitle":".sub","text/vnd.fly":".fly","text/vnd.fmi.flexstor":".flx","text/vnd.graphviz":".gv","text/vnd.in3d.3dml":".3dml","text/vnd.in3d.spot":".spot","text/vnd.sun.j2me.app-descriptor":".jad","text/vnd.wap.wml":".wml","text/vnd.wap.wmlscript":".wmls","text/x-asm":".s","text/x-c":".c","text/x-fortran":".f","text/x-java-source":".java","text/x-nfo":".nfo","text/x-opml":".opml","text/x-pascal":".p","text/x-python":".py","text/x-setext":".etx","text/x-sfv":".sfv","text/x-uuencode":".uu","text/x-vcalendar":".vcs","text/x-vcard":".vcf","video/3gpp":".3gp","video/3gpp2":".3g2","video/h261":".h261","video/h263":".h263","video/h264":".h264","video/jpeg":".jpgv","video/jpm":".jpm","video/mj2":".mj2","video/mp2t":".ts","video/mp4":".mp4","video/mpeg":".mpeg","video/ogg":".ogv","video/quicktime":".mov","video/vnd.dece.hd":".uvh","video/vnd.dece.mobile":".uvm","video/vnd.dece.pd":".uvp","video/vnd.dece.sd":".uvs","video/vnd.dece.video":".uvv","video/vnd.dvb.file":".dvb","video/vnd.fvt":".fvt","video/vnd.mpegurl":".mxu","video/vnd.ms-playready.media.pyv":".pyv","video/vnd.uvvu.mp4":".uvu","video/vnd.vivo":".viv","video/webm":".webm","video/x-dv":".dv","video/x-f4v":".f4v","video/x-fli":".fli","video/x-flv":".flv","video/x-m4v":".m4v","video/x-matroska":".mkv","video/x-mng":".mng","video/x-ms-asf":".asf","video/x-ms-vob":".vob","video/x-ms-wm":".wm","video/x-ms-wmv":".wmv","video/x-ms-wmx":".wmx","video/x-ms-wvx":".wvx","video/x-msvideo":".avi","video/x-sgi-movie":".movie","video/x-smv":".smv","x-conference/x-cooltalk":".ice"}
|
|
1126
|
+
|
|
1127
|
+
def read_download_filename(request):
|
|
1128
|
+
from urllib.parse import urlsplit, unquote
|
|
1129
|
+
import posixpath
|
|
1130
|
+
url = urlsplit(request['source'])
|
|
1131
|
+
filename = unquote(posixpath.basename(url.path.rstrip('/'))) or url.netloc.rsplit('@', 1)[-1]
|
|
1132
|
+
headers = {key.lower(): value for key, value in request['headers']}
|
|
1133
|
+
# CPython 3.9 cgi.parse_header rules, including last duplicate wins.
|
|
1134
|
+
remaining = ';' + headers.get('content-disposition', '')
|
|
1135
|
+
parameters = []
|
|
1136
|
+
while remaining[:1] == ';':
|
|
1137
|
+
remaining = remaining[1:]
|
|
1138
|
+
end = remaining.find(';')
|
|
1139
|
+
while end > 0 and (remaining.count('"', 0, end) - remaining.count('\\"', 0, end)) % 2:
|
|
1140
|
+
end = remaining.find(';', end + 1)
|
|
1141
|
+
if end < 0: end = len(remaining)
|
|
1142
|
+
parameters.append(remaining[:end].strip())
|
|
1143
|
+
remaining = remaining[end:]
|
|
1144
|
+
selected = None
|
|
1145
|
+
for parameter in parameters[1:]:
|
|
1146
|
+
if '=' not in parameter: continue
|
|
1147
|
+
key, value = parameter.split('=', 1)
|
|
1148
|
+
if key.strip().lower() != 'filename': continue
|
|
1149
|
+
value = value.strip()
|
|
1150
|
+
if len(value) >= 2 and value[0] == value[-1] == '"':
|
|
1151
|
+
value = value[1:-1].replace('\\\\', '\\').replace('\\"', '"')
|
|
1152
|
+
selected = posixpath.basename(value) if value else ''
|
|
1153
|
+
filename = selected or filename
|
|
1154
|
+
ext = posixpath.splitext(filename)[1]
|
|
1155
|
+
if not ext:
|
|
1156
|
+
ext = MIME_PREFERENCES.get(headers.get('content-type', '').lower())
|
|
1157
|
+
if ext: filename += ext
|
|
1158
|
+
if not ext and request['source'] != request['responseUrl']:
|
|
1159
|
+
ext = posixpath.splitext(request['responseUrl'])[1]
|
|
1160
|
+
if ext: filename += ext
|
|
1161
|
+
return filename
|
|
1162
|
+
`)();
|
|
1163
|
+
|
|
1113
1164
|
// packages/safe-bash-command-python/src/build-backend.ts
|
|
1114
1165
|
import { toByteSource as toByteSource5 } from "../../safe-bash-contracts/index.js";
|
|
1115
1166
|
function createPythonBuildBackend(options) {
|
|
1116
1167
|
if (!options.createExecutor || !options.environment || options.provisioning) throw new TypeError("Python build hooks require an asynchronous executor and explicit environment");
|
|
1117
1168
|
const capabilities = /* @__PURE__ */ new WeakMap();
|
|
1118
|
-
const environment = options.environment;
|
|
1169
|
+
const environment = options.environment, legacy = /* @__PURE__ */ new WeakSet();
|
|
1119
1170
|
const command = createPythonExecutorCommands({ ...options, environment: { ...environment, async prepare(context) {
|
|
1120
|
-
return { ...await environment.prepare(context), bootstrap: true };
|
|
1171
|
+
return { ...await environment.prepare(context), bootstrap: true, ...context.args && legacy.has(context.args) ? { bootstrapPackages: ["setuptools"] } : {} };
|
|
1121
1172
|
} }, createCapabilities(context) {
|
|
1122
1173
|
const provided = options.createCapabilities?.(context) ?? {};
|
|
1123
1174
|
if (provided.python_build) throw new Error("Python build capability is reserved");
|
|
@@ -1129,12 +1180,20 @@ function createPythonBuildBackend(options) {
|
|
|
1129
1180
|
context.signal.throwIfAborted();
|
|
1130
1181
|
const { maxBytes } = context;
|
|
1131
1182
|
if (maxBytes !== Infinity && (!Number.isSafeInteger(maxBytes) || maxBytes < 0)) throw new RangeError("Invalid Python build metadata limit");
|
|
1132
|
-
if (!input || !["read_build_system", "check_build_requirements", "get_requires_for_build_wheel", "build_wheel"].includes(input.hook) || typeof input.source !== "string" || !input.source) throw new TypeError("Invalid Python build hook request");
|
|
1133
|
-
if (input.hook === "
|
|
1183
|
+
if (!input || !["read_source_origin", "read_download_filename", "read_editable_requirement", "get_requires_for_legacy_wheel", "read_source_requirement", "read_build_system", "check_build_requirements", "get_requires_for_build_wheel", "build_wheel", "build_legacy_wheel"].includes(input.hook) || typeof input.source !== "string" || !input.source) throw new TypeError("Invalid Python build hook request");
|
|
1184
|
+
if (input.hook === "read_editable_requirement" && input.requirementLine !== void 0 && typeof input.requirementLine !== "boolean") throw new TypeError("Invalid editable requirement line");
|
|
1185
|
+
if (input.hook === "read_source_origin") {
|
|
1186
|
+
if (typeof input.directory !== "boolean") throw new TypeError("Invalid Python source origin");
|
|
1187
|
+
} else if (input.hook === "read_download_filename") {
|
|
1188
|
+
if (typeof input.responseUrl !== "string" || !Array.isArray(input.headers) || input.headers.some((pair) => !Array.isArray(pair) || pair.length !== 2 || pair.some((value) => typeof value !== "string"))) throw new TypeError("Invalid Python download metadata");
|
|
1189
|
+
} else if (input.hook === "build_legacy_wheel") {
|
|
1190
|
+
if (typeof input.wheelDirectory !== "string" || !input.wheelDirectory || input.editable !== void 0 && typeof input.editable !== "boolean") throw new TypeError("Invalid Python legacy wheel directory");
|
|
1191
|
+
} else if (input.hook === "check_build_requirements") {
|
|
1134
1192
|
if ([input.requirements, input.installed].some((values) => !Array.isArray(values) || values.some((value) => typeof value !== "string"))) throw new TypeError("Invalid Python build requirements request");
|
|
1135
1193
|
} else if (input.hook === "read_build_system") {
|
|
1194
|
+
if (input.installation !== void 0 && !["directory", "archive"].includes(input.installation)) throw new TypeError("Invalid Python source installation");
|
|
1136
1195
|
if (input.name !== void 0 && typeof input.name !== "string" || input.usePep517 !== void 0 && typeof input.usePep517 !== "boolean") throw new TypeError("Invalid Python build system request");
|
|
1137
|
-
} else {
|
|
1196
|
+
} else if (input.hook !== "read_source_requirement" && input.hook !== "read_editable_requirement" && input.hook !== "get_requires_for_legacy_wheel") {
|
|
1138
1197
|
if (typeof input.backend !== "string" || !input.backend || input.backendPath !== void 0 && (!Array.isArray(input.backendPath) || input.backendPath.some((path) => typeof path !== "string")) || input.hook === "build_wheel" && (typeof input.wheelDirectory !== "string" || !input.wheelDirectory || input.metadataDirectory !== void 0 && typeof input.metadataDirectory !== "string")) throw new TypeError("Invalid Python build hook request");
|
|
1139
1198
|
if (input.configSettings !== void 0 && (!input.configSettings || typeof input.configSettings !== "object" || Array.isArray(input.configSettings) || Object.values(input.configSettings).some((value) => typeof value !== "string" && (!Array.isArray(value) || value.some((item) => typeof item !== "string"))))) throw new TypeError("Invalid Python build configuration");
|
|
1140
1199
|
}
|
|
@@ -1142,6 +1201,7 @@ function createPythonBuildBackend(options) {
|
|
|
1142
1201
|
let done = false, size = 0, failure;
|
|
1143
1202
|
const chunks = [];
|
|
1144
1203
|
const invocation = { ...context, command: "python", args: ["-c", pythonBuildBackendProgram], stdin: toByteSource5("") };
|
|
1204
|
+
if (request.hook === "build_legacy_wheel" || request.hook === "get_requires_for_legacy_wheel") legacy.add(invocation.args);
|
|
1145
1205
|
capabilities.set(invocation.args, { async call(value) {
|
|
1146
1206
|
try {
|
|
1147
1207
|
context.signal.throwIfAborted();
|
|
@@ -1150,7 +1210,7 @@ function createPythonBuildBackend(options) {
|
|
|
1150
1210
|
if (message.op === "request") return request;
|
|
1151
1211
|
if (message.op === "error") {
|
|
1152
1212
|
if (typeof message.type !== "string" || typeof message.message !== "string") throw new TypeError("Invalid Python build failure");
|
|
1153
|
-
failure ??= Object.assign(new Error(message.message), { name: message.type });
|
|
1213
|
+
failure ??= Object.assign(message.type === "InstallationError" ? new PythonInstallationError(message.message) : new Error(message.message), { name: message.type });
|
|
1154
1214
|
done = true;
|
|
1155
1215
|
return null;
|
|
1156
1216
|
}
|
|
@@ -1176,7 +1236,12 @@ function createPythonBuildBackend(options) {
|
|
|
1176
1236
|
if (result.exitCode) throw new Error(`Python build interpreter exited with status ${result.exitCode}`);
|
|
1177
1237
|
if (!done) throw new Error("Python build interpreter returned no result");
|
|
1178
1238
|
const value = JSON.parse(chunks.join(""));
|
|
1179
|
-
if (request.hook === "
|
|
1239
|
+
if (request.hook === "read_source_origin" || request.hook === "read_download_filename") {
|
|
1240
|
+
if (typeof value !== "string") throw new TypeError("Invalid Python download filename");
|
|
1241
|
+
} else if (request.hook === "read_source_requirement" || request.hook === "read_editable_requirement") {
|
|
1242
|
+
const result2 = value;
|
|
1243
|
+
if (result2 !== null && (!result2 || typeof result2.name !== "string" || typeof result2.url !== "string" || typeof result2.active !== "boolean" || result2.marker !== null && typeof result2.marker !== "string" || !Array.isArray(result2.extras) || result2.extras.some((extra) => typeof extra !== "string"))) throw new TypeError("Invalid Python source requirement");
|
|
1244
|
+
} else if (request.hook === "check_build_requirements") {
|
|
1180
1245
|
const result2 = value;
|
|
1181
1246
|
if (!result2 || !Array.isArray(result2.missing) || result2.missing.some((value2) => typeof value2 !== "string") || !Array.isArray(result2.conflicting) || result2.conflicting.some((pair) => !Array.isArray(pair) || pair.length !== 2 || pair.some((value2) => typeof value2 !== "string"))) throw new TypeError("Invalid Python build requirement status");
|
|
1182
1247
|
} else if (request.hook === "read_build_system") {
|
|
@@ -1185,21 +1250,26 @@ function createPythonBuildBackend(options) {
|
|
|
1185
1250
|
const details = value;
|
|
1186
1251
|
if (typeof details.backend !== "string" || !details.backend || ["requires", "check", "backendPath"].some((key) => !Array.isArray(details[key]) || details[key].some((item) => typeof item !== "string"))) throw new TypeError("Invalid Python build system");
|
|
1187
1252
|
}
|
|
1188
|
-
} else if (request.hook === "build_wheel") {
|
|
1253
|
+
} else if (request.hook === "build_wheel" || request.hook === "build_legacy_wheel") {
|
|
1189
1254
|
if (typeof value !== "string" || !value.endsWith(".whl") || value.includes("/") || value.includes("\\") || value.includes("\0")) throw new TypeError("Invalid Python build wheel filename");
|
|
1190
1255
|
} else if (!Array.isArray(value) || value.some((item) => typeof item !== "string")) throw new TypeError("Invalid Python build requirements");
|
|
1191
1256
|
return value;
|
|
1192
1257
|
} finally {
|
|
1193
1258
|
capabilities.delete(invocation.args);
|
|
1259
|
+
legacy.delete(invocation.args);
|
|
1194
1260
|
}
|
|
1195
1261
|
};
|
|
1196
1262
|
}
|
|
1197
1263
|
var pythonBuildBackendProgram = /* @__PURE__ */ (() => String.raw`
|
|
1198
1264
|
import importlib, json, os, sys, safe_host
|
|
1265
|
+
${pythonDownloadFilenameProgram}
|
|
1199
1266
|
|
|
1200
1267
|
def send(op, **fields):
|
|
1201
1268
|
return safe_host.call('python_build', dict(op=op, **fields))
|
|
1202
1269
|
|
|
1270
|
+
|
|
1271
|
+
${pythonSourceOriginProgram}
|
|
1272
|
+
|
|
1203
1273
|
def parse_build_requirement(value):
|
|
1204
1274
|
from urllib.parse import urlparse, urlunparse
|
|
1205
1275
|
from micropip._vendored.packaging.src.packaging.requirements import Requirement, InvalidRequirement
|
|
@@ -1234,6 +1304,8 @@ def read_build_system(request):
|
|
|
1234
1304
|
source = request['source']
|
|
1235
1305
|
filename = os.path.join(source, 'pyproject.toml')
|
|
1236
1306
|
has_project, has_setup = os.path.isfile(filename), os.path.isfile(os.path.join(source, 'setup.py'))
|
|
1307
|
+
if request.get('installation') == 'directory' and not has_project and not has_setup:
|
|
1308
|
+
raise InstallationError("Directory {!r} is not installable. Neither 'setup.py' nor 'pyproject.toml' found.".format(request.get('name', source)))
|
|
1237
1309
|
system = None
|
|
1238
1310
|
if has_project:
|
|
1239
1311
|
limit = request['maxBytes']
|
|
@@ -1248,7 +1320,10 @@ def read_build_system(request):
|
|
|
1248
1320
|
if selected is False: raise InstallationError('Disabling PEP 517 processing is invalid: project specifies a build backend of {} in pyproject.toml'.format(system['build-backend']))
|
|
1249
1321
|
selected = True
|
|
1250
1322
|
elif selected is None: selected = has_project
|
|
1251
|
-
if not selected:
|
|
1323
|
+
if not selected:
|
|
1324
|
+
if request.get('installation') and not os.path.exists(os.path.join(source, 'setup.py')):
|
|
1325
|
+
raise InstallationError('File "setup.py" not found for legacy project {}.'.format(request.get('name', source)))
|
|
1326
|
+
return None
|
|
1252
1327
|
defaults = ['setuptools>=40.8.0', 'wheel']
|
|
1253
1328
|
if system is None: system = {'requires': defaults, 'build-backend': 'setuptools.build_meta:__legacy__'}
|
|
1254
1329
|
def invalid(reason):
|
|
@@ -1263,8 +1338,75 @@ def read_build_system(request):
|
|
|
1263
1338
|
backend = system.get('build-backend')
|
|
1264
1339
|
return dict(requires=requirements, backend=backend if backend is not None else 'setuptools.build_meta:__legacy__', check=defaults if backend is None else [], backendPath=system.get('backend-path', []))
|
|
1265
1340
|
|
|
1341
|
+
def build_legacy_wheel(request):
|
|
1342
|
+
source = os.path.realpath(request['source'])
|
|
1343
|
+
directory = os.path.abspath(request['wheelDirectory'])
|
|
1344
|
+
filename = os.path.join(source, 'setup.py')
|
|
1345
|
+
os.chdir(source)
|
|
1346
|
+
sys.path.insert(0, '')
|
|
1347
|
+
sys.argv = [filename, 'bdist_wheel', '-d', directory]
|
|
1348
|
+
namespace = dict(__name__='__main__', __file__=filename)
|
|
1349
|
+
try:
|
|
1350
|
+
exec("import io, os, sys, setuptools, tokenize\nsys.argv[0] = __file__\nf = getattr(tokenize, 'open', open)(__file__) if os.path.exists(__file__) else io.StringIO('from setuptools import setup; setup()')\ncode = f.read().replace('\\r\\n', '\\n')\nf.close()\nexec(compile(code, __file__, 'exec'))", namespace)
|
|
1351
|
+
except SystemExit as error:
|
|
1352
|
+
if error.code not in (None, 0): raise
|
|
1353
|
+
first = None
|
|
1354
|
+
with os.scandir(directory) as entries:
|
|
1355
|
+
for entry in entries:
|
|
1356
|
+
if first is None or entry.name < first: first = entry.name
|
|
1357
|
+
if first is None: raise RuntimeError('Legacy wheel build created no files')
|
|
1358
|
+
return first
|
|
1359
|
+
|
|
1360
|
+
def read_source_requirement(request):
|
|
1361
|
+
from micropip._vendored.packaging.src.packaging.requirements import InvalidRequirement
|
|
1362
|
+
try: requirement = parse_build_requirement(request['source'])
|
|
1363
|
+
except InvalidRequirement: return None
|
|
1364
|
+
if not requirement.url: return None
|
|
1365
|
+
marker = requirement.marker
|
|
1366
|
+
return dict(name=requirement.name, extras=sorted({'_'.join(part for part in extra.lower().split('_') if part) for extra in requirement.extras}), url=requirement.url, marker=str(marker) if marker else None, active=not marker or marker.evaluate({'extra': ''}))
|
|
1367
|
+
|
|
1368
|
+
def read_editable_requirement(request):
|
|
1369
|
+
from pathlib import Path
|
|
1370
|
+
from micropip._vendored.packaging.src.packaging.requirements import Requirement
|
|
1371
|
+
class InstallationError(Exception): pass
|
|
1372
|
+
source, extras = request['source'], None
|
|
1373
|
+
if request.get('requirementLine'):
|
|
1374
|
+
import shlex, optparse
|
|
1375
|
+
class OptionParsingError(Exception): pass
|
|
1376
|
+
class Parser(optparse.OptionParser):
|
|
1377
|
+
def exit(self, status=0, message=None): raise OptionParsingError(message)
|
|
1378
|
+
parser = Parser(add_help_option=False)
|
|
1379
|
+
parser.add_option('-e', '--editable', action='append', dest='editables')
|
|
1380
|
+
options, _ = parser.parse_args(shlex.split(source))
|
|
1381
|
+
if not options.editables: raise InstallationError('Editable requirement line requires -e')
|
|
1382
|
+
source = options.editables[0]
|
|
1383
|
+
start = source.rfind('[')
|
|
1384
|
+
if start > 0 and source.endswith(']') and start < len(source) - 2 and ']' not in source[start + 1:-1]:
|
|
1385
|
+
source, extras = source[:start], source[start:]
|
|
1386
|
+
if os.path.isdir(source):
|
|
1387
|
+
if not any(os.path.exists(os.path.join(source, name)) for name in ('setup.py', 'setup.cfg')):
|
|
1388
|
+
message = 'File "setup.py" or "setup.cfg" not found. Directory cannot be installed in editable mode: {}'.format(os.path.abspath(source))
|
|
1389
|
+
if os.path.isfile(os.path.join(source, 'pyproject.toml')): message += '\n(A "pyproject.toml" file was found, but editable mode currently requires a setuptools-based build.)'
|
|
1390
|
+
raise InstallationError(message)
|
|
1391
|
+
source = Path(os.path.abspath(source)).as_uri()
|
|
1392
|
+
if not source.lower().startswith('file:'): raise InstallationError('Editable source requires a local directory')
|
|
1393
|
+
name = ''
|
|
1394
|
+
for index, character in enumerate(source):
|
|
1395
|
+
if character in '#&' and source.startswith('egg=', index + 1):
|
|
1396
|
+
name = source[index + 5:].split('&', 1)[0]
|
|
1397
|
+
break
|
|
1398
|
+
return dict(name=name, url=source, extras=sorted(Requirement('placeholder' + extras.lower()).extras) if extras else [], marker=None, active=True)
|
|
1399
|
+
|
|
1266
1400
|
def main():
|
|
1267
1401
|
request = send('request')
|
|
1402
|
+
if request['hook'] == 'get_requires_for_legacy_wheel': request.update(hook='get_requires_for_build_wheel', backend='setuptools.build_meta:__legacy__')
|
|
1403
|
+
if request['hook'] == 'read_source_origin': return read_source_origin(request)
|
|
1404
|
+
if request['hook'] == 'read_download_filename': return read_download_filename(request)
|
|
1405
|
+
if request['hook'] == 'read_source_requirement': return read_source_requirement(request)
|
|
1406
|
+
if request['hook'] == 'read_editable_requirement': return read_editable_requirement(request)
|
|
1407
|
+
if request['hook'] == 'build_legacy_wheel':
|
|
1408
|
+
if not request.get('editable'): return build_legacy_wheel(request)
|
|
1409
|
+
request.update(hook='build_wheel', backend='setuptools.build_meta:__legacy__')
|
|
1268
1410
|
if request['hook'] == 'read_build_system': return read_build_system(request)
|
|
1269
1411
|
if request['hook'] == 'check_build_requirements': return check_build_requirements(request)
|
|
1270
1412
|
source = os.path.realpath(request['source'])
|
|
@@ -1290,7 +1432,8 @@ def main():
|
|
|
1290
1432
|
except AttributeError: result = []
|
|
1291
1433
|
else: result = hook(settings)
|
|
1292
1434
|
else:
|
|
1293
|
-
result = backend.
|
|
1435
|
+
if request.get('editable'): result = backend.build_editable(wheel_directory, {'editable_mode': 'compat'}, metadata_directory)
|
|
1436
|
+
else: result = backend.build_wheel(wheel_directory, settings, metadata_directory)
|
|
1294
1437
|
return result
|
|
1295
1438
|
|
|
1296
1439
|
try:
|
|
@@ -1312,7 +1455,7 @@ function createPythonBuildDependencies(options) {
|
|
|
1312
1455
|
const context = { ...caller };
|
|
1313
1456
|
context.signal.throwIfAborted();
|
|
1314
1457
|
const request = structuredClone(input), { source, buildSystem, configSettings } = request;
|
|
1315
|
-
if (typeof source !== "string" || !source || request.name !== void 0 && typeof request.name !== "string" || !buildSystem || typeof buildSystem.backend !== "string" || !buildSystem.backend || [buildSystem.requires, buildSystem.check, buildSystem.backendPath].some((values) => !Array.isArray(values) || values.some((value) => typeof value !== "string"))) throw new TypeError("Invalid Python build dependency request");
|
|
1458
|
+
if (typeof source !== "string" || !source || request.name !== void 0 && typeof request.name !== "string" || buildSystem !== null && (!buildSystem || typeof buildSystem.backend !== "string" || !buildSystem.backend || [buildSystem.requires, buildSystem.check, buildSystem.backendPath].some((values) => !Array.isArray(values) || values.some((value) => typeof value !== "string")))) throw new TypeError("Invalid Python build dependency request");
|
|
1316
1459
|
if (configSettings !== void 0 && (!configSettings || typeof configSettings !== "object" || Array.isArray(configSettings) || Object.values(configSettings).some((value) => typeof value !== "string" && (!Array.isArray(value) || value.some((item) => typeof item !== "string"))))) throw new TypeError("Invalid Python build configuration");
|
|
1317
1460
|
if (context.maxBytes !== Infinity && (!Number.isSafeInteger(context.maxBytes) || context.maxBytes < 0)) throw new RangeError("Invalid Python build metadata limit");
|
|
1318
1461
|
const install = async (requirements2) => {
|
|
@@ -1335,10 +1478,12 @@ function createPythonBuildDependencies(options) {
|
|
|
1335
1478
|
if (status.conflicting.length) throw Object.assign(new Error("Some build dependencies for " + (request.name ?? source) + " conflict with " + against + ": " + [...status.conflicting].sort(([a, b], [c, d]) => a < c ? -1 : a > c ? 1 : b < d ? -1 : b > d ? 1 : 0).map(([installed2, wanted]) => installed2 + " is incompatible with " + wanted).join(", ") + "."), { name: "InstallationError" });
|
|
1336
1479
|
return status.missing;
|
|
1337
1480
|
};
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1481
|
+
if (buildSystem) {
|
|
1482
|
+
await install(buildSystem.requires);
|
|
1483
|
+
const missing = await check(buildSystem.check, "PEP 517/518 supported requirements");
|
|
1484
|
+
if (missing.length) await context.stderr.write(new TextEncoder().encode("Missing build requirements in pyproject.toml for " + (request.name ?? source) + ".\nThe project does not specify a build backend, and pip cannot fall back to setuptools without " + missing.map((value) => "'" + value + "'").join(" and ") + ".\n"));
|
|
1485
|
+
}
|
|
1486
|
+
const requirements = await hook(buildSystem ? { hook: "get_requires_for_build_wheel", source, backend: buildSystem.backend, backendPath: buildSystem.backendPath, ...configSettings === void 0 ? {} : { configSettings } } : { hook: "get_requires_for_legacy_wheel", source }, context);
|
|
1342
1487
|
await install(await check(requirements, "the backend dependencies"));
|
|
1343
1488
|
};
|
|
1344
1489
|
}
|
|
@@ -1803,92 +1948,262 @@ del _install_safe_llm_import
|
|
|
1803
1948
|
}
|
|
1804
1949
|
}
|
|
1805
1950
|
|
|
1806
|
-
// packages/safe-bash-command-python/src/
|
|
1951
|
+
// packages/safe-bash-command-python/src/source-origin.ts
|
|
1807
1952
|
import { FsError as FsError3 } from "../../safe-bash-contracts/index.js";
|
|
1808
|
-
import { resolvePath as resolvePath2, basename } from "../../safe-bash-contracts/path.js";
|
|
1809
|
-
|
|
1810
|
-
const
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1953
|
+
import { resolvePath as resolvePath2, dirname, basename } from "../../safe-bash-contracts/path.js";
|
|
1954
|
+
function withPythonSourceOrigins(environment, directory, maxBytes) {
|
|
1955
|
+
const origins = /* @__PURE__ */ new Map(), encoder2 = new TextEncoder();
|
|
1956
|
+
return {
|
|
1957
|
+
...environment,
|
|
1958
|
+
async dispatch(operation, args, context) {
|
|
1959
|
+
const result = await environment.dispatch(operation, args, context), session = String(args[0]);
|
|
1960
|
+
if (operation === "package-open") {
|
|
1961
|
+
origins.delete(session);
|
|
1962
|
+
const url = new URL(String(args[1]));
|
|
1963
|
+
if (url.protocol === "file:" && url.hash.startsWith("#python-source=")) {
|
|
1964
|
+
const parent = dirname(decodeURIComponent(url.pathname));
|
|
1965
|
+
if (basename(parent) !== result.key) return result;
|
|
1966
|
+
let root;
|
|
1967
|
+
try {
|
|
1968
|
+
root = await context.fs.realpath(resolvePath2(context.cwd, directory), { signal: context.signal });
|
|
1969
|
+
} catch (error) {
|
|
1970
|
+
if (error instanceof FsError3 && error.code === "ENOENT") return result;
|
|
1971
|
+
throw error;
|
|
1972
|
+
}
|
|
1973
|
+
if (dirname(parent) !== root) return result;
|
|
1974
|
+
const origin = decodeURIComponent(url.hash.slice("#python-source=".length));
|
|
1975
|
+
if (encoder2.encode(origin).length > maxBytes) throw new RangeError("Python source origin exceeds maxMetadataBytes");
|
|
1976
|
+
origins.set(session, { key: result.key, origin });
|
|
1977
|
+
}
|
|
1978
|
+
} else if (operation === "package-retain") {
|
|
1979
|
+
const origin = origins.get(session);
|
|
1980
|
+
origins.delete(session);
|
|
1981
|
+
if (origin !== void 0) return { ...result, metadata: origin.origin === "null" ? {} : { "direct_url.json": origin.origin } };
|
|
1982
|
+
} else if (operation === "package-close" && origins.get(session)?.key === String(args[1])) origins.delete(session);
|
|
1983
|
+
return result;
|
|
1984
|
+
},
|
|
1985
|
+
finish(start) {
|
|
1986
|
+
origins.delete(start.session);
|
|
1987
|
+
return environment.finish(start);
|
|
1988
|
+
},
|
|
1989
|
+
async dispose() {
|
|
1990
|
+
try {
|
|
1991
|
+
await environment.dispose();
|
|
1992
|
+
} finally {
|
|
1993
|
+
origins.clear();
|
|
1994
|
+
}
|
|
1832
1995
|
}
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1996
|
+
};
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1999
|
+
// packages/safe-bash-command-python/src/source-environment.ts
|
|
2000
|
+
import { compareIdentity as compareIdentity2 } from "@poe-platform/safe-fs/core";
|
|
2001
|
+
import { FsError as FsError4, toByteSource as toByteSource7 } from "../../safe-bash-contracts/index.js";
|
|
2002
|
+
import { resolvePath as resolvePath4 } from "../../safe-bash-contracts/path.js";
|
|
2003
|
+
|
|
2004
|
+
// packages/safe-bash-command-python/src/source-download.ts
|
|
2005
|
+
import { dirname as dirname2, resolvePath as resolvePath3 } from "../../safe-bash-contracts/path.js";
|
|
2006
|
+
import { sha224, sha256, sha384, sha512 } from "@noble/hashes/sha2.js";
|
|
2007
|
+
import { sha1, md5 } from "@noble/hashes/legacy.js";
|
|
2008
|
+
async function* verifiedBytes(source, expected, maxBytes, signal) {
|
|
2009
|
+
const checksum = expected ? { sha1, sha224, sha384, sha256, sha512, md5 }[expected[0]].create() : void 0;
|
|
2010
|
+
let count = 0;
|
|
2011
|
+
try {
|
|
2012
|
+
for await (const bytes of source) {
|
|
2013
|
+
signal.throwIfAborted();
|
|
2014
|
+
if (!(bytes instanceof Uint8Array)) throw new TypeError("Python package body must yield bytes");
|
|
2015
|
+
if (bytes.length > maxBytes - count) throw new Error("Package download exceeds maxDownloadBytes");
|
|
2016
|
+
count += bytes.length;
|
|
2017
|
+
for (let offset = 0; offset < bytes.length; offset += 65536) {
|
|
2018
|
+
signal.throwIfAborted();
|
|
2019
|
+
const chunk = bytes.subarray(offset, offset + 65536);
|
|
2020
|
+
checksum?.update(chunk);
|
|
2021
|
+
yield chunk;
|
|
1840
2022
|
}
|
|
1841
|
-
}
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
2023
|
+
}
|
|
2024
|
+
if (checksum && Array.from(checksum.digest(), (byte) => byte.toString(16).padStart(2, "0")).join("") !== expected[1]) throw new Error("Python source archive integrity mismatch: " + expected[0]);
|
|
2025
|
+
} finally {
|
|
2026
|
+
checksum?.destroy();
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
async function downloadPythonSourceArchive(url, path, options, context) {
|
|
2030
|
+
const { fs, signal } = context, cacheDirectory = resolvePath3(context.cwd, options.cacheDirectory ?? dirname2(path));
|
|
2031
|
+
const caps = await fs.capabilitiesFor?.(cacheDirectory, { signal }) ?? fs.capabilities;
|
|
2032
|
+
if (!caps.retainedStagingWrite || !caps.retainedStagingCleanup || !caps.retainedRead || !caps.atomicFileStaging || !fs.createStagedFile || !fs.openReadFile || !fs.publishStagedFile || !fs.confineExtraction) throw new Error("Remote Python sources require retained caller storage");
|
|
2033
|
+
const output = await fs.confineExtraction([dirname2(path)], { signal });
|
|
2034
|
+
if (!output.writeStream) throw new Error("Remote Python sources require streaming writes");
|
|
2035
|
+
const expected = pythonPackageUrlHash(url.href), supplied = options.transport, maxBytes = options.maxDownloadBytes ?? Infinity;
|
|
2036
|
+
const transport = supplied && expected ? Object.assign(async (request) => {
|
|
2037
|
+
const response = await supplied(request);
|
|
2038
|
+
return response.status >= 200 && response.status < 300 ? {
|
|
2039
|
+
status: response.status,
|
|
2040
|
+
statusText: response.statusText,
|
|
2041
|
+
headers: response.headers,
|
|
2042
|
+
...response.httpVersion === void 0 ? {} : { httpVersion: response.httpVersion },
|
|
2043
|
+
...response.contentDecoded === void 0 ? {} : { contentDecoded: response.contentDecoded },
|
|
2044
|
+
body: verifiedBytes(response.body, expected, maxBytes, signal),
|
|
2045
|
+
dispose: response.dispose.bind(response)
|
|
2046
|
+
} : response;
|
|
2047
|
+
}, supplied.supportsPrivateNetworkDeny ? { supportsPrivateNetworkDeny: true } : {}) : supplied;
|
|
2048
|
+
const environment = createPythonBuildEnvironment({ ...options, ...transport ? { transport } : {}, cacheDirectory });
|
|
2049
|
+
try {
|
|
2050
|
+
const start = await environment.prepare({ ...context, requirements: [], requirementFiles: [] });
|
|
1847
2051
|
try {
|
|
1848
|
-
|
|
2052
|
+
const address = new URL(url);
|
|
2053
|
+
address.hash = "";
|
|
2054
|
+
const receipt = await environment.dispatch("package-open", [start.session, address.href], context);
|
|
2055
|
+
let consumed = false;
|
|
2056
|
+
const bytes = verifiedBytes((async function* () {
|
|
2057
|
+
for (let offset = 0; offset < receipt.size; ) {
|
|
2058
|
+
const chunk = await environment.dispatch("package-read", [start.session, receipt.key, offset, Math.min(65536, receipt.size - offset)], context);
|
|
2059
|
+
if (!chunk.length) throw new Error("Remote Python source ended early");
|
|
2060
|
+
offset += chunk.length;
|
|
2061
|
+
yield Uint8Array.from(chunk);
|
|
2062
|
+
}
|
|
2063
|
+
consumed = true;
|
|
2064
|
+
})(), expected, maxBytes, signal);
|
|
2065
|
+
try {
|
|
2066
|
+
await output.writeStream(path, bytes, { flag: "wx", mode: 384, signal });
|
|
2067
|
+
if (!consumed) throw new Error("Remote Python source write ended early");
|
|
2068
|
+
} finally {
|
|
2069
|
+
await bytes.return(void 0);
|
|
2070
|
+
}
|
|
2071
|
+
return { url: receipt.url, headers: receipt.headers };
|
|
1849
2072
|
} finally {
|
|
1850
|
-
await
|
|
2073
|
+
await environment.finish(start);
|
|
1851
2074
|
}
|
|
2075
|
+
} finally {
|
|
2076
|
+
await environment.dispose();
|
|
2077
|
+
}
|
|
2078
|
+
}
|
|
2079
|
+
async function snapshotPythonSourceArchive(source, path, url, maxBytes, context) {
|
|
2080
|
+
const { fs, signal } = context;
|
|
2081
|
+
if (!fs.writeStream) throw new Error("Local Python sources require streaming writes");
|
|
2082
|
+
const file = await openPythonPackageFile(context, source, maxBytes);
|
|
2083
|
+
if (!file) throw new Error("Local Python sources require retained reads");
|
|
2084
|
+
const bytes = verifiedBytes((async function* () {
|
|
2085
|
+
for (let offset = 0; offset < file.size; ) {
|
|
2086
|
+
const chunk = await file.read(offset, Math.min(65536, file.size - offset));
|
|
2087
|
+
offset += chunk.length;
|
|
2088
|
+
yield chunk;
|
|
2089
|
+
}
|
|
2090
|
+
})(), pythonPackageUrlHash(url), maxBytes, signal);
|
|
2091
|
+
let complete = false;
|
|
2092
|
+
try {
|
|
2093
|
+
await fs.writeStream(path, (async function* () {
|
|
2094
|
+
yield* bytes;
|
|
2095
|
+
complete = true;
|
|
2096
|
+
})(), { flag: "wx", mode: 384, signal });
|
|
2097
|
+
if (!complete) throw new Error("Local Python source write ended early");
|
|
1852
2098
|
} finally {
|
|
1853
2099
|
try {
|
|
1854
|
-
await
|
|
1855
|
-
});
|
|
2100
|
+
await bytes.return(void 0);
|
|
1856
2101
|
} finally {
|
|
1857
|
-
await
|
|
2102
|
+
await file.close();
|
|
1858
2103
|
}
|
|
1859
2104
|
}
|
|
1860
2105
|
}
|
|
1861
2106
|
|
|
1862
2107
|
// packages/safe-bash-command-python/src/source-environment.ts
|
|
1863
|
-
import { compareIdentity as compareIdentity2 } from "@poe-platform/safe-fs/core";
|
|
1864
|
-
import { FsError as FsError4, toByteSource as toByteSource7 } from "../../safe-bash-contracts/index.js";
|
|
1865
|
-
import { resolvePath as resolvePath3 } from "../../safe-bash-contracts/path.js";
|
|
1866
2108
|
var serial2 = 0;
|
|
2109
|
+
var archiveSuffix = (path) => [".zip", ".tar", ".tar.gz", ".tgz", ".tar.bz2", ".tbz", ".tar.xz", ".txz"].find((suffix) => path.toLowerCase().endsWith(suffix));
|
|
2110
|
+
var wheelLink = (url) => {
|
|
2111
|
+
let path = url.pathname;
|
|
2112
|
+
while (path.endsWith("/")) path = path.slice(0, -1);
|
|
2113
|
+
const parts = (path.slice(path.lastIndexOf("/") + 1) || url.host).split("%");
|
|
2114
|
+
let name = parts.shift();
|
|
2115
|
+
for (const part of parts) {
|
|
2116
|
+
const hex = part.slice(0, 2).toLowerCase();
|
|
2117
|
+
name += hex.length === 2 && [...hex].every((value) => "0123456789abcdef".includes(value)) ? String.fromCharCode(Number.parseInt(hex, 16)) + part.slice(2) : "%" + part;
|
|
2118
|
+
}
|
|
2119
|
+
name = name.slice(name.lastIndexOf("/") + 1);
|
|
2120
|
+
return name.endsWith(".whl") && name.slice(0, -4).split(".").some(Boolean);
|
|
2121
|
+
};
|
|
1867
2122
|
function createPythonSourcePackageEnvironment(options, build) {
|
|
1868
2123
|
if (options.prepareRequirements || !build.python.createExecutor || !build.directory) throw new TypeError("Source packages require an asynchronous build executor and caller storage");
|
|
1869
|
-
const prepareRequirement = async (requirement, context) => {
|
|
1870
|
-
const { fs, signal } = context, settings = { signal };
|
|
1871
|
-
|
|
1872
|
-
|
|
2124
|
+
const prepareRequirement = async (requirement, context, editable = false) => {
|
|
2125
|
+
const { fs, signal } = context, settings = { signal }, requirementLine = requirement.startsWith("-");
|
|
2126
|
+
editable ||= requirementLine;
|
|
2127
|
+
let source = requirement, named = null;
|
|
2128
|
+
let remote;
|
|
2129
|
+
const at = requirement.indexOf("@");
|
|
2130
|
+
let namedSource = false;
|
|
2131
|
+
if (at >= 0 && !requirement.startsWith("file:")) {
|
|
2132
|
+
const tail = requirement.slice(at + 1).trimStart();
|
|
2133
|
+
let end = 0;
|
|
2134
|
+
while (end < tail.length && ![" ", " ", "\r", "\n"].includes(tail[end])) end++;
|
|
2135
|
+
try {
|
|
2136
|
+
const url = new URL(tail.slice(0, end));
|
|
2137
|
+
namedSource = url.protocol === "file:" || ["http:", "https:"].includes(url.protocol) && !wheelLink(url);
|
|
2138
|
+
} catch {
|
|
2139
|
+
}
|
|
2140
|
+
}
|
|
2141
|
+
const editableExtras = editable && requirement.endsWith("]") && requirement.lastIndexOf("[") > 0;
|
|
2142
|
+
if (namedSource || editableExtras || requirementLine) {
|
|
2143
|
+
if (!context.stdout || !context.stderr || !context.env) throw new TypeError("Source requirement parsing requires command output and environment context");
|
|
2144
|
+
const environment2 = createPythonBuildEnvironment(options);
|
|
2145
|
+
const parsing = { ...context, env: context.env, stdout: context.stdout, stderr: context.stderr, maxBytes: options.maxMetadataBytes ?? Infinity };
|
|
2146
|
+
Reflect.deleteProperty(parsing, "editable");
|
|
2147
|
+
try {
|
|
2148
|
+
named = await createPythonBuildBackend({ ...build.python, environment: environment2 })({ hook: editableExtras || requirementLine ? "read_editable_requirement" : "read_source_requirement", source: requirement, ...requirementLine ? { requirementLine } : {} }, parsing);
|
|
2149
|
+
} finally {
|
|
2150
|
+
await environment2.dispose();
|
|
2151
|
+
}
|
|
2152
|
+
if (named) {
|
|
2153
|
+
if (!named.active) return requirement;
|
|
2154
|
+
source = named.url;
|
|
2155
|
+
}
|
|
2156
|
+
}
|
|
2157
|
+
const originalLink = source.slice(0, 5).toLowerCase() === "file:" || source.startsWith("https://") || source.startsWith("http://") ? source : void 0;
|
|
2158
|
+
let subdirectory;
|
|
2159
|
+
if (source.startsWith("file:") || source.startsWith("https://") || source.startsWith("http://")) {
|
|
2160
|
+
for (let index = 0; index < source.length; index++) if ((source[index] === "#" || source[index] === "&") && source.startsWith("subdirectory=", index + 1)) {
|
|
2161
|
+
const start = index + 1 + "subdirectory=".length, end = source.indexOf("&", start);
|
|
2162
|
+
subdirectory = source.slice(start, end < 0 ? void 0 : end);
|
|
2163
|
+
break;
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
if (source.slice(0, 5).toLowerCase() === "file:") {
|
|
1873
2167
|
const url = new URL(source);
|
|
1874
|
-
if (url.host && url.host !== "localhost")
|
|
2168
|
+
if (url.host && url.host !== "localhost") {
|
|
2169
|
+
if (editable) throw new Error("Editable source requires a local directory");
|
|
2170
|
+
return requirement;
|
|
2171
|
+
}
|
|
1875
2172
|
source = decodeURIComponent(url.pathname);
|
|
1876
|
-
} else if (source.
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
} catch (error) {
|
|
1881
|
-
if (error instanceof FsError4 && error.code === "ENOENT") return requirement;
|
|
1882
|
-
throw error;
|
|
2173
|
+
} else if (source.startsWith("https://") || source.startsWith("http://")) remote = new URL(source);
|
|
2174
|
+
else if (source.includes("://")) {
|
|
2175
|
+
if (editable) throw new Error("Editable source requires a local directory");
|
|
2176
|
+
return requirement;
|
|
1883
2177
|
}
|
|
2178
|
+
if (editable && remote) throw new Error("Editable source requires a local directory");
|
|
2179
|
+
const suffix = archiveSuffix(remote?.pathname ?? source);
|
|
2180
|
+
let archived = !!remote && !wheelLink(remote);
|
|
2181
|
+
if (remote) {
|
|
2182
|
+
if (!archived) return requirement;
|
|
2183
|
+
} else {
|
|
2184
|
+
source = resolvePath4(context.cwd, source);
|
|
2185
|
+
try {
|
|
2186
|
+
const stat = await fs.stat(source, settings);
|
|
2187
|
+
archived = stat.type === "file" && !!suffix;
|
|
2188
|
+
if (editable && stat.type !== "directory") throw new Error("Editable source requires a local directory");
|
|
2189
|
+
if (stat.type !== "directory" && !archived) return requirement;
|
|
2190
|
+
} catch (error) {
|
|
2191
|
+
if (error instanceof FsError4 && error.code === "ENOENT") {
|
|
2192
|
+
if (editable) throw new Error("Editable source requires an existing local directory");
|
|
2193
|
+
return requirement;
|
|
2194
|
+
}
|
|
2195
|
+
throw error;
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2198
|
+
const originSource = originalLink ?? source;
|
|
1884
2199
|
if (!context.stdout || !context.stderr || !context.env) throw new TypeError("Source package preparation requires command output and environment context");
|
|
1885
2200
|
if (!fs.prepareDirectory || !fs.removeTreeConditional || !fs.confineExtraction) throw new Error("Source packages require conditional caller storage");
|
|
1886
|
-
const root = await fs.realpath(
|
|
2201
|
+
const root = await fs.realpath(resolvePath4(context.cwd, build.directory), settings), parent = await fs.stat(root, settings);
|
|
1887
2202
|
const caps = await fs.capabilitiesFor?.(root, settings) ?? fs.capabilities;
|
|
1888
2203
|
if (!caps.atomicTreeRemoval) throw new Error("Source packages require conditional tree cleanup");
|
|
1889
2204
|
let path = "", owned;
|
|
1890
2205
|
for (let attempt = 0; attempt < 16; attempt++) {
|
|
1891
|
-
path =
|
|
2206
|
+
path = resolvePath4(root, ".python-build-" + ++serial2);
|
|
1892
2207
|
try {
|
|
1893
2208
|
owned = await fs.prepareDirectory(path, { parent, expected: null, mode: 448, signal });
|
|
1894
2209
|
break;
|
|
@@ -1920,17 +2235,45 @@ function createPythonSourcePackageEnvironment(options, build) {
|
|
|
1920
2235
|
return typeof value === "function" ? value.bind(owner) : value;
|
|
1921
2236
|
} });
|
|
1922
2237
|
const command = { ...context, env: context.env, stdout: context.stdout, stderr: context.stderr, command: "python", args: [], stdin: toByteSource7("") };
|
|
1923
|
-
|
|
1924
|
-
const wheelDirectory = resolvePath3(path, "wheels");
|
|
1925
|
-
await confined.mkdir(wheelDirectory, settings);
|
|
2238
|
+
Reflect.deleteProperty(command, "editable");
|
|
1926
2239
|
const configuration = { ...build.python, environment }, hook = createPythonBuildBackend(configuration), hookContext = { ...command, maxBytes: options.maxMetadataBytes ?? Infinity };
|
|
1927
|
-
|
|
1928
|
-
if (
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
2240
|
+
let prepared;
|
|
2241
|
+
if (archived) {
|
|
2242
|
+
prepared = resolvePath4(path, "source");
|
|
2243
|
+
await confined.mkdir(prepared, settings);
|
|
2244
|
+
if (!build.extractArchive) throw new Error("Source archives require an extraction capability");
|
|
2245
|
+
let metadata;
|
|
2246
|
+
if (remote) {
|
|
2247
|
+
source = resolvePath4(path, "archive");
|
|
2248
|
+
const response = await downloadPythonSourceArchive(remote, source, options, command);
|
|
2249
|
+
const filename2 = await hook({ hook: "read_download_filename", source: remote.href, responseUrl: response.url, headers: response.headers }, hookContext);
|
|
2250
|
+
const headers = new Map(response.headers.map(([key, value]) => [key.toLowerCase(), value]));
|
|
2251
|
+
metadata = { filename: filename2, ...headers.has("content-type") ? { contentType: headers.get("content-type") } : {} };
|
|
2252
|
+
}
|
|
2253
|
+
if (!remote && originalLink && pythonPackageUrlHash(originalLink)) {
|
|
2254
|
+
const snapshot = resolvePath4(path, "archive" + suffix);
|
|
2255
|
+
await snapshotPythonSourceArchive(source, snapshot, originalLink, options.maxDownloadBytes ?? Infinity, { ...command, fs: staging });
|
|
2256
|
+
source = snapshot;
|
|
2257
|
+
}
|
|
2258
|
+
await build.extractArchive(source, prepared, options.maxDownloadBytes ?? Infinity, { ...command, fs: staging }, metadata);
|
|
2259
|
+
} else prepared = editable ? await fs.realpath(source, settings) : (await createPythonSourceSnapshot(source, path, { ...command, fs: staging })).path;
|
|
2260
|
+
if (subdirectory) {
|
|
2261
|
+
const selected = resolvePath4(prepared, subdirectory);
|
|
2262
|
+
if (selected !== prepared && !selected.startsWith(prepared + "/")) throw new Error("Source subdirectory escapes the build tree");
|
|
2263
|
+
const root2 = await fs.realpath(prepared, settings), actual = await fs.realpath(selected, settings);
|
|
2264
|
+
if (actual !== root2 && !actual.startsWith(root2 + "/")) throw new Error("Source subdirectory escapes the build tree");
|
|
2265
|
+
prepared = actual;
|
|
2266
|
+
}
|
|
2267
|
+
const wheelDirectory = resolvePath4(path, "wheels");
|
|
2268
|
+
await confined.mkdir(wheelDirectory, settings);
|
|
2269
|
+
const buildSystem = await hook({ hook: "read_build_system", source: prepared, name: requirement, installation: archived ? "archive" : "directory" }, hookContext);
|
|
2270
|
+
await createPythonBuildDependencies(configuration)({ source: prepared, buildSystem }, hookContext);
|
|
2271
|
+
const filename = await hook(editable ? { hook: "build_legacy_wheel", source: prepared, wheelDirectory, editable: true } : buildSystem ? { hook: "build_wheel", source: prepared, backend: buildSystem.backend, backendPath: buildSystem.backendPath, wheelDirectory } : { hook: "build_legacy_wheel", source: prepared, wheelDirectory }, hookContext);
|
|
2272
|
+
const published = await publishPythonBuildWheel(resolvePath4(wheelDirectory, filename), root, options.maxDownloadBytes ?? Infinity, context);
|
|
2273
|
+
const origin = buildSystem && !editable ? await hook({ hook: "read_source_origin", source: originSource, directory: !archived }, hookContext) : void 0;
|
|
2274
|
+
const url = published.url + "#python-source=" + encodeURIComponent(origin ?? "null");
|
|
1932
2275
|
await cleanup();
|
|
1933
|
-
return
|
|
2276
|
+
return named ? (named.name || filename.slice(0, filename.indexOf("-"))) + (named.extras.length ? "[" + named.extras.join(",") + "]" : "") + " @ " + url + (named.marker ? " ; " + named.marker : "") : url;
|
|
1934
2277
|
} catch (error) {
|
|
1935
2278
|
try {
|
|
1936
2279
|
await cleanup();
|
|
@@ -1941,14 +2284,16 @@ function createPythonSourcePackageEnvironment(options, build) {
|
|
|
1941
2284
|
throw error;
|
|
1942
2285
|
}
|
|
1943
2286
|
};
|
|
1944
|
-
return createPythonPackageEnvironment({ ...options, async prepareRequirements(requirements, context) {
|
|
2287
|
+
return withPythonSourceOrigins(createPythonPackageEnvironment({ ...options, async prepareRequirements(requirements, context) {
|
|
1945
2288
|
const resolved = [];
|
|
2289
|
+
for (const requirement of /* @__PURE__ */ new Set([...options.editable ?? [], ...context.editable ?? []])) resolved.push(await prepareRequirement(requirement, context, true));
|
|
1946
2290
|
for (const requirement of new Set(requirements)) resolved.push(await prepareRequirement(requirement, context));
|
|
1947
2291
|
return resolved;
|
|
1948
|
-
} });
|
|
2292
|
+
} }), build.directory, options.maxMetadataBytes ?? Infinity);
|
|
1949
2293
|
}
|
|
1950
2294
|
|
|
1951
2295
|
// packages/safe-bash-command-python/src/executor.ts
|
|
2296
|
+
var encoder = new TextEncoder();
|
|
1952
2297
|
var PythonInputChunkError = class extends RangeError {
|
|
1953
2298
|
};
|
|
1954
2299
|
function createPythonExecutorCommands(options) {
|
|
@@ -1970,7 +2315,7 @@ function createPythonExecutorCommands(options) {
|
|
|
1970
2315
|
const environment = options.environment ?? createPythonPackageEnvironment(options.provisioning);
|
|
1971
2316
|
const execute = async (context) => {
|
|
1972
2317
|
if (pythonShellDispatchActive(context.executionScope)) {
|
|
1973
|
-
await writeBytes(context.stderr,
|
|
2318
|
+
await writeBytes(context.stderr, encoder.encode("python: nested Python execution is unavailable while the parent interpreter is suspended\n"), context.signal);
|
|
1974
2319
|
return { exitCode: 1 };
|
|
1975
2320
|
}
|
|
1976
2321
|
let installation;
|
|
@@ -1979,17 +2324,17 @@ function createPythonExecutorCommands(options) {
|
|
|
1979
2324
|
installation = invocation.module?.name === "pip" ? parsePythonInstallation(invocation.module.args) : void 0;
|
|
1980
2325
|
} catch (error) {
|
|
1981
2326
|
if (!(error instanceof PythonInvocationError)) throw error;
|
|
1982
|
-
await writeBytes(context.stderr,
|
|
2327
|
+
await writeBytes(context.stderr, encoder.encode("python: " + error.message + "\n"), context.signal);
|
|
1983
2328
|
return { exitCode: 2 };
|
|
1984
2329
|
}
|
|
1985
2330
|
if (installation?.help) {
|
|
1986
|
-
await writeBytes(context.stdout,
|
|
2331
|
+
await writeBytes(context.stdout, encoder.encode(pythonInstallationHelp), context.signal);
|
|
1987
2332
|
return { exitCode: 0 };
|
|
1988
2333
|
}
|
|
1989
2334
|
context.signal.throwIfAborted();
|
|
1990
2335
|
if (activeWorkers >= maxConcurrentWorkers) {
|
|
1991
2336
|
const failure = reportPythonFailure("capacity", void 0, options.onDiagnostic);
|
|
1992
|
-
await writeBytes(context.stderr,
|
|
2337
|
+
await writeBytes(context.stderr, encoder.encode("python: " + failure.message + "\n"), context.signal);
|
|
1993
2338
|
return { exitCode: 1 };
|
|
1994
2339
|
}
|
|
1995
2340
|
const controller = new AbortController();
|
|
@@ -2077,7 +2422,7 @@ function createPythonExecutorCommands(options) {
|
|
|
2077
2422
|
if (!filesystemDiagnostics.has(category)) {
|
|
2078
2423
|
filesystemDiagnostics.add(category);
|
|
2079
2424
|
const failure = reportPythonFailure(category, error, options.onDiagnostic);
|
|
2080
|
-
await writeBytes(stderrOperation.output,
|
|
2425
|
+
await writeBytes(stderrOperation.output, encoder.encode("python: " + failure.message + "\n"), signal);
|
|
2081
2426
|
}
|
|
2082
2427
|
};
|
|
2083
2428
|
const dispatch = async (request) => {
|
|
@@ -2353,9 +2698,9 @@ function createPythonExecutorCommands(options) {
|
|
|
2353
2698
|
});
|
|
2354
2699
|
}
|
|
2355
2700
|
} catch (reason) {
|
|
2356
|
-
if (!signal.aborted && reason instanceof PythonInputChunkError) {
|
|
2701
|
+
if (!signal.aborted && (reason instanceof PythonInputChunkError || reason instanceof PythonInstallationError)) {
|
|
2357
2702
|
try {
|
|
2358
|
-
await writeBytes(stderrOperation.output,
|
|
2703
|
+
await writeBytes(stderrOperation.output, encoder.encode("python: " + reason.message + "\n"), signal);
|
|
2359
2704
|
} catch (error) {
|
|
2360
2705
|
primary = { reason: error };
|
|
2361
2706
|
}
|
|
@@ -2377,7 +2722,7 @@ function createPythonExecutorCommands(options) {
|
|
|
2377
2722
|
if (primary) {
|
|
2378
2723
|
if (!(primary.reason instanceof PythonFailure)) throw primary.reason;
|
|
2379
2724
|
const failure = primary.reason;
|
|
2380
|
-
await writeBytes(context.stderr,
|
|
2725
|
+
await writeBytes(context.stderr, encoder.encode("python: " + failure.message + "\n"), context.signal);
|
|
2381
2726
|
return { exitCode: 1 };
|
|
2382
2727
|
}
|
|
2383
2728
|
return { exitCode: result };
|
|
@@ -2411,7 +2756,6 @@ export {
|
|
|
2411
2756
|
createPythonSourceSnapshot,
|
|
2412
2757
|
pythonLlmPackages,
|
|
2413
2758
|
installPythonLlmPackages,
|
|
2414
|
-
publishPythonBuildWheel,
|
|
2415
2759
|
createPythonSourcePackageEnvironment,
|
|
2416
2760
|
createPythonExecutorCommands,
|
|
2417
2761
|
pythonExecutorCommands
|