refact: add cargo "python" feature for pyo3
This commit is contained in:
parent
00f23543a5
commit
0b06c62fd9
7 changed files with 12 additions and 6 deletions
|
|
@ -12,6 +12,10 @@ name = "trictrac_store"
|
|||
# "staticlib" → used by the C++ OpenSpiel game (cxxengine)
|
||||
crate-type = ["cdylib", "rlib", "staticlib"]
|
||||
|
||||
[features]
|
||||
# Enable Python bindings (required for maturin / AI training). Not available on wasm32.
|
||||
python = ["pyo3"]
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0"
|
||||
base64 = "0.21.7"
|
||||
|
|
@ -20,7 +24,7 @@ cxx = "1.0"
|
|||
log = "0.4.20"
|
||||
merge = "0.1.0"
|
||||
# generate python lib (with maturin) to be used in AI training
|
||||
pyo3 = { version = "0.23", features = ["extension-module", "abi3-py38"] }
|
||||
pyo3 = { version = "0.23", features = ["extension-module", "abi3-py38"], optional = true }
|
||||
rand = "0.9"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
transpose = "0.2.2"
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ pub use dice::{Dice, DiceRoller};
|
|||
pub mod training_common;
|
||||
|
||||
// python interface "trictrac_engine" (for AI training..)
|
||||
#[cfg(feature = "python")]
|
||||
mod pyengine;
|
||||
|
||||
// C++ interface via cxx.rs (for OpenSpiel C++ integration)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#[cfg(feature = "python")]
|
||||
use pyo3::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
|
|
@ -5,7 +6,7 @@ use std::fmt;
|
|||
// This just makes it easier to dissern between a player id and any ol' u64
|
||||
pub type PlayerId = u64;
|
||||
|
||||
#[pyclass(eq, eq_int)]
|
||||
#[cfg_attr(feature = "python", pyclass(eq, eq_int))]
|
||||
#[derive(Copy, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum Color {
|
||||
White,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue