Skip to content

Commit 07c8e84

Browse files
committed
Include abi tag for free-threaded extensions
1 parent 94e5fab commit 07c8e84

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

cpython-windows/build.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,20 @@ def find_additional_dependencies(project: pathlib.Path):
12481248

12491249
return set()
12501250

1251+
if arch == "amd64":
1252+
abi_platform = "win_amd64"
1253+
elif arch == "x86":
1254+
abi_platform = "win32"
1255+
else:
1256+
raise ValueError("unhandled arch: %s" % arch)
1257+
1258+
if freethreaded:
1259+
abi_tag = ".cp%st-%s" % (python_majmin, abi_platform)
1260+
lib_suffix = "t"
1261+
else:
1262+
abi_tag = ""
1263+
lib_suffix = ""
1264+
12511265
# Copy object files for core sources into their own directory.
12521266
core_dir = out_dir / "build" / "core"
12531267
core_dir.mkdir(parents=True)
@@ -1267,11 +1281,6 @@ def find_additional_dependencies(project: pathlib.Path):
12671281

12681282
exts = ("lib", "exp")
12691283

1270-
if freethreaded:
1271-
lib_suffix = "t"
1272-
else:
1273-
lib_suffix = ""
1274-
12751284
for ext in exts:
12761285
source = outputs_path / ("python%s%s.%s" % (python_majmin, lib_suffix, ext))
12771286
dest = core_dir / ("python%s%s.%s" % (python_majmin, lib_suffix, ext))
@@ -1364,12 +1373,15 @@ def find_additional_dependencies(project: pathlib.Path):
13641373
res["extensions"][ext] = [entry]
13651374

13661375
# Copy the extension static library.
1367-
ext_static = outputs_path / ("%s.lib" % ext)
1368-
dest = dest_dir / ("%s.lib" % ext)
1376+
ext_static = outputs_path / ("%s%s.lib" % (ext, abi_tag))
1377+
dest = dest_dir / ("%s%s.lib" % (ext, abi_tag))
13691378
log("copying static extension %s" % ext_static)
13701379
shutil.copyfile(ext_static, dest)
13711380

1372-
res["extensions"][ext][0]["shared_lib"] = "install/DLLs/%s.pyd" % ext
1381+
res["extensions"][ext][0]["shared_lib"] = "install/DLLs/%s%s.pyd" % (
1382+
ext,
1383+
abi_tag,
1384+
)
13731385

13741386
lib_dir = out_dir / "build" / "lib"
13751387
lib_dir.mkdir()

0 commit comments

Comments
 (0)