Skip to content

Commit 5d20b9c

Browse files
authored
updates for generating python types (#918)
* updates for generating python types Signed-off-by: Jessie Frazelle <[email protected]> * updates Signed-off-by: Jessie Frazelle <[email protected]> * updates Signed-off-by: Jessie Frazelle <[email protected]> * updates Signed-off-by: Jessie Frazelle <[email protected]> * updates Signed-off-by: Jessie Frazelle <[email protected]> * updates Signed-off-by: Jessie Frazelle <[email protected]> --------- Signed-off-by: Jessie Frazelle <[email protected]>
1 parent e7a8229 commit 5d20b9c

File tree

19 files changed

+294
-105
lines changed

19 files changed

+294
-105
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.

flake.lock

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

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
rustToolchain
5454

5555
cargo-nextest
56+
cargo-sort
5657

5758
just
5859
openssl

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/base64.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ static ALLOWED_DECODING_FORMATS: &[data_encoding::Encoding] = &[
1818
];
1919

2020
#[derive(Debug, Clone, PartialEq, Eq)]
21+
#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass)]
2122
/// A container for binary that should be base64 encoded in serialisation. In reverse
2223
/// when deserializing, will decode from many different types of base64 possible.
2324
pub struct Base64Data(pub Vec<u8>);

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/def_enum.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1187,11 +1187,12 @@ define_modeling_cmd_enum! {
11871187
}
11881188

11891189
/// Enum containing the variety of image formats snapshots may be exported to.
1190-
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, FromStr, Display)]
1190+
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, FromStr, Display)]
11911191
#[serde(rename_all = "snake_case")]
11921192
#[display(style = "snake_case")]
11931193
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
11941194
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1195+
#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass_enum)]
11951196
pub enum ImageFormat {
11961197
/// .png format
11971198
Png,

modeling-cmds/src/format/dxf.rs

Lines changed: 3 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,13 +30,14 @@ 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,
3637
}
3738

3839
#[cfg(feature = "python")]
40+
#[pyo3_stub_gen::derive::gen_stub_pymethods]
3941
#[pyo3::pymethods]
4042
impl Options {
4143
#[new]

modeling-cmds/src/format/fbx.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ 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")]
18+
#[pyo3_stub_gen::derive::gen_stub_pymethods]
1819
#[pyo3::pymethods]
1920
impl Options {
2021
#[new]
@@ -33,7 +34,7 @@ pub mod export {
3334
#[derive(Clone, Debug, Default, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema)]
3435
#[serde(rename = "FbxExportOptions")]
3536
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
36-
#[cfg_attr(feature = "python", pyo3::pyclass)]
37+
#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass)]
3738
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
3839
pub struct Options {
3940
/// Specifies which kind of FBX will be exported.
@@ -44,6 +45,7 @@ pub mod export {
4445
}
4546

4647
#[cfg(feature = "python")]
48+
#[pyo3_stub_gen::derive::gen_stub_pymethods]
4749
#[pyo3::pymethods]
4850
impl Options {
4951
#[new]
@@ -77,6 +79,7 @@ pub mod export {
7779
#[serde(rename = "FbxStorage", rename_all = "snake_case")]
7880
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
7981
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
82+
#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass_enum)]
8083
pub enum Storage {
8184
/// ASCII FBX encoding.
8285
Ascii,

modeling-cmds/src/format/gltf.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ 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")]
19+
#[pyo3_stub_gen::derive::gen_stub_pymethods]
1920
#[pyo3::pymethods]
2021
impl Options {
2122
#[new]
@@ -34,7 +35,7 @@ pub mod export {
3435
#[display("storage: {storage}, presentation: {presentation}")]
3536
#[serde(rename = "GltfExportOptions")]
3637
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
37-
#[cfg_attr(feature = "python", pyo3::pyclass)]
38+
#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass)]
3839
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
3940
pub struct Options {
4041
/// Specifies which kind of glTF 2.0 will be exported.
@@ -44,6 +45,7 @@ pub mod export {
4445
}
4546

4647
#[cfg(feature = "python")]
48+
#[pyo3_stub_gen::derive::gen_stub_pymethods]
4749
#[pyo3::pymethods]
4850
impl Options {
4951
#[new]
@@ -61,6 +63,7 @@ pub mod export {
6163
#[serde(rename = "GltfStorage", rename_all = "snake_case")]
6264
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
6365
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
66+
#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass_enum)]
6467
pub enum Storage {
6568
/// Binary glTF 2.0.
6669
///

0 commit comments

Comments
 (0)