From patchwork Tue Aug 19 01:24:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 24162 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 0022DBDCC1 for ; Tue, 19 Aug 2025 01:24:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8DBDE6926B; Tue, 19 Aug 2025 03:24:35 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Spy0n/ut"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CE38D69259 for ; Tue, 19 Aug 2025 03:24:28 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 364D9446; Tue, 19 Aug 2025 03:23:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1755566611; bh=mM1MlgwoX48G/vAdbqdW17U+FLxSBc8pb2/LFb09Ua0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Spy0n/utVQrlG5kN8MsWfTs33RCbdgw38hlYEGTZI1d5r7kdh/r450CMYb04PrnVG F+ePec2649iu4OsjqSNy9TLZBwDBKyQOZmabLBkQVwb7Pe9wk9mp5Tg5+IQVSauq1r 8YZNsE9uI7XmcymKqNM2bwgHJ3d/rUZKwPM0JvB0= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Cc: William Vinnicombe , Tomi Valkeinen Subject: [PATCH v3 3/3] py: libcamera: Always use install path from meson python 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 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" libcamera uses the meson python module to handle native compilation of Python extension modules, and uses the shared_module() function when cross-compiling due to an issue in the python module. The difference between native and cross compilation also extends to the installation path: native compilation lets the python module handle the paths, while cross compilation constructs a path manually using a heuristic based on the Python version and hardcoded components. This manually-constructed installation path is problematic for cross compilation for the same reason it caused issue when used for native compilation: it is not guaranteed to be right, and it can't be overridden by users. Switch to obtaining the installation path from the meson python module for cross-compilation as well. This also prepares for usage of py.extension_module() once the file suffix issue will be fixed in meson. On Debian 13, this change replaces the incorrect path /usr/local/lib/python3.12/site-packages/libcamera with the still (but differently) incorrect /usr/local/lib/python3/dist-packages/libcamera. Future fixes in meson to address this issue will make the path correct by default. When the path calculated by the python module is not correct, it can now be overridden by the user through the meson python.platlibdir configuration variable. Signed-off-by: Laurent Pinchart --- src/py/libcamera/meson.build | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/py/libcamera/meson.build b/src/py/libcamera/meson.build index d5433fbc1e3a..b0bd291fa9d6 100644 --- a/src/py/libcamera/meson.build +++ b/src/py/libcamera/meson.build @@ -62,7 +62,7 @@ if meson.is_cross_build() # module. There's work in progress to fix this, based on PEP 739 # (https://github.com/mesonbuild/meson/pull/14657). While waiting for this # to become available, work around the issue by using shared_module(). - destdir = get_option('libdir') / ('python' + py3.language_version()) / 'site-packages' / 'libcamera' + destdir = py3.get_install_dir(subdir : 'libcamera', pure : false) pycamera = shared_module('_libcamera', pycamera_sources, @@ -72,9 +72,6 @@ if meson.is_cross_build() name_prefix : '', dependencies : pycamera_deps, cpp_args : pycamera_args) - install_data(['__init__.py'], - install_dir : destdir, - install_tag : 'python-runtime') else pycamera = py3.extension_module('_libcamera', pycamera_sources, @@ -82,11 +79,12 @@ else subdir : 'libcamera', dependencies : pycamera_deps, cpp_args : pycamera_args) - py3.install_sources(['__init__.py'], - subdir : 'libcamera', - pure : false) endif +py3.install_sources(['__init__.py'], + subdir : 'libcamera', + pure : false) + # Create symlinks from the build dir to the source dir so that we can use the # Python module directly from the build dir.