1
1
use std:: fmt:: { Display , Formatter } ;
2
2
3
+ use crate :: python_interpreter:: { MINIMUM_PYPY_MINOR , MINIMUM_PYTHON_MINOR } ;
4
+
3
5
/// The name and version of the bindings crate
4
6
#[ derive( Clone , Debug , PartialEq , Eq ) ]
5
7
pub struct Bindings {
@@ -11,7 +13,7 @@ pub struct Bindings {
11
13
12
14
impl Bindings {
13
15
/// Returns the minimum python minor version supported
14
- pub fn minimal_python_minor_version ( & self ) -> usize {
16
+ fn minimal_python_minor_version ( & self ) -> usize {
15
17
use crate :: python_interpreter:: MINIMUM_PYTHON_MINOR ;
16
18
17
19
match self . name . as_str ( ) {
@@ -30,7 +32,7 @@ impl Bindings {
30
32
}
31
33
32
34
/// Returns the minimum PyPy minor version supported
33
- pub fn minimal_pypy_minor_version ( & self ) -> usize {
35
+ fn minimal_pypy_minor_version ( & self ) -> usize {
34
36
use crate :: python_interpreter:: MINIMUM_PYPY_MINOR ;
35
37
36
38
match self . name . as_str ( ) {
@@ -121,6 +123,34 @@ impl BridgeModel {
121
123
matches ! ( self , BridgeModel :: Bin ( _) )
122
124
}
123
125
126
+ /// Returns the minimum python minor version supported
127
+ pub fn minimal_python_minor_version ( & self ) -> usize {
128
+ match self {
129
+ BridgeModel :: Bin ( Some ( bindings) ) | BridgeModel :: Bindings ( bindings) => {
130
+ bindings. minimal_python_minor_version ( )
131
+ }
132
+ BridgeModel :: BindingsAbi3 {
133
+ bindings,
134
+ minor : abi3_minor,
135
+ ..
136
+ } => {
137
+ let bindings_minor = bindings. minimal_python_minor_version ( ) ;
138
+ bindings_minor. max ( * abi3_minor as usize )
139
+ }
140
+ BridgeModel :: Bin ( None ) | BridgeModel :: Cffi | BridgeModel :: UniFfi => {
141
+ MINIMUM_PYTHON_MINOR
142
+ }
143
+ }
144
+ }
145
+
146
+ /// Returns the minimum PyPy minor version supported
147
+ pub fn minimal_pypy_minor_version ( & self ) -> usize {
148
+ match self . bindings ( ) {
149
+ Some ( bindings) => bindings. minimal_pypy_minor_version ( ) ,
150
+ None => MINIMUM_PYPY_MINOR ,
151
+ }
152
+ }
153
+
124
154
/// free-threaded Python support
125
155
pub fn supports_free_threaded ( & self ) -> bool {
126
156
match self {
0 commit comments