-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
119 lines (96 loc) · 3.42 KB
/
build.rs
File metadata and controls
119 lines (96 loc) · 3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
use std::env;
use std::process::Command;
fn main() {
println!("cargo:rerun-if-changed=ember-graph-import/pyproject.toml");
let is_windows = cfg!(windows);
if is_windows {
windows_setup();
} else {
unix_setup();
}
}
fn windows_setup() {
println!("cargo:warning=🧩 Running on Windows platform");
// check if the `uv` package manager is installed
let uv_exists = Command::new("powershell")
.arg("-Command")
.arg("Get-Command uv -ErrorAction SilentlyContinue")
.status()
.map(|status| status.success())
.unwrap_or(false);
if !uv_exists {
println!("cargo:warning=🌐 Installing uv package manager on Windows...\n");
// install the `uv` package manager (via Powershell)
let install_status = Command::new("powershell")
.arg("-ExecutionPolicy")
.arg("ByPass")
.arg("-Command")
.arg("irm https://astral.sh/uv/install.ps1 | iex")
.status()
.expect("❌ Failed to install uv on Windows");
if !install_status.success() {
panic!("❌ Failed to install uv package manager on Windows");
}
println!("cargo:warning=✅ uv package manager installed successfully on Windows");
} else {
println!(
"cargo:warning=✅ uv package manager already installed on Windows, skipping installation"
);
}
// sync Python dependencies
println!("cargo:warning=🌐 Syncing Python dependencies on Windows...\n");
// Windows requires specific handling for paths
let current_dir = env::current_dir().expect("❌ Failed to get current directory");
let ember_dir = current_dir.join("ember-graph-import");
let sync_status = Command::new("powershell")
.arg("-Command")
.arg(format!(
"cd '{}'; uv sync; cd '{}'",
ember_dir.display(),
current_dir.display()
))
.status()
.expect("❌ Failed to sync dependencies on Windows");
if !sync_status.success() {
panic!("❌ Failed to sync Python dependencies on Windows");
}
println!("cargo:warning=✅ Python dependencies synced successfully on Windows");
}
fn unix_setup() {
println!("cargo:warning=🧩 Running on Unix-like platform");
// check if the `uv` package manager is installed
let uv_exists = Command::new("sh")
.arg("-c")
.arg("command -v uv")
.status()
.map(|status| status.success())
.unwrap_or(false);
if !uv_exists {
println!("cargo:warning=🌐 Installing uv package manager on Unix...\n");
// install the `uv` package manager (via sh)
let install_status = Command::new("sh")
.arg("-c")
.arg("curl -LsSf https://astral.sh/uv/install.sh | sh")
.status()
.expect("❌ Failed to install uv on Unix");
if !install_status.success() {
panic!("❌ Failed to install uv package manager on Unix");
}
println!("cargo:warning=✅ uv package manager installed successfully on Unix");
} else {
println!(
"cargo:warning=✅ uv package manager already installed on Unix, skipping installation"
);
}
// sync Python dependencies
println!("cargo:warning=🌐 Syncing Python dependencies on Unix...\n");
let sync_status = Command::new("sh")
.arg("-c")
.arg("cd ember-graph-import && uv sync && cd ..")
.status()
.expect("❌ Failed to sync dependencies on Unix");
if !sync_status.success() {
panic!("❌ Failed to sync Python dependencies on Unix");
}
println!("cargo:warning=✅ Python dependencies synced successfully on Unix");
}