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

gh-141671: PyMODINIT_FUNC: apply__declspec(dllexport) on Windows#141672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
encukou merged 11 commits intopython:mainfromencukou:pymodexport-always-export
Jan 7, 2026

Conversation

@encukou
Copy link
Member

@encukouencukou commentedNov 17, 2025
edited by bedevere-appbot
Loading

@encukou
Copy link
MemberAuthor

encukou commentedNov 17, 2025
edited
Loading

cc@jaraco /@pfmoore: what are your thoughts on removing/EXPORT from setuptools/distutils on Python 3.15+?


#if defined(_WIN32) || defined(__CYGWIN__)
#if defined(Py_ENABLE_SHARED)
#if!defined(Py_BUILD_CORE) ||defined(Py_ENABLE_SHARED)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'm not 100% sure about this... don't we need it for our own exports?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Only forPy_ENABLE_SHARED -- see#99888 that added the#else.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Ah, I see we do these checks again everywhere else we use the macros. No problem them.

@pfmoore
Copy link
Member

TBH, I have no view. My knowledge of C is very out of date, so I wouldn't trust anything I might say anyway...

@da-woods
Copy link
Contributor

da-woods commentedNov 18, 2025
edited
Loading

The/EXPORT from setuptools has definitely caused Cython an amount of pain before (although some of that was self-inflicted....). It'd be nice not to have to definePyInit_ just to to make the name exist. Although I suspect we can't really avoid it in a realistic timeline.

(Edit: admittedly we also aren't the people that it's designed to help either)

@encukou
Copy link
MemberAuthor

Here's a version that removes some redundant defines (setting things to defaults).

Copy link
Member

@vstinnervstinner left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM. This change mostly moves code around, and just add__declspec(dllexport) on Windows.


#define PyMODINIT_FUNC _PyINIT_FUNC_DECLSPEC PyObject*
#define PyMODEXPORT_FUNC _PyINIT_FUNC_DECLSPEC PyModuleDef_Slot*
#ifndef PyMODINIT_FUNC
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Supporting an already defined PyMODINIT_FUNC/PyMODEXPORT_FUNC is a new feature. Is it really worth it? I'm not against it, just curious.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It's an escape hatch: if there's an unexpected problem with this PR, this can allow people to hotfix it without patching or waiting for a new release.

@encukouencukou added the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelDec 19, 2025
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@encukou for commit5091b79 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F141672%2Fmerge

If you want to schedule another build, you need to add the🔨 test-with-buildbots label again.

@bedevere-botbedevere-bot removed the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelDec 19, 2025
#if defined(Py_BUILD_CORE)
#define _PyINIT_EXPORTED_SYMBOL Py_EXPORTED_SYMBOL
#else
#define _PyINIT_EXPORTED_SYMBOL __declspec(dllexport)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think a better option instead is to definePy_EXPORTED_SYMBOL here and then use that.

Also I feel like an escape hatch likePy_EMBED_MODULE where it basically usesPy_LOCAL_SYMBOL instead could be an option as well for when one does not want the module init function exported due to intending to usePyImport_AppendInitTab within the exe that they directly build the module into.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I don't want to change the meaning ofPy_EXPORTED_SYMBOL.

For the inittab, you can avoidPyMODINIT_FUNC/PyMODEXPORT_FUNC, and just use a normal declaration.

@encukouencukou merged commit8565ddd intopython:mainJan 7, 2026
46 checks passed
@encukouencukou deleted the pymodexport-always-export branchJanuary 7, 2026 12:09
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@zoobazoobazooba left review comments

@vstinnervstinnervstinner approved these changes

+1 more reviewer

@AraHaanAraHaanAraHaan left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

7 participants

@encukou@pfmoore@da-woods@bedevere-bot@vstinner@zooba@AraHaan

[8]ページ先頭

©2009-2026 Movatter.jp