@@ -2,36 +2,37 @@ use std::env;
22use std:: path:: PathBuf ;
33use 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 ) ;
0 commit comments