{"id":"ba29bb313c5d2105","repo":"pypa/pip","slug":"invalid-sysconfig-get-config-var-ext-suffix","errorCode":null,"errorMessage":"invalid sysconfig.get_config_var('EXT_SUFFIX')","messagePattern":"invalid sysconfig\\.get_config_var\\('EXT_SUFFIX'\\)","errorType":"exception","errorClass":"SystemError","httpStatus":null,"severity":"error","filePath":"src/pip/_vendor/packaging/tags.py","lineNumber":421,"sourceCode":"\ndef _generic_abi() -> list[str]:\n    \"\"\"\n    Return the ABI tag based on EXT_SUFFIX.\n    \"\"\"\n    # The following are examples of `EXT_SUFFIX`.\n    # We want to keep the parts which are related to the ABI and remove the\n    # parts which are related to the platform:\n    # - linux:   '.cpython-310-x86_64-linux-gnu.so' => cp310\n    # - mac:     '.cpython-310-darwin.so'           => cp310\n    # - win:     '.cp310-win_amd64.pyd'             => cp310\n    # - win:     '.pyd'                             => cp37 (uses _cpython_abis())\n    # - pypy:    '.pypy38-pp73-x86_64-linux-gnu.so' => pypy38_pp73\n    # - graalpy: '.graalpy-38-native-x86_64-darwin.dylib'\n    #                                               => graalpy_38_native\n\n    ext_suffix = _get_config_var(\"EXT_SUFFIX\", warn=True)\n    if not isinstance(ext_suffix, str) or ext_suffix[0] != \".\":\n        raise SystemError(\"invalid sysconfig.get_config_var('EXT_SUFFIX')\")\n    parts = ext_suffix.split(\".\")\n    if len(parts) < 3:\n        # CPython3.7 and earlier uses \".pyd\" on Windows.\n        return _cpython_abis(sys.version_info[:2])\n    soabi = parts[1]\n    if soabi.startswith(\"cpython\"):\n        # non-windows\n        abi = \"cp\" + soabi.split(\"-\")[1]\n    elif soabi.startswith(\"cp\"):\n        # windows\n        abi = soabi.split(\"-\")[0]\n    elif soabi.startswith(\"pypy\"):\n        abi = \"-\".join(soabi.split(\"-\")[:2])\n    elif soabi.startswith(\"graalpy\"):\n        abi = \"-\".join(soabi.split(\"-\")[:3])\n    elif soabi:\n        # pyston, ironpython, others?\n        abi = soabi","sourceCodeStart":403,"sourceCodeEnd":439,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_vendor/packaging/tags.py#L403-L439","documentation":"Raised by `_generic_abi()` in `packaging.tags` when `sysconfig.get_config_var('EXT_SUFFIX')` returns a value that is not a string or does not begin with a '.'. The EXT_SUFFIX encodes the CPython ABI (e.g. '.cpython-310-x86_64-linux-gnu.so'); if it is malformed, the library cannot infer the current interpreter's ABI tag and aborts with `SystemError`. This almost always indicates a broken or non-standard Python build/install rather than a packaging bug.","triggerScenarios":"Calling `tags._generic_abi()` directly, or indirectly via `tags.sys_tags()` / `tags.generic_tags()` / `pip`-style wheel compatibility resolution, on an interpreter where `sysconfig.get_config_var('EXT_SUFFIX')` returns `None`, a non-string, or a string without a leading dot (e.g. a self-compiled or embedded Python with a misconfigured `pyconfig.h` / `sysconfigdata`).","commonSituations":"A custom-compiled CPython missing the EXT_SUFFIX macro; a stripped/redistributable Python build (some Linux distros, conda envs, embedded Pythons); a stub or `python-build-standalone` artifact with incomplete sysconfig; running under an unusual interpreter (old IronPython, modified PyPy).","solutions":["Verify the value with `python -c \"import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))\"` — it must be a string starting with '.'.","Switch to a known-good interpreter (official CPython from python.org, an unmodified conda env, distro python3 package).","If compiling CPython yourself, ensure EXT_SUFFIX is set (it derives from `ALT_SOABI`/`SOABI`/`EXT_SUFFIX` config); reconfigure and rebuild.","If you cannot change interpreters, avoid the generic-ABI path by constructing `Tag` objects explicitly or calling an interpreter-specific tags function (e.g. `cpython_tags`) with explicit `abis=...`.","Report the broken sysconfig to the maintainer of your Python distribution."],"exampleFix":"// before\nfrom pip._vendor.packaging.tags import sys_tags\ntags = list(sys_tags())  # raises SystemError on broken EXT_SUFFIX\n\n# after\nimport sysconfig\nfrom pip._vendor.packaging.tags import cpython_tags\next = sysconfig.get_config_var('EXT_SUFFIX')\nif not isinstance(ext, str) or not ext.startswith('.'):\n    # fall back to explicit interpreter/abi/platform\n    tags = list(cpython_tags(abis=['cp311', 'abi3', 'none'],\n                             platforms=['linux_x86_64']))\nelse:\n    tags = list(sys_tags())","handlingStrategy":"try-catch","validationCode":"import sysconfig\n\ndef has_valid_ext_suffix() -> bool:\n    ext = sysconfig.get_config_var('EXT_SUFFIX')\n    return isinstance(ext, str) and ext.startswith('.')","typeGuard":null,"tryCatchPattern":"from pip._vendor.packaging import tags\n\ntry:\n    abi = tags._generic_abi()\nexcept SystemError:\n    # broken interpreter sysconfig; supply explicit abis instead\n    abi = ['cp311', 'abi3', 'none']","preventionTips":["Run on an official, unmodified CPython interpreter where EXT_SUFFIX is well-defined.","Pin to interpreter distributions known to ship complete sysconfig (python.org, distro python3, unmodified conda).","In cross-env/embedded scenarios, pass explicit `abis=`/`platforms=` to `cpython_tags`/`generic_tags` rather than relying on EXT_SUFFIX inference."],"tags":["python","packaging","tags","sysconfig","environment","abi"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}