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

bpo-21536: C extensions are no longer linked to libpython #12946

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.

Sign up for GitHub

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

Already on GitHub? Sign in to your account

Merged
vstinner merged 1 commit into python:master from vstinner:omit_libpython
Apr 25, 2019

Uh oh!

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

Merged

bpo-21536: C extensions are no longer linked to libpython #12946

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1 commit
Select commit
14e4843
bpo-21536: C extensions are no longer linked to libpython
vstinner Apr 24, 2019
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

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

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

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

Diff view
Diff view

There are no files selected for viewing

4 changes: 4 additions & 0 deletions 4 Doc/distutils/apiref.rst
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ the full reference.
| | simply skip the extension. | |
+------------------------+--------------------------------+---------------------------+

.. versionchanged:: 3.8

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


.. class:: Distribution

Expand Down
11 changes: 7 additions & 4 deletions 11 Doc/whatsnew/3.8.rst
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -851,16 +851,19 @@ Changes in the Python API
Changes in the C API
--------------------

* On Unix, C extensions are no longer linked to libpython. 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``.

* Use of ``#`` variants of formats in parsing or building value (e.g.
:c:func:`PyArg_ParseTuple`, :c:func:`Py_BuildValue`, :c:func:`PyObject_CallFunction`,
etc.) without ``PY_SSIZE_T_CLEAN`` defined raises ``DeprecationWarning`` now.
It will be removed in 3.10 or 4.0. Read :ref:`arg-parsing` for detail.
(Contributed by Inada Naoki in :issue:`36381`.)


Changes in the C API
--------------------------

* Instances of heap-allocated types (such as those created with
:c:func:`PyType_FromSpec`) hold a reference to their type object.
Increasing the reference count of these type objects has been moved from
Expand Down
19 changes: 2 additions & 17 deletions 19 Lib/distutils/command/build_ext.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -714,20 +714,5 @@ def get_libraries(self, ext):
# don't extend ext.libraries, it may be shared with other
# extensions, it is a reference to the original list
return ext.libraries + [pythonlib]
else:
return ext.libraries
elif sys.platform == 'darwin':
# Don't use the default code below
return ext.libraries
elif sys.platform[:3] == 'aix':
# Don't use the default code below
return ext.libraries
else:
from distutils import sysconfig
if sysconfig.get_config_var('Py_ENABLE_SHARED'):
pythonlib = 'python{}.{}{}'.format(
sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff,
sysconfig.get_config_var('ABIFLAGS'))
return ext.libraries + [pythonlib]
else:
return ext.libraries

return ext.libraries
2 changes: 1 addition & 1 deletion 2 Makefile.pre.in
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,7 @@ libinstall: build_all $(srcdir)/Modules/xxmodule.c
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
$(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt

python-config: $(srcdir)/Misc/python-config.in Misc/python-config.sh
python-config: $(srcdir)/Misc/python-config.in $(srcdir)/Misc/python-config.sh
@ # Substitution happens here, as the completely-expanded BINDIR
@ # is not available in configure
sed -e "s,@EXENAME@,$(BINDIR)/python$(LDVERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config.py
Expand Down
12 changes: 12 additions & 0 deletions 12 Misc/NEWS.d/next/Build/2019-04-25-01-51-52.bpo-21536.ACQkiC.rst
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
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.
4 changes: 1 addition & 3 deletions 4 Misc/python-config.in
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ for opt in opt_flags:
print(' '.join(flags))

elif opt in ('--libs', '--ldflags'):
libs = ['-lpython' + pyver + sys.abiflags]
libs += getvar('LIBS').split()
libs += getvar('SYSLIBS').split()
libs = getvar('LIBS').split() + getvar('SYSLIBS').split()
# add the prefix/lib/pythonX.Y/config dir, but only if there is no
# shared library in prefix/lib/.
if opt == '--ldflags':
Expand Down
2 changes: 1 addition & 1 deletion 2 Misc/python-config.sh.in
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ LIBM="@LIBM@"
LIBC="@LIBC@"
SYSLIBS="$LIBM $LIBC"
ABIFLAGS="@ABIFLAGS@"
LIBS="-lpython${VERSION}${ABIFLAGS} @LIBS@ $SYSLIBS"
LIBS="@LIBS@ $SYSLIBS"
BASECFLAGS="@BASECFLAGS@"
LDLIBRARY="@LDLIBRARY@"
OPT="@OPT@"
Expand Down
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 01402520 — 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.