@@ -230,6 +230,7 @@ print_if_set("base_prefix", base_prefix)
230
230
print("executable", sys.executable)
231
231
print("calcsize_pointer", struct.calcsize("P"))
232
232
print("mingw", get_platform().startswith("mingw"))
233
+ print("ext_suffix", get_config_var("EXT_SUFFIX"))
233
234
"# ;
234
235
let output = run_python_script ( interpreter. as_ref ( ) , SCRIPT ) ?;
235
236
let map: HashMap < String , String > = parse_script_output ( & output) ;
@@ -261,6 +262,10 @@ print("mingw", get_platform().startswith("mingw"))
261
262
implementation,
262
263
abi3,
263
264
map[ "mingw" ] . as_str ( ) == "True" ,
265
+ // This is the best heuristic currently available to detect debug build
266
+ // on Windows from sysconfig - e.g. ext_suffix may be
267
+ // `_d.cp312-win_amd64.pyd` for 3.12 debug build
268
+ map[ "ext_suffix" ] . starts_with ( "_d." ) ,
264
269
)
265
270
} else {
266
271
default_lib_name_unix (
@@ -1418,6 +1423,7 @@ fn default_abi3_config(host: &Triple, version: PythonVersion) -> InterpreterConf
1418
1423
implementation,
1419
1424
abi3,
1420
1425
false ,
1426
+ false ,
1421
1427
) )
1422
1428
} else {
1423
1429
None
@@ -1493,6 +1499,7 @@ fn default_lib_name_for_target(
1493
1499
implementation,
1494
1500
abi3,
1495
1501
false ,
1502
+ false ,
1496
1503
) )
1497
1504
} else if is_linking_libpython_for_target ( target) {
1498
1505
Some ( default_lib_name_unix ( version, implementation, None ) )
@@ -1506,8 +1513,13 @@ fn default_lib_name_windows(
1506
1513
implementation : PythonImplementation ,
1507
1514
abi3 : bool ,
1508
1515
mingw : bool ,
1516
+ debug : bool ,
1509
1517
) -> String {
1510
- if abi3 && !implementation. is_pypy ( ) {
1518
+ if debug {
1519
+ // CPython bug: linking against python3_d.dll raises error
1520
+ // https://github.com/python/cpython/issues/101614
1521
+ format ! ( "python{}{}_d" , version. major, version. minor)
1522
+ } else if abi3 && !implementation. is_pypy ( ) {
1511
1523
WINDOWS_ABI3_LIB_NAME . to_owned ( )
1512
1524
} else if mingw {
1513
1525
// https://packages.msys2.org/base/mingw-w64-python
@@ -2244,7 +2256,8 @@ mod tests {
2244
2256
PythonVersion { major: 3 , minor: 7 } ,
2245
2257
CPython ,
2246
2258
false ,
2247
- false
2259
+ false ,
2260
+ false ,
2248
2261
) ,
2249
2262
"python37" ,
2250
2263
) ;
@@ -2253,7 +2266,8 @@ mod tests {
2253
2266
PythonVersion { major: 3 , minor: 7 } ,
2254
2267
CPython ,
2255
2268
true ,
2256
- false
2269
+ false ,
2270
+ false ,
2257
2271
) ,
2258
2272
"python3" ,
2259
2273
) ;
@@ -2262,7 +2276,8 @@ mod tests {
2262
2276
PythonVersion { major: 3 , minor: 7 } ,
2263
2277
CPython ,
2264
2278
false ,
2265
- true
2279
+ true ,
2280
+ false ,
2266
2281
) ,
2267
2282
"python3.7" ,
2268
2283
) ;
@@ -2271,7 +2286,8 @@ mod tests {
2271
2286
PythonVersion { major: 3 , minor: 7 } ,
2272
2287
CPython ,
2273
2288
true ,
2274
- true
2289
+ true ,
2290
+ false ,
2275
2291
) ,
2276
2292
"python3" ,
2277
2293
) ;
@@ -2280,10 +2296,33 @@ mod tests {
2280
2296
PythonVersion { major: 3 , minor: 7 } ,
2281
2297
PyPy ,
2282
2298
true ,
2283
- false
2299
+ false ,
2300
+ false ,
2284
2301
) ,
2285
2302
"python37" ,
2286
2303
) ;
2304
+ assert_eq ! (
2305
+ super :: default_lib_name_windows(
2306
+ PythonVersion { major: 3 , minor: 7 } ,
2307
+ CPython ,
2308
+ false ,
2309
+ false ,
2310
+ true ,
2311
+ ) ,
2312
+ "python37_d" ,
2313
+ ) ;
2314
+ // abi3 debug builds on windows use version-specific lib
2315
+ // to workaround https://github.com/python/cpython/issues/101614
2316
+ assert_eq ! (
2317
+ super :: default_lib_name_windows(
2318
+ PythonVersion { major: 3 , minor: 7 } ,
2319
+ CPython ,
2320
+ true ,
2321
+ false ,
2322
+ true ,
2323
+ ) ,
2324
+ "python37_d" ,
2325
+ ) ;
2287
2326
}
2288
2327
2289
2328
#[ test]
0 commit comments