1- use std:: env;
2- use std:: path:: Path ;
3- use std:: process:: Command ;
4- use std:: str:: from_utf8;
5-
6- fn generate_self_schema ( ) {
7- println ! ( "cargo:rerun-if-changed=python/pydantic_core/core_schema.py" ) ;
8- println ! ( "cargo:rerun-if-changed=generate_self_schema.py" ) ;
9- if Path :: new ( "./src/self_schema.py" ) . exists ( ) && option_env ! ( "CI" ) == Some ( "true" ) {
10- // self_schema.py already exists and CI indicates we're running on a github actions build,
11- // don't bother generating again
12- return ;
13- }
14-
15- let output = Command :: new (
16- env:: var ( "PYTHON" )
17- . ok ( )
18- . or_else ( || pyo3_build_config:: get ( ) . executable . clone ( ) )
19- . unwrap_or_else ( || "python3" . to_owned ( ) ) ,
20- )
21- . arg ( "generate_self_schema.py" )
22- . output ( )
23- . expect ( "failed to execute process" ) ;
24-
25- if !output. status . success ( ) {
26- let stdout = from_utf8 ( & output. stdout ) . unwrap ( ) ;
27- let stderr = from_utf8 ( & output. stderr ) . unwrap ( ) ;
28- eprint ! ( "{stdout}{stderr}" ) ;
29- panic ! ( "generate_self_schema.py failed with {}" , output. status) ;
30- }
31- }
32-
331fn main ( ) {
342 pyo3_build_config:: use_pyo3_cfgs ( ) ;
353 if let Some ( true ) = version_check:: supports_feature ( "coverage_attribute" ) {
@@ -44,7 +12,5 @@ fn main() {
4412 println ! ( "cargo:rustc-cfg=specified_profile_use" ) ;
4513 }
4614 println ! ( "cargo:rustc-check-cfg=cfg(specified_profile_use)" ) ;
47-
48- generate_self_schema ( ) ;
4915 println ! ( "cargo:rustc-env=PROFILE={}" , std:: env:: var( "PROFILE" ) . unwrap( ) ) ;
5016}
0 commit comments