Skip to content

Commit 3df756d

Browse files
committed
updates for generating python types
Signed-off-by: Jessie Frazelle <[email protected]>
1 parent e7a8229 commit 3df756d

File tree

14 files changed

+241
-101
lines changed

14 files changed

+241
-101
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[workspace]
22
resolver = "2"
33
members = [
4-
"bumper",
5-
"modeling-cmds",
6-
"modeling-cmds-macros",
7-
"modeling-cmds-macros-impl",
8-
"modeling-session",
9-
"unit-conversion-derive",
4+
"bumper",
5+
"modeling-cmds",
6+
"modeling-cmds-macros",
7+
"modeling-cmds-macros-impl",
8+
"modeling-session",
9+
"unit-conversion-derive",
1010
]
1111

1212
[workspace.lints.rust]

modeling-cmds/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ convert_client_crate = ["dep:kittycad"]
2323
websocket = ["dep:serde_json"]
2424
webrtc = ["dep:webrtc"]
2525
unstable_exhaustive = []
26-
python = ["dep:pyo3"]
26+
python = ["dep:pyo3", "dep:pyo3-stub-gen"]
2727
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
2828

2929
[dependencies]
@@ -42,6 +42,7 @@ measurements = "0.11.0"
4242
parse-display = "0.9.1"
4343
parse-display-derive = "0.9.0"
4444
pyo3 = { version = "0.25.1", optional = true }
45+
pyo3-stub-gen = { version = "0.12.2", optional = true }
4546
schemars = { version = "0.8.22", features = [
4647
"bigdecimal04",
4748
"chrono",
@@ -54,10 +55,10 @@ serde_json = { version = "1.0.139", optional = true }
5455
slog = { version = "2.7.0", optional = true }
5556
tabled = { version = "0.18", optional = true }
5657
ts-rs = { version = "11.0.1", optional = true, features = [
57-
"chrono-impl",
58-
"uuid-impl",
59-
"no-serde-warnings",
60-
"serde-json-impl",
58+
"chrono-impl",
59+
"uuid-impl",
60+
"no-serde-warnings",
61+
"serde-json-impl",
6162
] }
6263
uuid = { version = "1.16.0", features = ["serde", "v4", "js"] }
6364
webrtc = { version = "0.12", optional = true }
@@ -67,4 +68,3 @@ bson = "2.14.0"
6768

6869
[lints]
6970
workspace = true
70-

modeling-cmds/src/coord.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use serde::{Deserialize, Serialize};
1212
#[display(style = "snake_case")]
1313
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1414
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
15+
#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass_enum)]
1516
pub enum Axis {
1617
/// 'Y' axis.
1718
Y = 1,
@@ -25,6 +26,7 @@ pub enum Axis {
2526
#[display(style = "snake_case")]
2627
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
2728
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
29+
#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass_enum)]
2830
pub enum Direction {
2931
/// Increasing numbers.
3032
Positive = 1,
@@ -48,6 +50,7 @@ impl std::ops::Mul for Direction {
4850
#[display("({axis}, {direction})")]
4951
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
5052
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
53+
#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass)]
5154
pub struct AxisDirectionPair {
5255
/// Axis specifier.
5356
pub axis: Axis,
@@ -67,6 +70,7 @@ pub struct AxisDirectionPair {
6770
#[display("forward: {forward}, up: {up}")]
6871
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
6972
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
73+
#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass)]
7074
pub struct System {
7175
/// Axis the front face of a model looks along.
7276
pub forward: AxisDirectionPair,

modeling-cmds/src/format/dxf.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub mod export {
1212
#[serde(rename = "DxfStorage", rename_all = "snake_case")]
1313
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1414
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
15+
#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass_enum)]
1516
pub enum Storage {
1617
/// Plaintext encoding.
1718
///
@@ -29,7 +30,7 @@ pub mod export {
2930
#[serde(rename = "DxfExportOptions")]
3031
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
3132
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
32-
#[cfg_attr(feature = "python", pyo3::pyclass)]
33+
#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass)]
3334
pub struct Options {
3435
/// Export storage.
3536
pub storage: Storage,

modeling-cmds/src/format/fbx.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub mod import {
1111
#[serde(rename = "FbxImportOptions")]
1212
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1313
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
14-
#[cfg_attr(feature = "python", pyo3::pyclass)]
14+
#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass)]
1515
pub struct Options {}
1616

1717
#[cfg(feature = "python")]
@@ -33,7 +33,7 @@ pub mod export {
3333
#[derive(Clone, Debug, Default, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema)]
3434
#[serde(rename = "FbxExportOptions")]
3535
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
36-
#[cfg_attr(feature = "python", pyo3::pyclass)]
36+
#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass)]
3737
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
3838
pub struct Options {
3939
/// Specifies which kind of FBX will be exported.
@@ -77,6 +77,7 @@ pub mod export {
7777
#[serde(rename = "FbxStorage", rename_all = "snake_case")]
7878
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
7979
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
80+
#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass_enum)]
8081
pub enum Storage {
8182
/// ASCII FBX encoding.
8283
Ascii,

modeling-cmds/src/format/gltf.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub mod import {
1212
#[serde(rename = "GltfImportOptions")]
1313
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1414
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
15-
#[cfg_attr(feature = "python", pyo3::pyclass)]
15+
#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass)]
1616
pub struct Options {}
1717

1818
#[cfg(feature = "python")]
@@ -34,7 +34,7 @@ pub mod export {
3434
#[display("storage: {storage}, presentation: {presentation}")]
3535
#[serde(rename = "GltfExportOptions")]
3636
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
37-
#[cfg_attr(feature = "python", pyo3::pyclass)]
37+
#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass)]
3838
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
3939
pub struct Options {
4040
/// Specifies which kind of glTF 2.0 will be exported.
@@ -61,6 +61,7 @@ pub mod export {
6161
#[serde(rename = "GltfStorage", rename_all = "snake_case")]
6262
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
6363
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
64+
#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass_enum)]
6465
pub enum Storage {
6566
/// Binary glTF 2.0.
6667
///

modeling-cmds/src/format/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ pub type InputFormat = InputFormat3d;
7979
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr)]
8080
#[serde(tag = "type", rename_all = "snake_case")]
8181
#[display(style = "snake_case")]
82-
#[cfg_attr(feature = "python", pyo3::pyclass)]
82+
#[cfg_attr(
83+
feature = "python",
84+
pyo3::pyclass,
85+
pyo3_stub_gen::derive::gen_stub_pyclass_complex_enum
86+
)]
8387
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
8488
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
8589
pub enum InputFormat3d {

modeling-cmds/src/format/obj.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub mod import {
1414
#[serde(rename = "ObjImportOptions")]
1515
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1616
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
17-
#[cfg_attr(feature = "python", pyo3::pyclass)]
17+
#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass)]
1818
pub struct Options {
1919
/// Co-ordinate system of input data.
2020
///
@@ -61,7 +61,7 @@ pub mod export {
6161
#[display("coords: {coords}, units: {units}")]
6262
#[serde(rename = "ObjExportOptions")]
6363
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
64-
#[cfg_attr(feature = "python", pyo3::pyclass)]
64+
#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass)]
6565
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
6666
pub struct Options {
6767
/// Co-ordinate system of output data.

modeling-cmds/src/format/ply.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub mod import {
1414
#[serde(rename = "PlyImportOptions")]
1515
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1616
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
17-
#[cfg_attr(feature = "python", pyo3::pyclass)]
17+
#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass)]
1818
pub struct Options {
1919
/// Co-ordinate system of input data.
2020
///
@@ -62,7 +62,7 @@ pub mod export {
6262
#[display("coords: {coords}, selection: {selection}, storage: {storage}, units: {units}")]
6363
#[serde(rename = "PlyExportOptions")]
6464
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
65-
#[cfg_attr(feature = "python", pyo3::pyclass)]
65+
#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass)]
6666
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
6767
pub struct Options {
6868
/// Co-ordinate system of output data.

0 commit comments

Comments
 (0)