Skip to content

Commit 3d140e5

Browse files
move project inspector zipapp files to project crate (#240)
1 parent 12671eb commit 3d140e5

File tree

10 files changed

+23
-78
lines changed

10 files changed

+23
-78
lines changed

crates/djls-project/build.rs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,37 @@ use std::env;
22
use std::path::PathBuf;
33
use std::process::Command;
44

5-
fn get_python_executable_path() -> PathBuf {
5+
fn main() {
6+
println!("cargo:rerun-if-changed=build.rs");
7+
8+
let manifest_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set");
9+
let manifest_path = PathBuf::from(manifest_dir);
10+
let inspector_dir = manifest_path.join("inspector");
11+
let dist_dir = manifest_path.join("dist");
12+
let pyz_path = dist_dir.join("djls_inspector.pyz");
13+
14+
println!("cargo:rerun-if-changed={}", inspector_dir.display());
15+
16+
std::fs::create_dir_all(&dist_dir)
17+
.expect("Failed to create inspector/dist directory for Python zipapp");
18+
619
let python = which::which("python3")
720
.or_else(|_| which::which("python"))
821
.expect("Python not found. Please install Python to build this project.");
922
println!(
1023
"cargo:warning=Building Python inspector with: {}",
1124
python.display()
1225
);
13-
python
14-
}
15-
16-
fn main() {
17-
println!("cargo:rerun-if-changed=../../python/src/djls_inspector");
18-
println!("cargo:rerun-if-changed=../../python/build.py");
19-
20-
let workspace_dir = env::var("CARGO_WORKSPACE_DIR").expect("CARGO_WORKSPACE_DIR not set");
21-
let workspace_path = PathBuf::from(workspace_dir);
22-
let python_dir = workspace_path.join("python");
23-
let dist_dir = python_dir.join("dist");
24-
let pyz_path = dist_dir.join("djls_inspector.pyz");
25-
26-
std::fs::create_dir_all(&dist_dir).expect("Failed to create python/dist directory");
27-
28-
let python = get_python_executable_path();
2926

3027
let output = Command::new(&python)
31-
.arg("build.py")
32-
.current_dir(&python_dir)
28+
.arg("-m")
29+
.arg("zipapp")
30+
.arg(&inspector_dir)
31+
.arg("-o")
32+
.arg(&pyz_path)
33+
.arg("-c")
3334
.output()
34-
.expect("Failed to run Python build script");
35+
.expect("Failed to run Python zipapp builder");
3536

3637
if !output.status.success() {
3738
let stderr = String::from_utf8_lossy(&output.stderr);
File renamed without changes.
File renamed without changes.
File renamed without changes.

crates/djls-project/src/inspector/zipapp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use camino::Utf8Path;
66
use tempfile::NamedTempFile;
77

88
const INSPECTOR_PYZ: &[u8] = include_bytes!(concat!(
9-
env!("CARGO_WORKSPACE_DIR"),
10-
"/python/dist/djls_inspector.pyz"
9+
env!("CARGO_MANIFEST_DIR"),
10+
"/dist/djls_inspector.pyz"
1111
));
1212

1313
pub struct InspectorFile(NamedTempFile);

python/Justfile

Lines changed: 0 additions & 12 deletions
This file was deleted.

python/build.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

python/pyproject.toml

Lines changed: 0 additions & 12 deletions
This file was deleted.

python/uv.lock

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)