11use std:: fmt:: { Display , Formatter } ;
22
3+ use crate :: python_interpreter:: { MINIMUM_PYPY_MINOR , MINIMUM_PYTHON_MINOR } ;
4+
35/// The name and version of the bindings crate
46#[ derive( Clone , Debug , PartialEq , Eq ) ]
57pub struct Bindings {
@@ -11,7 +13,7 @@ pub struct Bindings {
1113
1214impl Bindings {
1315 /// Returns the minimum python minor version supported
14- pub fn minimal_python_minor_version ( & self ) -> usize {
16+ fn minimal_python_minor_version ( & self ) -> usize {
1517 use crate :: python_interpreter:: MINIMUM_PYTHON_MINOR ;
1618
1719 match self . name . as_str ( ) {
@@ -30,7 +32,7 @@ impl Bindings {
3032 }
3133
3234 /// Returns the minimum PyPy minor version supported
33- pub fn minimal_pypy_minor_version ( & self ) -> usize {
35+ fn minimal_pypy_minor_version ( & self ) -> usize {
3436 use crate :: python_interpreter:: MINIMUM_PYPY_MINOR ;
3537
3638 match self . name . as_str ( ) {
@@ -121,6 +123,34 @@ impl BridgeModel {
121123 matches ! ( self , BridgeModel :: Bin ( _) )
122124 }
123125
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+
124154 /// free-threaded Python support
125155 pub fn supports_free_threaded ( & self ) -> bool {
126156 match self {
0 commit comments