From 48fcf17f18cbfd2b12b9625b188fde4f627f42c2 Mon Sep 17 00:00:00 2001 From: "Dr. Andrew Annex" Date: Sun, 22 Jun 2025 08:41:58 -0700 Subject: [PATCH] DOC: shared-libraries: fix and clarify install location example Fixes #769 --- docs/how-to-guides/shared-libraries.rst | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/docs/how-to-guides/shared-libraries.rst b/docs/how-to-guides/shared-libraries.rst index 178620fc8..55a9b2c10 100644 --- a/docs/how-to-guides/shared-libraries.rst +++ b/docs/how-to-guides/shared-libraries.rst @@ -64,18 +64,28 @@ A shared library produced by ``library()`` or ``shared_library()`` built like th is installed to ``libdir`` by default. If the only reason the shared library exists is to be used inside the Python package being built, then it is best to modify -the install location to be within the Python package itself: +the install location, via the ``install_dir`` argument, to be within +the Python package itself: -.. code-block:: python +.. TODO update the text block below to 'meson' when +.. meson lexer is updated to fix +.. https://github.com/pygments/pygments/issues/2918 - install_path: py.get_install_dir() / 'mypkg/subdir' +.. code-block:: text + + example_lib = shared_library( + 'example', + 'examplelib.c', + install: true, + install_dir: py.get_install_dir() / 'mypkg/subdir', + ) Then an extension module in the same install directory can link against the shared library in a portable manner by using ``install_rpath``: .. code-block:: meson - py3.extension_module('_extmodule', + py.extension_module('_extmodule', '_extmodule.c', link_with: example_lib, install: true,