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 — bpo-21536: C extensions are no longer linked to libpython by vstinner · Pull Request #12946 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Apr 25, 2019 •
edited by bedevere-bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

On Unix, C extensions are no longer linked to libpython.

It is now possible to load a C extension built using a shared library
Python with a statically linked Python.

When Python is embedded, libpython must not be loaded with
RTLD_LOCAL, but RTDL_GLOBAL instead. Previously, using RTLD_LOCAL, it
was already not possible to load C extensions which were not linked
to libpython, like C extensions of the standard library built by the
"shared" section of Modules/Setup.

distutils, python-config and python-config.py have been modified.

https://bugs.python.org/issue21536

Sorry, something went wrong.

Uh oh!

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

All reactions
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Apr 25, 2019
@bedevere-bot bedevere-bot added the awaiting core review label Apr 25, 2019
@vstinner
vstinner requested a review from pitrou April 25, 2019 01:28
@vstinner

vstinner commented Apr 25, 2019

Copy link
Copy Markdown
Member Author

This PR allows to load a C extension built by a shared libpython with a statically linked Python: https://bugs.python.org/issue21536#msg340819

It also allows to load C extension built in release mode with a Python built in debug mode: https://bugs.python.org/issue21536#msg340821

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Apr 25, 2019

Copy link
Copy Markdown
Member Author

One potential issue: linking an application to libpython to embed Python, see discussion at https://bugs.python.org/issue21536#msg340837

All reactions

Sorry, something went wrong.

Uh oh!

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

pitrou
pitrou approved these changes Apr 25, 2019
View reviewed changes

@pitrou pitrou 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.

LGTM. Thank you!

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 core review labels Apr 25, 2019
skoslowski
skoslowski reviewed Apr 25, 2019
View reviewed changes
Comment thread Doc/whatsnew/3.8.rst Resolved

Uh oh!

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

@vstinner
bpo-21536: C extensions are no longer linked to libpython
14e4843
On Unix, C extensions are no longer linked to libpython.

It is now possible to load a C extension built using a shared library
Python with a statically linked Python.

When Python is embedded, libpython must not be loaded with
RTLD_LOCAL, but RTLD_GLOBAL instead. Previously, using RTLD_LOCAL, it
was already not possible to load C extensions which were not linked
to libpython, like C extensions of the standard library built by the
"*shared*" section of Modules/Setup.

distutils, python-config and python-config.py have been modified.
@vstinner
vstinner merged commit 8c3ecc6 into python:master Apr 25, 2019
@bedevere-bot bedevere-bot removed the awaiting merge label Apr 25, 2019
@vstinner
vstinner deleted the omit_libpython branch April 25, 2019 18:13
This was referenced May 24, 2019
bpo-21536: On Android, C extensions are linked to libpython #12989
Merged
bpo-21536: On Cygwin, C extensions must be linked with libpython #13549
Merged
@yarda yarda mentioned this pull request May 19, 2020
Please do not link with libpython Hamlib/Hamlib#253
Closed
@sanjayankur31 sanjayankur31 mentioned this pull request May 28, 2020
Python3.8+ no longer needed to link against libpython nest/nest-simulator#1630
Closed
gferon added a commit to gferon/libArcus that referenced this pull request Jun 2, 2020
@gferon
Don't link to libpython for Python >= 3.8
4ebc453
As of Python 3.8, python C extensions modules should not link to
libpython, unless they embed the interpreter in their code.

Relevant upstream PR: python/cpython#12946

Signed-off-by: Gabriel Féron <[email protected]>
@gferon gferon mentioned this pull request Jun 2, 2020
Don't link to libpython for Python >= 3.8 Ultimaker/libArcus#109
Merged
gferon added a commit to gferon/libSavitar that referenced this pull request Jun 2, 2020
@gferon
Don't link to libpython for Python >= 3.8
fcea518
As of Python 3.8, python C extensions modules should not link to
libpython, unless they embed the interpreter in their code.

Relevant upstream PR: python/cpython#12946

Signed-off-by: Gabriel Féron <[email protected]>
@gferon gferon mentioned this pull request Jun 2, 2020
Don't link to libpython for Python >= 3.8 Ultimaker/libSavitar#25
Closed
@froody

froody commented Dec 7, 2020 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

This change causes strange bugs on Mac OS X due to the two-level namespace symbol resolution for dynamic libraries. A C extension that links against libpython will resolve symbols from libpython instead of the python executable (for example, PDAL/python#75 ). I believe linking C extensions on Mac OS X with "-flat_namespace" would be a reliable fix, as it would allow the python executable symbols to take precedence over those from libpython.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Dec 7, 2020

Copy link
Copy Markdown
Member Author

Please don't comment closed PRs, but open a new issue at https://bugs.python.org/ Otherwise, your comment will simply be ignored.

All reactions

Sorry, something went wrong.

Uh oh!

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

@krsfrodaslz krsfrodaslz mentioned this pull request May 2, 2022
Manjaro (Arch) Linux modification thomasa88/pyets2_telemetry#4
Open
@pitrou pitrou mentioned this pull request Sep 2, 2022
extension built with a shared python cannot be loaded with a static python #65735
Closed
@DownerCase DownerCase mentioned this pull request Feb 26, 2024
[python] Don't link C extensions to libpython eclipse-ecal/ecal#1395
Merged
@messense messense mentioned this pull request Apr 12, 2024
python ld flags not detected... PyO3/pyo3#4068
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@pitrou pitrou pitrou approved these changes
+1 more reviewer
@skoslowski skoslowski skoslowski left review comments
Reviewers whose approvals may not affect merge requirements

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.

Uh oh!

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

6 participants

@vstinner @froody @skoslowski @pitrou @the-knights-who-say-ni @bedevere-bot
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.