Skip to content

New sysconfig API: Build information - Compilation #103482

Open
@FFY00

Description

@FFY00

Feature or enhancement

sysconfig should export all the information required to build extensions.

Pitch

The new API should try to expose the information in a compiler-agnostic way.

Information to expose

  • Python version
    • currently: sys.version_info
  • Interpreter version
    • currently: sys.implementation
  • Extension suffixes
    • definition: See PEP 3149
      • consideration: PEP 3149 only defines the names for POSIX
      • design: The API should identify the different extensions types (interpreter, stable abi, none)
    • currently: importlib.machinery.EXTENSION_SUFFIXES, sysconfig.get_config_var('EXT_SUFFIX'), sysconfig.get_config_var('SHLIB_SUFFIX')
  • Is a shared libpython available? What's its name? Location?
    • definition: Yes if built with --enable-shared
    • currently:
      • (available?) bool(sysconfig.get_config_var('LDLIBRARY'))
      • (name?) sysconfig.get_config_var('LDLIBRARY')
      • (location?) sysconfig.get_config_var('LIBDIR')
  • Is a static libpython available? What's its name? Location?
    • definition: Yes unless built with --without-static-libpython
    • currently:
      • (available?) bool(sysconfig.get_config_var('LIBRARY'))
      • (name?) sysconfig.get_config_var('LIBRARY')
      • (location?) sysconfig.get_config_var('LIBDIR')
  • Should extensions link against libpython?
  • Is it a debug build?
    • definition: Yes if built with --with-pydebug
    • currently: bool(sysconfig.get_config_var('Py_DEBUG'))
  • C flags needed when using the C API
    • definition:
      • -fwrapv (until Enable -fstrict-overflow #96821)
        • Currently, we have unsafe code, and for a lack of a better option we assume it made into C macros, so extensions that use the C API should use -fwrapv.
  • what else? please comment...
"definition" sections list the answer, if a question, or the value(s) of the item. "currently" sections list the current way of fetching the information.

This is list is a work in progress. Currently, we need to gather all the information that is required to build extensions. If you see anything that's missing, please comment!

Previous discussion

https://discuss.python.org/t/building-extensions-modules-in-a-post-distutils-world/23938
https://discuss.python.org/t/what-information-is-useful-to-know-statically-about-an-interpreter/25563
https://gregoryszorc.com/docs/python-build-standalone/20230116/distributions.html

New sysconfig API meta-issue: GH-103480

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions