Skip to content

Commit 2dfd3d5

Browse files
author
Phil Cummins
committed
latest
1 parent 0e6cf53 commit 2dfd3d5

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

src/lib.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ mod summary;
4949
mod test;
5050
mod util;
5151

52-
5352
wasmtime::component::bindgen!({
5453
path: "wit",
5554
world: "init",
@@ -215,8 +214,8 @@ pub async fn componentize(
215214
let embedded_python_standard_lib = embedded_python_standard_library()?;
216215
let embedded_helper_utils = embedded_helper_utils()?;
217216

218-
let (configs, mut libraries) = prelink::search_for_libraries_and_configs(python_path, module_worlds)?;
219-
217+
let (configs, mut libraries) =
218+
prelink::search_for_libraries_and_configs(python_path, module_worlds, world)?;
220219

221220
// Next, iterate over all the WIT directories, merging them into a single `Resolve`, and matching Python
222221
// packages to `WorldId`s.
@@ -675,9 +674,6 @@ fn add_wasi_and_stubs(
675674
Ok(())
676675
}
677676

678-
679-
680-
681677
fn add_wasi_imports<'a>(
682678
module: &'a [u8],
683679
imports: &mut HashMap<&'a str, HashMap<&'a str, FuncType>>,

src/prelink.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#![deny(warnings)]
22

33
use std::{
4-
collections::{HashMap, HashSet}, fs::{self}, io::{self, Cursor}, ops::Deref, path::{Path, PathBuf}
4+
collections::{HashMap, HashSet},
5+
fs::{self},
6+
io::{self, Cursor},
7+
ops::Deref,
8+
path::{Path, PathBuf},
59
};
610

711
use anyhow::{anyhow, bail, Context, Result};
@@ -90,8 +94,17 @@ fn library_from_so(library_name: &str) -> Result<Library, io::Error> {
9094
})
9195
}
9296

93-
pub fn search_for_libraries_and_configs<'a>(python_path: &'a Vec<&'a str>, module_worlds: &'a [(&'a str, &'a str)])
94-
-> Result<(IndexMap<String, (ConfigContext<ComponentizePyConfig>, Option<&'a str>)>, Vec<Library>), anyhow::Error> {
97+
pub fn search_for_libraries_and_configs<'a>(
98+
python_path: &'a Vec<&'a str>,
99+
module_worlds: &'a [(&'a str, &'a str)],
100+
world: Option<&'a str>,
101+
) -> Result<
102+
(
103+
IndexMap<String, (ConfigContext<ComponentizePyConfig>, Option<&'a str>)>,
104+
Vec<Library>,
105+
),
106+
anyhow::Error,
107+
> {
95108
let mut raw_configs: Vec<crate::ConfigContext<crate::RawComponentizePyConfig>> = Vec::new();
96109
let mut library_path: Vec<(&str, Vec<std::path::PathBuf>)> =
97110
Vec::with_capacity(python_path.len());
@@ -107,7 +120,7 @@ pub fn search_for_libraries_and_configs<'a>(python_path: &'a Vec<&'a str>, modul
107120
library_path.push((*path, libraries));
108121
}
109122

110-
let mut libraries = bundle_libraries(library_path)?;
123+
let libraries = bundle_libraries(library_path)?;
111124

112125
// Validate the paths parsed from any componentize-py.toml files discovered above and match them up with
113126
// `module_worlds` entries. Note that we use an `IndexMap` to preserve the order specified in `module_worlds`,
@@ -229,4 +242,4 @@ fn module_name(root: &Path, path: &Path) -> Option<String> {
229242
} else {
230243
None
231244
}
232-
}
245+
}

0 commit comments

Comments
 (0)