@@ -515,44 +515,19 @@ for example, call :c:func:`Py_DecRef` through a pointer instead of using
515515 the same way, and not next to :file: `libpython3.so `.
516516 To choose the exact file, pass the absolute path of the versioned library
517517 to ``dlopen() `` instead.
518- * ``RTLD_GLOBAL `` makes Python's symbols available to the extension modules
519- that Python imports, which are normally not linked against a Python library.
518+ * ``RTLD_GLOBAL `` is required.
519+ Extension modules are generally not linked against a Python library,
520+ so Python can only import them if its symbols are visible globally.
520521
521- .. rubric :: Unsupported alternative : renaming the dependency after linking
522+ .. rubric :: Unsupported workaround : renaming the dependency after linking
522523
523- Loading Python at run time, as described above,
524- is the preferred way to run one binary with several Python versions,
525- and it does not need anything described below.
526-
527- The following is a packaging workaround for an existing application that
528- calls the C API directly and cannot easily be changed.
529- It is unsupported and not recommended; use it at your own risk.
530-
531- Such an application is linked as described :ref: `above <compiling >`.
532- The dependency recorded in the executable is then renamed, for example with
533- `patchelf <https://github.com/NixOS/patchelf >`__:
534-
535- .. code-block :: shell-session
536-
537- $ patchelf --replace-needed libpython3.12.so.1.0 libpython3.so myapp
524+ Some applications are instead linked against a versioned library as described
525+ :ref: `above <compiling >`, and the dependency recorded in the executable is
526+ then renamed to :file: `libpython3.so `, for example with ``patchelf ``.
538527
539528.. warning ::
540529
541- Renaming the dependency does not make the application compatible with
542- other Python versions, and it has additional limitations and caveats:
543-
544- * Renaming the dependency does not check that the application uses only
545- the Stable ABI.
546- Compile it with :c:macro: `Py_LIMITED_API ` defined, as described in
547- :ref: `abi3-compiling `.
548- * If the application refers to a Python data symbol directly, for example
549- ``&PyLong_Type ``, the linker may have used a copy relocation.
550- This reserves space for the object in the executable, using its size in
551- the Python version that the application was linked against.
552- That size is not part of the Stable ABI and can differ between versions.
553- Look for such relocations with ``readelf -rW myapp | grep COPY ``, and
554- compile the application as position-independent code (``-fPIC ``) to
555- avoid them.
556- * The dynamic loader must find :file: `libpython3.so ` in its search path
557- when the application starts.
558- Otherwise the application does not start at all.
530+ Renaming the dependency this way is unsupported.
531+ Nothing checks that such an executable only uses the Stable ABI, and it
532+ can contain copies of Python data, such as ``PyLong_Type ``, whose size
533+ differs between Python versions.
0 commit comments