@@ -175,6 +175,11 @@ pub struct ImportLibraryGenerator {
175175 version : Option < ( u8 , u8 ) > ,
176176 /// Python interpreter implementation
177177 implementation : PythonImplementation ,
178+ /// Optional Python ABI tag
179+ ///
180+ /// For example, `"t"` stands for the free-threaded CPython v3.13 build
181+ /// aka CPython `3.13t`.
182+ abi_tag : Option < String > ,
178183}
179184
180185impl ImportLibraryGenerator {
@@ -191,6 +196,7 @@ impl ImportLibraryGenerator {
191196 env : env. to_string ( ) ,
192197 version : None ,
193198 implementation : PythonImplementation :: CPython ,
199+ abi_tag : None ,
194200 }
195201 }
196202
@@ -202,6 +208,17 @@ impl ImportLibraryGenerator {
202208 self
203209 }
204210
211+ /// Sets the ABI tag for the `pythonXY<abi>.dll` import library.
212+ ///
213+ /// For example, `"t"` stands for the free-threaded CPython v3.13 build
214+ /// aka CPython `3.13t`. `python313t.dll` import library is generated.
215+ ///
216+ /// The untagged versioned `pythonXY.dll` is generated by default.
217+ pub fn abi_tag ( & mut self , abi_tag : Option < & str > ) -> & mut Self {
218+ self . abi_tag = abi_tag. map ( ToOwned :: to_owned) ;
219+ self
220+ }
221+
205222 /// Sets Python interpreter implementation
206223 pub fn implementation ( & mut self , implementation : PythonImplementation ) -> & mut Self {
207224 self . implementation = implementation;
@@ -256,7 +273,11 @@ impl ImportLibraryGenerator {
256273 Some ( ( 3 , 10 ) ) => ( "python310.def" , include_str ! ( "python310.def" ) ) ,
257274 Some ( ( 3 , 11 ) ) => ( "python311.def" , include_str ! ( "python311.def" ) ) ,
258275 Some ( ( 3 , 12 ) ) => ( "python312.def" , include_str ! ( "python312.def" ) ) ,
259- Some ( ( 3 , 13 ) ) => ( "python313.def" , include_str ! ( "python313.def" ) ) ,
276+ Some ( ( 3 , 13 ) ) => match self . abi_tag . as_deref ( ) {
277+ Some ( "t" ) => ( "python313t.def" , include_str ! ( "python313t.def" ) ) ,
278+ None => ( "python313.def" , include_str ! ( "python313.def" ) ) ,
279+ _ => return Err ( Error :: new ( ErrorKind :: Other , "Unsupported Python ABI tag" ) ) ,
280+ } ,
260281 _ => return Err ( Error :: new ( ErrorKind :: Other , "Unsupported Python version" ) ) ,
261282 } ,
262283 PythonImplementation :: PyPy => match self . version {
0 commit comments