Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PyMODINIT_FUNC does not apply__declspec(dllexport) on Windows #141671

Open
Assignees
encukou
@encukou

Description

@encukou

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:

  1. __declspec(dllexport) in the source code
  2. AnEXPORTS statement in a .def file
  3. An /EXPORT specification in a LINK command
  4. 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+.

Linked PRs

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2026 Movatter.jp