mirror of
https://github.com/joshuadavidthomas/django-language-server.git
synced 2025-09-13 05:46:17 +00:00
Some checks are pending
lint / pre-commit (push) Waiting to run
lint / rustfmt (push) Waiting to run
lint / clippy (push) Waiting to run
lint / cargo-check (push) Waiting to run
release / release (push) Blocked by required conditions
test / generate-matrix (push) Waiting to run
release / build (push) Waiting to run
release / test (push) Waiting to run
test / Python , Django () (push) Blocked by required conditions
test / tests (push) Blocked by required conditions
zizmor 🌈 / zizmor latest via PyPI (push) Waiting to run
56 lines
1.8 KiB
Rust
56 lines
1.8 KiB
Rust
use std::env;
|
|
use std::path::PathBuf;
|
|
use std::process::Command;
|
|
|
|
fn get_python_executable_path() -> PathBuf {
|
|
let python = which::which("python3")
|
|
.or_else(|_| which::which("python"))
|
|
.expect("Python not found. Please install Python to build this project.");
|
|
println!(
|
|
"cargo:warning=Building Python inspector with: {}",
|
|
python.display()
|
|
);
|
|
python
|
|
}
|
|
|
|
fn main() {
|
|
println!("cargo:rerun-if-changed=../../python/src/djls_inspector");
|
|
println!("cargo:rerun-if-changed=../../python/build.py");
|
|
|
|
let workspace_dir = env::var("CARGO_WORKSPACE_DIR").expect("CARGO_WORKSPACE_DIR not set");
|
|
let workspace_path = PathBuf::from(workspace_dir);
|
|
let python_dir = workspace_path.join("python");
|
|
let dist_dir = python_dir.join("dist");
|
|
let pyz_path = dist_dir.join("djls_inspector.pyz");
|
|
|
|
std::fs::create_dir_all(&dist_dir).expect("Failed to create python/dist directory");
|
|
|
|
let python = get_python_executable_path();
|
|
|
|
let output = Command::new(&python)
|
|
.arg("build.py")
|
|
.current_dir(&python_dir)
|
|
.output()
|
|
.expect("Failed to run Python build script");
|
|
|
|
if !output.status.success() {
|
|
let stderr = String::from_utf8_lossy(&output.stderr);
|
|
let stdout = String::from_utf8_lossy(&output.stdout);
|
|
panic!("Failed to build Python inspector:\nSTDOUT:\n{stdout}\nSTDERR:\n{stderr}");
|
|
}
|
|
|
|
assert!(
|
|
pyz_path.exists(),
|
|
"Python inspector zipapp was not created at expected location: {}",
|
|
pyz_path.display()
|
|
);
|
|
|
|
let metadata =
|
|
std::fs::metadata(&pyz_path).expect("Failed to get metadata for inspector zipapp");
|
|
|
|
println!(
|
|
"cargo:warning=Successfully built Python inspector: {} ({} bytes)",
|
|
pyz_path.display(),
|
|
metadata.len()
|
|
);
|
|
}
|