GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-88267: Avoid exporting functions when a static build is used by lakor64 · Pull Request #99888 · python/cpython

Conversation

@lakor64

@lakor64 lakor64 commented Nov 30, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

In a Python core static build scenario (for example: embedding in Windows), MSVC would export the Python symbols for such application as well.
This commit fixes this behavour allowing the application to not export python modules and remove the automatically generated lib file, wichi shouldn't be generated for an executable.

Modules such as _socket.pyd would be disabled in a static build as the linked environment would differ, therefore I don't think there is any use for having an application specifically export modules.

In case where such behavour would be required, I would suggest adding an extra macro to disable such exports (such as Py_NO_EXPORTS).

This behavour has been tested on Windows MSVC2022, on Linux I don't think GCC would automatically export such functions but I'm not an expert on that topic.

(Fixes #88267)

NOTE: I am aware that pythoncore currently doesn't build properly in static, I used vcpkg's https://github.com/microsoft/vcpkg/blob/master/ports/python3/0002-static-library.patch (updated for Py 3.12) along with some changes to PC/dl_nt.c to allow the python interpreter to properly run, I could send a PR for this changes in case.

  • Issue: Generation of an executable's library file when python is built is static #88267

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@lakor64
pythongh-88267: Avoid exporting functions when a static build is used…
9ca49be
… (Windows-only)
@bedevere-bot bedevere-bot mentioned this pull request Nov 30, 2022
Generation of an executable's library file when python is built is static #88267
Closed
@bedevere-bot bedevere-bot added the awaiting review label Nov 30, 2022
@bedevere-bot

bedevere-bot commented Nov 30, 2022

Copy link
Copy Markdown

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ghost

ghost commented Nov 30, 2022 •
edited by ghost
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.
CLA signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kumaraditya303
kumaraditya303 requested a review from a team December 8, 2022 08:50
@zooba

zooba commented Dec 8, 2022

Copy link
Copy Markdown
Member

The change is fine, I think it does deserve a NEWS entry (under Build) though.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@blurb-it
📜🤖 Added by blurb_it.
b68b3fa
@netlify

netlify Bot commented Dec 8, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

✅ Deploy Preview for python-cpython-preview ready!

Name Link
🔨 Latest commit b68b3fa
🔍 Latest deploy log https://app.netlify.com/sites/python-cpython-preview/deploys/6391ee0a03bce400086c5748
😎 Deploy Preview https://deploy-preview-99888--python-cpython-preview.netlify.app/whatsnew/changelog
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lakor64

lakor64 commented Dec 8, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

The change is fine, I think it does deserve a NEWS entry (under Build) though.

Thank you for letting me know this (as it's my first time contributing in cpython I had no idea if this change required an entry) I've added an entry now via blurb. If I have to rebase the changes to master / modify the NEWS let me know.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

zooba
zooba approved these changes Dec 8, 2022
View reviewed changes

@zooba zooba left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Approved. I won't be around to merge today, but someone else can.

If there's a desire to backport, this should be safe enough. But it might make pre-3.12 builds a bit less predictable compared to knowing that you need to patch yourself.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting review labels Dec 8, 2022
@zooba
zooba merged commit 3c53554 into python:main Dec 9, 2022
@bedevere-bot bedevere-bot removed the awaiting merge label Dec 9, 2022
@encukou encukou mentioned this pull request Nov 18, 2025
gh-141671: PyMODINIT_FUNC: apply __declspec(dllexport) on Windows #141672
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@zooba zooba zooba approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Generation of an executable's library file when python is built is static

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@lakor64 @bedevere-bot @zooba
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.