Skip to content

Commit c50986d

Browse files
committed
Python bindings for hugr-model.
1 parent 6c4ea4f commit c50986d

27 files changed

+1721
-10
lines changed

Cargo.lock

+108
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ members = [
1010
"hugr-cli",
1111
"hugr-model",
1212
"hugr-llvm",
13+
"hugr-py",
1314
]
1415
default-members = ["hugr", "hugr-core", "hugr-passes", "hugr-cli", "hugr-model"]
1516

@@ -76,6 +77,7 @@ pest = "2.7.12"
7677
pest_derive = "2.7.12"
7778
pretty = "0.12.3"
7879
pretty_assertions = "1.4.1"
80+
pyo3 = "0.23.4"
7981

8082
[profile.dev.package]
8183
insta.opt-level = 3

hugr-core/src/std_extensions/arithmetic/float_types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl std::ops::Deref for ConstF64 {
6666
impl ConstF64 {
6767
/// Name of the constructor for creating constant 64bit floats.
6868
#[cfg_attr(not(feature = "model_unstable"), allow(dead_code))]
69-
pub(crate) const CTR_NAME: &'static str = "arithmetic.float.const-f64";
69+
pub(crate) const CTR_NAME: &'static str = "arithmetic.float.const_f64";
7070

7171
/// Create a new [`ConstF64`]
7272
pub fn new(value: f64) -> Self {

hugr-core/tests/model.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::str::FromStr;
44

55
use hugr::std_extensions::std_reg;
66
use hugr_core::{export::export_hugr, import::import_hugr};
7-
use hugr_model::v0 as model;
7+
use hugr_model::v0::{self as model};
88

99
fn roundtrip(source: &str) -> String {
1010
let bump = model::bumpalo::Bump::new();

hugr-model/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pest_derive = { workspace = true }
2929
pretty = { workspace = true }
3030
smol_str = { workspace = true, features = ["serde"] }
3131
thiserror.workspace = true
32+
pyo3 = { workspace = true, optional = true }
3233

3334
[lints]
3435
workspace = true

hugr-model/src/v0/ast/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ use super::{LinkName, Literal, RegionKind, SymbolName, VarName};
2929

3030
mod parse;
3131
mod print;
32+
#[cfg(feature = "pyo3")]
33+
mod python;
3234
mod resolve;
3335
mod view;
3436

hugr-model/src/v0/ast/parse.rs

+1
Original file line numberDiff line numberDiff line change
@@ -444,3 +444,4 @@ impl_from_str!(Param, param, parse_param);
444444
impl_from_str!(Module, module, parse_module);
445445
impl_from_str!(SeqPart, part, parse_seq_part);
446446
impl_from_str!(Literal, literal, parse_literal);
447+
impl_from_str!(Symbol, symbol, parse_symbol);

hugr-model/src/v0/ast/print.rs

+1
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ impl_display!(Param, print_param);
426426
impl_display!(Term, print_term);
427427
impl_display!(SeqPart, print_seq_part);
428428
impl_display!(Literal, print_literal);
429+
impl_display!(Symbol, print_symbol);
429430

430431
impl Display for VarName {
431432
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {

0 commit comments

Comments
 (0)