@@ -854,9 +854,17 @@ fn configure(interpreter_config: &InterpreterConfig) -> Result<()> {
854
854
println ! ( "cargo:rustc-cfg=Py_3_{}" , i) ;
855
855
}
856
856
857
+ configure_min_const_generics ( ) ;
858
+
857
859
Ok ( ( ) )
858
860
}
859
861
862
+ fn configure_min_const_generics ( ) {
863
+ if rustc_minor_version ( ) . unwrap_or ( 0 ) >= 51 {
864
+ println ! ( "cargo:rustc-cfg=min_const_generics" ) ;
865
+ }
866
+ }
867
+
860
868
fn check_target_architecture ( interpreter_config : & InterpreterConfig ) -> Result < ( ) > {
861
869
// Try to check whether the target architecture matches the python library
862
870
let rust_target = match cargo_env_var ( "CARGO_CFG_TARGET_POINTER_WIDTH" )
@@ -922,7 +930,7 @@ fn configure_abi3_without_interpreter() {
922
930
}
923
931
924
932
fn rustc_minor_version ( ) -> Option < u32 > {
925
- let rustc = env :: var_os ( "RUSTC" ) ?;
933
+ let rustc = env_var ( "RUSTC" ) ?;
926
934
let output = Command :: new ( rustc) . arg ( "--version" ) . output ( ) . ok ( ) ?;
927
935
let version = core:: str:: from_utf8 ( & output. stdout ) . ok ( ) ?;
928
936
let mut pieces = version. split ( '.' ) ;
@@ -932,12 +940,6 @@ fn rustc_minor_version() -> Option<u32> {
932
940
pieces. next ( ) ?. parse ( ) . ok ( )
933
941
}
934
942
935
- fn manage_min_const_generics ( ) {
936
- if rustc_minor_version ( ) . unwrap_or ( 0 ) >= 51 {
937
- println ! ( "cargo:rustc-cfg=min_const_generics" ) ;
938
- }
939
- }
940
-
941
943
fn main_impl ( ) -> Result < ( ) > {
942
944
// If PYO3_NO_PYTHON is set with abi3, we can build PyO3 without calling Python.
943
945
// We only check for the abi3-py3{ABI3_MAX_MINOR} because lower versions depend on it.
@@ -974,8 +976,6 @@ fn main_impl() -> Result<()> {
974
976
println ! ( "cargo:rustc-cfg={}=\" {}\" " , CFG_KEY , flag)
975
977
}
976
978
977
- manage_min_const_generics ( ) ;
978
-
979
979
Ok ( ( ) )
980
980
}
981
981
0 commit comments