Skip to content

Commit 2efafb6

Browse files
committed
update to CPython 3.14.0
Also: - bump Wasmtime patch version - set Rust edition to 2024 - run `cargo fmt` Signed-off-by: Joel Dice <joel.dice@fermyon.com>
1 parent 139d0ed commit 2efafb6

File tree

14 files changed

+174
-164
lines changed

14 files changed

+174
-164
lines changed

Cargo.lock

Lines changed: 77 additions & 77 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "componentize-py"
33
version = "0.18.0"
4-
edition = "2021"
4+
edition = "2024"
55
exclude = ["cpython"]
66

77
[lib]
@@ -26,8 +26,8 @@ pyo3 = { version = "0.26.0", features = [
2626
"abi3-py39",
2727
"extension-module",
2828
], optional = true }
29-
wasmtime = "37.0.1"
30-
wasmtime-wasi = "37.0.1"
29+
wasmtime = "37.0.2"
30+
wasmtime-wasi = "37.0.2"
3131
once_cell = "1.20.2"
3232
component-init-transform = { version = "0.2", git = "https://github.com/dicej/component-init", rev = "3800ab6e" }
3333
async-trait = "0.1.83"

build.rs

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

33
use {
4-
anyhow::{anyhow, bail, Context, Result},
4+
anyhow::{Context, Result, anyhow, bail},
55
std::{
66
env,
77
fmt::Write as _,
@@ -297,11 +297,17 @@ fn maybe_make_cpython(repo_dir: &Path, wasi_sdk: &Path) -> Result<()> {
297297
)
298298
.env(
299299
"CFLAGS",
300-
format!("-fPIC -I{}/deps/include", cpython_wasi_dir.display()),
300+
format!(
301+
"--target=wasm32-wasip2 -fPIC -I{}/deps/include",
302+
cpython_wasi_dir.display()
303+
),
301304
)
302305
.env(
303306
"LDFLAGS",
304-
format!("-L{}/deps/lib", cpython_wasi_dir.display()),
307+
format!(
308+
"--target=wasm32-wasip2 -L{}/deps/lib",
309+
cpython_wasi_dir.display()
310+
),
305311
)
306312
.current_dir(&cpython_wasi_dir)
307313
.args([

cpython

Submodule cpython updated 122 files

src/bindings.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use {
22
crate::{
33
bindgen::{
4-
FunctionBindgen, DISPATCHABLE_CORE_PARAM_COUNT, DISPATCH_CORE_PARAM_COUNT, IMPORTS,
5-
IMPORT_SIGNATURES,
4+
DISPATCH_CORE_PARAM_COUNT, DISPATCHABLE_CORE_PARAM_COUNT, FunctionBindgen,
5+
IMPORT_SIGNATURES, IMPORTS,
66
},
77
summary::{FunctionKind, Summary},
88
},
@@ -181,14 +181,14 @@ pub fn make_bindings(
181181
types.ty().function(params, results);
182182
functions.function(offset);
183183
function_names.push((offset, function.internal_name(resolve)));
184-
let mut gen = FunctionBindgen::new(summary, function, stack_pointer);
184+
let mut r#gen = FunctionBindgen::new(summary, function, stack_pointer);
185185

186186
match function.kind {
187187
FunctionKind::Import => {
188-
gen.compile_import(import_index.try_into().unwrap());
188+
r#gen.compile_import(import_index.try_into().unwrap());
189189
import_index += 1;
190190
}
191-
FunctionKind::Export => gen.compile_export(
191+
FunctionKind::Export => r#gen.compile_export(
192192
export_set
193193
.get_index_of(&(function.interface.as_ref().map(|i| i.name), function.name))
194194
.unwrap()
@@ -198,25 +198,25 @@ pub fn make_bindings(
198198
dispatch_index,
199199
dispatch_index + 1,
200200
),
201-
FunctionKind::ExportFromCanon => gen.compile_export_from_canon(),
202-
FunctionKind::ExportToCanon => gen.compile_export_to_canon(),
203-
FunctionKind::ExportPostReturn => gen.compile_export_post_return(),
201+
FunctionKind::ExportFromCanon => r#gen.compile_export_from_canon(),
202+
FunctionKind::ExportToCanon => r#gen.compile_export_to_canon(),
203+
FunctionKind::ExportPostReturn => r#gen.compile_export_post_return(),
204204
FunctionKind::ResourceNew => {
205-
gen.compile_resource_new(import_index.try_into().unwrap());
205+
r#gen.compile_resource_new(import_index.try_into().unwrap());
206206
import_index += 1;
207207
}
208208
FunctionKind::ResourceRep => {
209-
gen.compile_resource_rep(import_index.try_into().unwrap());
209+
r#gen.compile_resource_rep(import_index.try_into().unwrap());
210210
import_index += 1;
211211
}
212212
FunctionKind::ResourceDropLocal | FunctionKind::ResourceDropRemote => {
213-
gen.compile_resource_drop(import_index.try_into().unwrap());
213+
r#gen.compile_resource_drop(import_index.try_into().unwrap());
214214
import_index += 1;
215215
}
216216
};
217217

218-
let mut func = Function::new_with_locals_types(gen.local_types);
219-
for instruction in &gen.instructions {
218+
let mut func = Function::new_with_locals_types(r#gen.local_types);
219+
for instruction in &r#gen.instructions {
220220
func.instruction(instruction);
221221
}
222222
func.instruction(&Ins::End);

src/lib.rs

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

33
use {
4-
anyhow::{anyhow, bail, ensure, Context, Error, Result},
4+
anyhow::{Context, Error, Result, anyhow, bail, ensure},
55
async_trait::async_trait,
66
bytes::Bytes,
77
component_init_transform::Invoker,
@@ -18,12 +18,12 @@ use {
1818
},
1919
summary::{Escape, Locations, Summary},
2020
wasmtime::{
21-
component::{Component, Instance, Linker, ResourceTable, ResourceType},
2221
Config, Engine, Store,
22+
component::{Component, Instance, Linker, ResourceTable, ResourceType},
2323
},
2424
wasmtime_wasi::{
25-
p2::pipe::{MemoryInputPipe, MemoryOutputPipe},
2625
DirPerms, FilePerms, WasiCtx, WasiCtxBuilder, WasiCtxView, WasiView,
26+
p2::pipe::{MemoryInputPipe, MemoryOutputPipe},
2727
},
2828
wit_parser::{Resolve, TypeDefKind, UnresolvedPackageGroup, WorldId, WorldItem, WorldKey},
2929
};
@@ -661,29 +661,27 @@ fn add_wasi_and_stubs(
661661
// Note that we do _not_ stub interfaces which appear to be part of WASIp2 since those should be
662662
// provided by the `wasmtime_wasi::add_to_linker_async` call above, and adding stubs to those same
663663
// interfaces would just cause trouble.
664-
if !is_wasip2_cli(&interface_name) {
665-
if let Ok(mut instance) = linker.instance(&interface_name) {
666-
for stub in stubs {
667-
let interface_name = interface_name.clone();
668-
match stub {
669-
Stub::Function(name) => instance.func_new(name, {
664+
if !is_wasip2_cli(&interface_name)
665+
&& let Ok(mut instance) = linker.instance(&interface_name)
666+
{
667+
for stub in stubs {
668+
let interface_name = interface_name.clone();
669+
match stub {
670+
Stub::Function(name) => instance.func_new(name, {
671+
let name = name.clone();
672+
move |_, _, _| {
673+
Err(anyhow!("called trapping stub: {interface_name}#{name}"))
674+
}
675+
}),
676+
Stub::Resource(name) => instance
677+
.resource(name, ResourceType::host::<()>(), {
670678
let name = name.clone();
671-
move |_, _, _| {
679+
move |_, _| {
672680
Err(anyhow!("called trapping stub: {interface_name}#{name}"))
673681
}
674-
}),
675-
Stub::Resource(name) => instance
676-
.resource(name, ResourceType::host::<()>(), {
677-
let name = name.clone();
678-
move |_, _| {
679-
Err(anyhow!(
680-
"called trapping stub: {interface_name}#{name}"
681-
))
682-
}
683-
})
684-
.map(drop),
685-
}?;
686-
}
682+
})
683+
.map(drop),
684+
}?;
687685
}
688686
}
689687
} else {

src/prelink.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{
88
path::{Path, PathBuf},
99
};
1010

11-
use anyhow::{anyhow, bail, Context, Result};
11+
use anyhow::{Context, Result, anyhow, bail};
1212
use indexmap::IndexMap;
1313
use tar::Archive;
1414
use tempfile::TempDir;

src/python.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
use {
77
pyo3::{
8+
Bound, PyResult, Python,
89
exceptions::PyAssertionError,
910
pybacked::PyBackedStr,
1011
types::{PyAnyMethods, PyModule, PyModuleMethods},
11-
Bound, PyResult, Python,
1212
},
1313
std::{ffi::OsString, path::PathBuf},
1414
tokio::runtime::Runtime,

src/stubwasi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::collections::HashMap;
22

3-
use anyhow::{bail, Error};
3+
use anyhow::{Error, bail};
44
use wasm_encoder::{
55
CodeSection, ExportKind, ExportSection, Function, FunctionSection, Instruction as Ins, Module,
66
TypeSection,

src/summary.rs

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ use {
88
},
99
util::Types as _,
1010
},
11-
anyhow::{bail, Result},
11+
anyhow::{Result, bail},
1212
heck::{ToShoutySnakeCase, ToSnakeCase, ToUpperCamelCase},
1313
indexmap::{IndexMap, IndexSet},
1414
once_cell::sync,
1515
semver::Version,
1616
std::{
17-
collections::{hash_map::Entry, HashMap, HashSet},
17+
collections::{HashMap, HashSet, hash_map::Entry},
1818
fmt::Write as _,
1919
fs::{self, File},
2020
io::Write as _,
@@ -654,7 +654,7 @@ impl<'a> Summary<'a> {
654654
OwnedKind::Flags(flags.repr().count().try_into().unwrap())
655655
}
656656
TypeDefKind::Tuple(_) | TypeDefKind::Option(_) | TypeDefKind::Result(_) => {
657-
return self.summarize_unowned_type(id)
657+
return self.summarize_unowned_type(id);
658658
}
659659
TypeDefKind::Resource => {
660660
let info = &self.resource_info[&id];
@@ -1082,25 +1082,27 @@ impl<'a> Summary<'a> {
10821082
unreachable!()
10831083
};
10841084

1085-
assert!(tree
1086-
.entry(info.name)
1087-
.or_default()
1088-
.entry(info.package.map(|p| (p.namespace, p.name)))
1089-
.or_default()
1090-
.insert(info.package.and_then(|p| p.version), id)
1091-
.is_none());
1085+
assert!(
1086+
tree.entry(info.name)
1087+
.or_default()
1088+
.entry(info.package.map(|p| (p.namespace, p.name)))
1089+
.or_default()
1090+
.insert(info.package.and_then(|p| p.version), id)
1091+
.is_none()
1092+
);
10921093
}
10931094

10941095
let mut names = HashMap::new();
10951096
for (name, packages) in &tree {
10961097
for (package, versions) in packages {
10971098
if let Some((package_namespace, package_name)) = package {
10981099
for (version, id) in versions {
1099-
assert!(names
1100-
.insert(
1101-
*id,
1102-
if let Some(version) = version {
1103-
if let Some(name) = interface_names.get(
1100+
assert!(
1101+
names
1102+
.insert(
1103+
*id,
1104+
if let Some(version) = version {
1105+
if let Some(name) = interface_names.get(
11041106
format!(
11051107
"{package_namespace}:{package_name}/{name}@{version}"
11061108
)
@@ -1119,25 +1121,29 @@ impl<'a> Summary<'a> {
11191121
version.to_string().replace('.', "-")
11201122
)
11211123
}
1122-
} else if let Some(name) = interface_names.get(
1123-
format!("{package_namespace}:{package_name}/{name}").as_str()
1124-
) {
1125-
(*name).to_owned()
1126-
} else if packages.len() == 1 {
1127-
(*name).to_owned()
1128-
} else {
1129-
format!("{package_namespace}-{package_name}-{name}",)
1130-
}
1131-
)
1132-
.is_none());
1124+
} else if let Some(name) = interface_names.get(
1125+
format!("{package_namespace}:{package_name}/{name}")
1126+
.as_str()
1127+
) {
1128+
(*name).to_owned()
1129+
} else if packages.len() == 1 {
1130+
(*name).to_owned()
1131+
} else {
1132+
format!("{package_namespace}-{package_name}-{name}",)
1133+
}
1134+
)
1135+
.is_none()
1136+
);
11331137
}
11341138
} else {
1135-
assert!(names
1136-
.insert(
1137-
*versions.get(&None).unwrap(),
1138-
(*interface_names.get(*name).unwrap_or(name)).to_owned()
1139-
)
1140-
.is_none());
1139+
assert!(
1140+
names
1141+
.insert(
1142+
*versions.get(&None).unwrap(),
1143+
(*interface_names.get(*name).unwrap_or(name)).to_owned()
1144+
)
1145+
.is_none()
1146+
);
11411147
}
11421148
}
11431149
}

0 commit comments

Comments
 (0)