31 lines
973 B
Rust
31 lines
973 B
Rust
use std::env;
|
|
use std::path::PathBuf;
|
|
|
|
fn main() {
|
|
// Configure PyO3 extension module build
|
|
|
|
// Enable GPU features if available
|
|
if env::var("CARGO_FEATURE_GPU").is_ok() {
|
|
println!("cargo:rustc-cfg=feature=\"gpu\"");
|
|
}
|
|
|
|
// Configure Python extension module
|
|
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
|
|
match target_os.as_str() {
|
|
"linux" => {
|
|
println!("cargo:rustc-link-arg=-Wl,-soname,rustytorch_ml.so");
|
|
}
|
|
"macos" => {
|
|
println!("cargo:rustc-link-arg=-Wl,-install_name,@rpath/rustytorch_ml.dylib");
|
|
}
|
|
_ => {}
|
|
}
|
|
|
|
// Set up Python paths for development
|
|
if let Ok(python_path) = env::var("PYTHON_SYS_EXECUTABLE") {
|
|
println!("cargo:rerun-if-env-changed=PYTHON_SYS_EXECUTABLE");
|
|
let python_dir = PathBuf::from(python_path).parent().unwrap().to_path_buf();
|
|
println!("cargo:rustc-env=PYTHON_DIR={}", python_dir.display());
|
|
}
|
|
}
|