@@ -11,7 +11,7 @@ msgid ""
1111msgstr ""
1212"Project-Id-Version : Python 3.15\n "
1313"Report-Msgid-Bugs-To : \n "
14- "POT-Creation-Date : 2026-11-07 18:23 +0000\n "
14+ "POT-Creation-Date : 2026-11-27 22:25 +0000\n "
1515"PO-Revision-Date : 2025-09-16 00:00+0000\n "
1616"Last-Translator : python-doc bot, 2025\n "
1717"Language-Team : Polish (https://app.transifex.com/python-doc/teams/5390/pl/)\n "
@@ -515,3 +515,203 @@ msgstr ""
515515"'-lpthread -ldl -lutil'\n"
516516">>> sysconfig.get_config_var('LINKFORSHARED')\n"
517517"'-Xlinker -export-dynamic'"
518+
519+ msgid "Linking for one or several Python versions on Linux"
520+ msgstr ""
521+
522+ msgid ""
523+ "The flags obtained from ``pythonX.Y-config --ldflags --embed`` link the "
524+ "application against one minor version of Python. If that Python was built as "
525+ "a shared library, the executable records a dependency on the versioned "
526+ "library, such as :file:`libpython3.12.so.1.0`, and expected that specific "
527+ "minor version at runtime. This is the recommended setup for most host "
528+ "(embedding) applications. Build the application for each Python version that "
529+ "it supports, or distribute it together with the Python that it was built "
530+ "with."
531+ msgstr ""
532+
533+ msgid ""
534+ "Using the :ref:`Limited API <limited-c-api>` does not change this. "
535+ "Defining :c:macro:`Py_LIMITED_API` restricts your source code to API that is "
536+ "compatible across minor versions, but the library dependency is recorded "
537+ "when linking, so the executable still requires :file:`libpython3.12.so.1.0`."
538+ msgstr ""
539+
540+ msgid ""
541+ "A binary that needs to run with several minor Python versions must use only "
542+ "the Limited API and must *also* avoid the versioned dependency."
543+ msgstr ""
544+
545+ msgid ""
546+ "Host applications that use the :ref:`Limited API <limited-c-api>` must be "
547+ "aware of the following limitations:"
548+ msgstr ""
549+
550+ msgid ""
551+ "It can only initialize Python with :c:func:`Py_Initialize` "
552+ "or :c:func:`Py_InitializeEx`, which set Python up much like "
553+ "the :program:`python` command does. They honor :envvar:`PYTHONHOME` "
554+ "and :envvar:`PYTHONPATH`, add the :data:`user site-packages directory "
555+ "<site.USER_SITE>` to :data:`sys.path`, and terminate the process if "
556+ "initialization fails. They set :data:`sys.executable` to "
557+ "the :program:`python3` program found on :envvar:`!PATH`, which can belong to "
558+ "a different Python installation than the library that was loaded. The "
559+ "functions that accept an :ref:`isolated configuration <init-isolated-"
560+ "conf>`, :c:func:`Py_InitializeFromConfig` "
561+ "and :c:func:`Py_InitializeFromInitConfig`, are not part of the Limited API."
562+ msgstr ""
563+
564+ msgid ""
565+ "The Python that gets loaded is only known at run-time. Checking that it is "
566+ "suitable is up to the application. An incompatible Python, such as a too-old "
567+ "or too-new version, is not rejected automatically."
568+ msgstr ""
569+
570+ msgid ""
571+ "The Stable ABI keeps functions available in later versions, but it does not "
572+ "guarantee identical behavior. The default configuration and the "
573+ "way :data:`sys.path` is computed can change between Python versions, and "
574+ "between installations of the same version. Test the application with every "
575+ "Python version and installation that it is meant to support. See "
576+ "also :ref:`limited-api-caveats`."
577+ msgstr ""
578+
579+ msgid ""
580+ "A Python built with :option:`--enable-shared` and without :option:`--with-"
581+ "pydebug` installs :file:`libpython3.so` next to the versioned library. When "
582+ "the dynamic loader loads this library, it also loads the versioned library "
583+ "that it was built with, and symbols looked up through :file:`libpython3.so` "
584+ "are found in the versioned library. An application can therefore "
585+ "load :file:`libpython3.so` with :manpage:`dlopen(3)` and look up each "
586+ "function that it uses with :manpage:`dlsym(3)`."
587+ msgstr ""
588+
589+ msgid ""
590+ "This only works at run time. When linking an executable, the linker does not "
591+ "use the dependencies of a library to resolve symbols, "
592+ "and :file:`libpython3.so` defines no Python symbols of its own, so linking "
593+ "with ``-lpython3`` fails with ``undefined reference`` errors."
594+ msgstr ""
595+
596+ msgid "For example, with Python 3.12 as the oldest supported version::"
597+ msgstr ""
598+
599+ msgid ""
600+ "#define Py_LIMITED_API 0x030c0000 /* Limited API 3.12 */\n"
601+ "#include <Python.h>\n"
602+ "#include <dlfcn.h>\n"
603+ "#include <stdio.h>\n"
604+ "\n"
605+ "/* The API this application uses, declared as in Python.h.\n"
606+ " Everything is reached through these pointers. */\n"
607+ "static struct {\n"
608+ " const unsigned long *Version;\n"
609+ " const char *(*GetVersion)(void);\n"
610+ " void (*InitializeEx)(int);\n"
611+ " int (*FinalizeEx)(void);\n"
612+ "} py;\n"
613+ "\n"
614+ "#define LOAD(lib, pointer, name) \\ \n"
615+ " ((*(void **)&(pointer) = dlsym(lib, name)) != NULL)\n"
616+ "\n"
617+ "int\n"
618+ "main(int argc, char *argv[])\n"
619+ "{\n"
620+ " /* For brevity, the path comes from the command line. A real\n"
621+ " application reads it from its own configuration. */\n"
622+ " if (argc != 2 || argv[1][0] != '/') {\n"
623+ " fprintf(stderr, \" usage: %s /absolute/path/to/libpython3.so\\ n\" ,\n"
624+ " argv[0]);\n"
625+ " return 2;\n"
626+ " }\n"
627+ " /* RTLD_GLOBAL is required: it lets the extension modules that\n"
628+ " Python imports find Python's symbols. */\n"
629+ " void *lib = dlopen(argv[1], RTLD_NOW | RTLD_GLOBAL);\n"
630+ " if (lib == NULL) {\n"
631+ " fprintf(stderr, \" Python is not available: %s\\ n\" , dlerror());\n"
632+ " return 1;\n"
633+ " }\n"
634+ " if (!LOAD(lib, py.Version, \" Py_Version\" )\n"
635+ " || !LOAD(lib, py.GetVersion, \" Py_GetVersion\" )\n"
636+ " || !LOAD(lib, py.InitializeEx, \" Py_InitializeEx\" )\n"
637+ " || !LOAD(lib, py.FinalizeEx, \" Py_FinalizeEx\" ))\n"
638+ " {\n"
639+ " fprintf(stderr, \" Unsupported Python: %s\\ n\" , dlerror());\n"
640+ " return 1;\n"
641+ " }\n"
642+ " if (*py.Version < Py_LIMITED_API) {\n"
643+ " fprintf(stderr, \" Python %s is older than 3.12\\ n\" , "
644+ "py.GetVersion());\n"
645+ " return 1;\n"
646+ " }\n"
647+ "\n"
648+ " py.InitializeEx(0);\n"
649+ " printf(\" Loaded Python %s\\ n\" , py.GetVersion());\n"
650+ " return py.FinalizeEx() < 0 ? 120 : 0;\n"
651+ "}"
652+ msgstr ""
653+
654+ msgid ""
655+ "Compile the program with Python's headers, but without the output of ``--"
656+ "ldflags``:"
657+ msgstr ""
658+
659+ msgid ""
660+ "$ gcc $(/opt/bin/python3.12-config --includes) -o myapp myapp.c\n"
661+ "$ ./myapp /usr/local/lib/libpython3.so\n"
662+ "Loaded Python 3.14.10 (main, Nov 5 2026, 09:47:10) [GCC 14.2.0]"
663+ msgstr ""
664+
665+ msgid ""
666+ "No Python library is passed to the linker, so the executable does not depend "
667+ "on one. You can check this with ``readelf``:"
668+ msgstr ""
669+
670+ msgid ""
671+ "$ readelf -d myapp | grep NEEDED\n"
672+ " 0x0000000000000001 (NEEDED) Shared library: [libc.so.6]"
673+ msgstr ""
674+
675+ msgid ""
676+ "For the same reason, Python functions can only be called through such "
677+ "pointers. This includes the functions that macros in :file:`Python.h` expand "
678+ "to: for example, call :c:func:`Py_DecRef` through a pointer instead of "
679+ "using :c:func:`Py_DECREF`."
680+ msgstr ""
681+
682+ msgid ""
683+ "The path passed to ``dlopen()`` selects the code that runs in your process. "
684+ "It should come from a trusted source and name a file that only trusted users "
685+ "can replace."
686+ msgstr ""
687+
688+ msgid ""
689+ "Use an absolute path. The dynamic loader looks for a name without a slash in "
690+ "its usual search path, such as :envvar:`!LD_LIBRARY_PATH` and the system "
691+ "library directories. It looks for the versioned library "
692+ "that :file:`libpython3.so` depends on in the same way, and not next "
693+ "to :file:`libpython3.so`. To choose the exact file, pass the absolute path "
694+ "of the versioned library to ``dlopen()`` instead."
695+ msgstr ""
696+
697+ msgid ""
698+ "``RTLD_GLOBAL`` is required. Extension modules are generally not linked "
699+ "against a Python library, so Python can only import them if its symbols are "
700+ "visible globally."
701+ msgstr ""
702+
703+ msgid "Unsupported workaround: renaming the dependency after linking"
704+ msgstr ""
705+
706+ msgid ""
707+ "Some applications are instead linked against a versioned library as "
708+ "described :ref:`above <compiling>`, and the dependency recorded in the "
709+ "executable is then renamed to :file:`libpython3.so`, for example with "
710+ "``patchelf``."
711+ msgstr ""
712+
713+ msgid ""
714+ "Renaming the dependency this way is unsupported. Nothing checks that such an "
715+ "executable only uses the Stable ABI, and it can contain copies of Python "
716+ "data, such as ``PyLong_Type``, whose size differs between Python versions."
717+ msgstr ""
0 commit comments