[Lldb-commits] [lldb] [lldb] Use (_d).pyd as Python extension suffix on Windows (PR #195262)
via lldb-commits
lldb-commits at lists.llvm.org
Fri May 1 06:21:56 PDT 2026
https://github.com/Nerixyz created https://github.com/llvm/llvm-project/pull/195262
The current Windows x86_x64 installer ships a `_lldb.abi3None` in `lib\site-packages\lldb\native`. This will cause errors when trying to import LLDB in Python.
We always use `.abi3{SHLIB_SUFFIX}` as the Python extension suffix in `get-python-config.py`. On Windows(-msvc), this won't result in the correct path. `SHLIB_SUFFIX` is not defined there.
The recognized extensions are:
```console
> python -c "import importlib.machinery;print(importlib.machinery.EXTENSION_SUFFIXES)"
['.cp314-win_amd64.pyd', '.pyd']
> python_d -c "import importlib.machinery;print(importlib.machinery.EXTENSION_SUFFIXES)"
['_d.cp314-win_amd64.pyd', '_d.pyd']
```
The first one is equal to `sysconfig.get_config_var("EXT_SUFFIX")`.
I changed `get-python-config.py` to use `.pyd` if `SHLIB_SUFFIX` is undefined. This is currently hardcoded. It seems like cpython has some contract that the last suffix in `EXTENSION_SUFFIXES` is the untagged one ([from this test](https://github.com/python/cpython/blob/f2c7c0d2b799c927d9a78e87e4a640d3f9b0356c/Lib/test/test_traceback.py#L5225-L5232)). But I haven't found any documentation on that.
>From bb590593fbe649f0b31470cb062a8b307ec11081 Mon Sep 17 00:00:00 2001
From: Nerixyz <nerixdev at outlook.de>
Date: Fri, 1 May 2026 15:08:53 +0200
Subject: [PATCH] [lldb] Use (_d).pyd as extension suffix on Windows
---
lldb/bindings/python/get-python-config.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/lldb/bindings/python/get-python-config.py b/lldb/bindings/python/get-python-config.py
index bf8cc48b013e1..efda709d485a8 100755
--- a/lldb/bindings/python/get-python-config.py
+++ b/lldb/bindings/python/get-python-config.py
@@ -72,7 +72,15 @@ def main():
sys.exit(1)
elif args.variable_name == "LLDB_PYTHON_EXT_SUFFIX":
if args.stable_abi:
- print(".abi3%s" % sysconfig.get_config_var("SHLIB_SUFFIX"))
+ shlib_suffix = sysconfig.get_config_var("SHLIB_SUFFIX")
+ if shlib_suffix:
+ print(".abi3%s" % sysconfig.get_config_var("SHLIB_SUFFIX"))
+ else:
+ assert os.name == "nt"
+ if sysconfig.get_config_var("EXT_SUFFIX").startswith("_d"):
+ print("_d.pyd")
+ else:
+ print(".pyd")
else:
print(sysconfig.get_config_var("EXT_SUFFIX"))
else:
More information about the lldb-commits
mailing list