|
1 | 1 | #![deny(warnings)] |
2 | 2 |
|
3 | 3 | use { |
4 | | - anyhow::{anyhow, bail, ensure, Context, Error, Result}, async_trait::async_trait, bytes::Bytes, component_init::Invoker, futures::future::FutureExt, heck::ToSnakeCase, indexmap::{IndexMap, IndexSet}, prelink::{embedded_helper_utils, embedded_python_standard_library}, serde::Deserialize, std::{ |
| 4 | + anyhow::{anyhow, bail, ensure, Context, Error, Result}, |
| 5 | + async_trait::async_trait, |
| 6 | + bytes::Bytes, |
| 7 | + component_init::Invoker, |
| 8 | + futures::future::FutureExt, |
| 9 | + heck::ToSnakeCase, |
| 10 | + indexmap::{IndexMap, IndexSet}, |
| 11 | + prelink::{embedded_helper_utils, embedded_python_standard_library}, |
| 12 | + serde::Deserialize, |
| 13 | + std::{ |
5 | 14 | collections::{HashMap, HashSet}, |
6 | 15 | env, fs, |
7 | 16 | io::Cursor, |
8 | 17 | iter, |
9 | 18 | ops::Deref, |
10 | 19 | path::{Path, PathBuf}, |
11 | 20 | str, |
12 | | - }, summary::{Escape, Locations, Summary}, wasm_convert::IntoValType, wasm_encoder::{ |
| 21 | + }, |
| 22 | + summary::{Escape, Locations, Summary}, |
| 23 | + wasm_convert::IntoValType, |
| 24 | + wasm_encoder::{ |
13 | 25 | CodeSection, ExportKind, ExportSection, Function, FunctionSection, Instruction, Module, |
14 | 26 | TypeSection, |
15 | | - }, wasmparser::{FuncType, Parser, Payload, TypeRef}, wasmtime::{ |
| 27 | + }, |
| 28 | + wasmparser::{FuncType, Parser, Payload, TypeRef}, |
| 29 | + wasmtime::{ |
16 | 30 | component::{Component, Instance, Linker, ResourceTable, ResourceType}, |
17 | 31 | Config, Engine, Store, |
18 | | - }, wasmtime_wasi::{ |
| 32 | + }, |
| 33 | + wasmtime_wasi::{ |
19 | 34 | pipe::{MemoryInputPipe, MemoryOutputPipe}, |
20 | 35 | DirPerms, FilePerms, WasiCtx, WasiCtxBuilder, WasiView, |
21 | | - }, wit_parser::{Resolve, TypeDefKind, UnresolvedPackageGroup, WorldId, WorldItem, WorldKey} |
| 36 | + }, |
| 37 | + wit_parser::{Resolve, TypeDefKind, UnresolvedPackageGroup, WorldId, WorldItem, WorldKey}, |
22 | 38 | }; |
23 | 39 |
|
24 | 40 | mod abi; |
25 | 41 | mod bindgen; |
26 | 42 | mod bindings; |
27 | 43 | pub mod command; |
| 44 | +mod prelink; |
28 | 45 | #[cfg(feature = "pyo3")] |
29 | 46 | mod python; |
30 | 47 | mod summary; |
31 | 48 | #[cfg(test)] |
32 | 49 | mod test; |
33 | 50 | mod util; |
34 | | -mod prelink; |
35 | 51 |
|
36 | 52 | static NATIVE_EXTENSION_SUFFIX: &str = ".cpython-312-wasm32-wasi.so"; |
37 | 53 |
|
@@ -204,7 +220,8 @@ pub async fn componentize( |
204 | 220 | // the latter may contain their own WIT files defining their own worlds (in addition to what the caller |
205 | 221 | // specified as paramters), which we'll try to match up with `module_worlds` in the next step. |
206 | 222 | let mut raw_configs: Vec<crate::ConfigContext<crate::RawComponentizePyConfig>> = Vec::new(); |
207 | | - let mut library_path: Vec<(&str, Vec<std::path::PathBuf>)> = Vec::with_capacity(python_path.len()); |
| 223 | + let mut library_path: Vec<(&str, Vec<std::path::PathBuf>)> = |
| 224 | + Vec::with_capacity(python_path.len()); |
208 | 225 | for path in python_path { |
209 | 226 | let mut libraries = Vec::new(); |
210 | 227 | search_directory( |
@@ -414,8 +431,18 @@ pub async fn componentize( |
414 | 431 | .env("PYTHONUNBUFFERED", "1") |
415 | 432 | .env("COMPONENTIZE_PY_APP_NAME", app_name) |
416 | 433 | .env("PYTHONHOME", "/python") |
417 | | - .preopened_dir(embedded_python_standard_lib.path(), "python", DirPerms::all(), FilePerms::all())? |
418 | | - .preopened_dir(embedded_helper_utils.path(), "bundled", DirPerms::all(), FilePerms::all())?; |
| 434 | + .preopened_dir( |
| 435 | + embedded_python_standard_lib.path(), |
| 436 | + "python", |
| 437 | + DirPerms::all(), |
| 438 | + FilePerms::all(), |
| 439 | + )? |
| 440 | + .preopened_dir( |
| 441 | + embedded_helper_utils.path(), |
| 442 | + "bundled", |
| 443 | + DirPerms::all(), |
| 444 | + FilePerms::all(), |
| 445 | + )?; |
419 | 446 |
|
420 | 447 | // Generate guest mounts for each host directory in `python_path`. |
421 | 448 | for (index, path) in python_path.iter().enumerate() { |
|
0 commit comments