{"id":24162,"url":"https://patchwork.libcamera.org/api/1.1/patches/24162/?format=json","web_url":"https://patchwork.libcamera.org/patch/24162/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20250819012402.8395-4-laurent.pinchart@ideasonboard.com>","date":"2025-08-19T01:24:01","name":"[v3,3/3] py: libcamera: Always use install path from meson python module","commit_ref":"d54e5537ca0909339bb6950f3a565c9077406a3c","pull_url":null,"state":"accepted","archived":false,"hash":"a7909cec3b3cd4ab845ac9962e9dbd6861915026","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/24162/mbox/","series":[{"id":5393,"url":"https://patchwork.libcamera.org/api/1.1/series/5393/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5393","date":"2025-08-19T01:23:58","name":"py: Improve native and cross-compilation of Python bindings","version":3,"mbox":"https://patchwork.libcamera.org/series/5393/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/24162/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/24162/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 0022DBDCC1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 19 Aug 2025 01:24:35 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8DBDE6926B;\n\tTue, 19 Aug 2025 03:24:35 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CE38D69259\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 Aug 2025 03:24:28 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 364D9446;\n\tTue, 19 Aug 2025 03:23:31 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Spy0n/ut\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1755566611;\n\tbh=mM1MlgwoX48G/vAdbqdW17U+FLxSBc8pb2/LFb09Ua0=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=Spy0n/utVQrlG5kN8MsWfTs33RCbdgw38hlYEGTZI1d5r7kdh/r450CMYb04PrnVG\n\tF+ePec2649iu4OsjqSNy9TLZBwDBKyQOZmabLBkQVwb7Pe9wk9mp5Tg5+IQVSauq1r\n\t8YZNsE9uI7XmcymKqNM2bwgHJ3d/rUZKwPM0JvB0=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"William Vinnicombe <william.vinnicombe@raspberrypi.com>,\n\tTomi Valkeinen <tomi.valkeinen@ideasonboard.com>","Subject":"[PATCH v3 3/3] py: libcamera: Always use install path from meson\n\tpython module","Date":"Tue, 19 Aug 2025 04:24:01 +0300","Message-ID":"<20250819012402.8395-4-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.49.1","In-Reply-To":"<20250819012402.8395-1-laurent.pinchart@ideasonboard.com>","References":"<20250819012402.8395-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"libcamera uses the meson python module to handle native compilation of\nPython extension modules, and uses the shared_module() function when\ncross-compiling due to an issue in the python module. The difference\nbetween native and cross compilation also extends to the installation\npath: native compilation lets the python module handle the paths, while\ncross compilation constructs a path manually using a heuristic based on\nthe Python version and hardcoded components.\n\nThis manually-constructed installation path is problematic for cross\ncompilation for the same reason it caused issue when used for native\ncompilation: it is not guaranteed to be right, and it can't be\noverridden by users.\n\nSwitch to obtaining the installation path from the meson python module\nfor cross-compilation as well. This also prepares for usage of\npy.extension_module() once the file suffix issue will be fixed in meson.\n\nOn Debian 13, this change replaces the incorrect path\n/usr/local/lib/python3.12/site-packages/libcamera with the still (but\ndifferently) incorrect /usr/local/lib/python3/dist-packages/libcamera.\nFuture fixes in meson to address this issue will make the path correct\nby default.\n\nWhen the path calculated by the python module is not correct, it can now\nbe overridden by the user through the meson python.platlibdir\nconfiguration variable.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/py/libcamera/meson.build | 12 +++++-------\n 1 file changed, 5 insertions(+), 7 deletions(-)","diff":"diff --git a/src/py/libcamera/meson.build b/src/py/libcamera/meson.build\nindex d5433fbc1e3a..b0bd291fa9d6 100644\n--- a/src/py/libcamera/meson.build\n+++ b/src/py/libcamera/meson.build\n@@ -62,7 +62,7 @@ if meson.is_cross_build()\n     # module. There's work in progress to fix this, based on PEP 739\n     # (https://github.com/mesonbuild/meson/pull/14657). While waiting for this\n     # to become available, work around the issue by using shared_module().\n-    destdir = get_option('libdir') / ('python' + py3.language_version()) / 'site-packages' / 'libcamera'\n+    destdir = py3.get_install_dir(subdir : 'libcamera', pure : false)\n \n     pycamera = shared_module('_libcamera',\n                              pycamera_sources,\n@@ -72,9 +72,6 @@ if meson.is_cross_build()\n                              name_prefix : '',\n                              dependencies : pycamera_deps,\n                              cpp_args : pycamera_args)\n-    install_data(['__init__.py'],\n-                 install_dir : destdir,\n-                 install_tag : 'python-runtime')\n else\n     pycamera = py3.extension_module('_libcamera',\n                                     pycamera_sources,\n@@ -82,11 +79,12 @@ else\n                                     subdir : 'libcamera',\n                                     dependencies : pycamera_deps,\n                                     cpp_args : pycamera_args)\n-    py3.install_sources(['__init__.py'],\n-                        subdir : 'libcamera',\n-                        pure : false)\n endif\n \n+py3.install_sources(['__init__.py'],\n+                    subdir : 'libcamera',\n+                    pure : false)\n+\n # Create symlinks from the build dir to the source dir so that we can use the\n # Python module directly from the build dir.\n \n","prefixes":["v3","3/3"]}