Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34k
Description
The macro isdocumented as:
Declare an extension module initialization function. This macro:
- specifies thePyObject* return type,
- adds any special linkage declarations required by the platform, and
- for C++, declares the function as extern "C".
Specifically, the special linkage declarations should be__attribute__ ((visibility ("default"))) on GCC/clang, and__declspec(dllexport) on Windows.
However, the definition assumes we're building CPython itself, and only adds a linkage declaration withPy_ENABLE_SHARED -- that is, whenPython itself is built with a shared library.
According toMSVC docs:
There are four methods for exporting a definition, listed in recommended order of use:
__declspec(dllexport)in the source code- AnEXPORTS statement in a .def file
- An /EXPORT specification in a LINK command
- Acomment directive in the source code, of the form
#pragma comment(linker, "/export: definition ").
Setuptools, and historically distutils,does (2) -- and so does, presumably, any other build system for native extensions on Windows.
However, this breaks for modules that define thePEP-793PyModExport hook.
It would be great to switch to the preferred (1), and then tell Setuptools to avoid/EXPORT for 3.15+.