{"id":19183,"url":"https://patchwork.libcamera.org/api/1.1/patches/19183/?format=json","web_url":"https://patchwork.libcamera.org/patch/19183/","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":"<20231025093649.25222-1-william.vinnicombe@raspberrypi.com>","date":"2023-10-25T09:36:49","name":"[libcamera-devel] py: libcamera: Improve python binding installation","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"c240003d7de5cd581670ccf21ade9da50fa0580f","submitter":{"id":131,"url":"https://patchwork.libcamera.org/api/1.1/people/131/?format=json","name":"William Vinnicombe","email":"william.vinnicombe@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/19183/mbox/","series":[{"id":4061,"url":"https://patchwork.libcamera.org/api/1.1/series/4061/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4061","date":"2023-10-25T09:36:49","name":"[libcamera-devel] py: libcamera: Improve python binding installation","version":1,"mbox":"https://patchwork.libcamera.org/series/4061/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/19183/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/19183/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 850A5BDCBD\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 25 Oct 2023 09:37:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BC1CE6298F;\n\tWed, 25 Oct 2023 11:37:43 +0200 (CEST)","from mail-wm1-x332.google.com (mail-wm1-x332.google.com\n\t[IPv6:2a00:1450:4864:20::332])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C999161DCB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 25 Oct 2023 11:37:41 +0200 (CEST)","by mail-wm1-x332.google.com with SMTP id\n\t5b1f17b1804b1-40838915cecso44645565e9.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 25 Oct 2023 02:37:41 -0700 (PDT)","from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tr17-20020a5d4e51000000b0032d09f7a713sm11712295wrt.18.2023.10.25.02.37.39\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 25 Oct 2023 02:37:40 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1698226663;\n\tbh=Wg0hwiLnNC4ocCGf3NTeTThJSfhTGMP+0Mig14kS8dQ=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=3osmvNg8/E/sndk1z2+vOCprt51Pacet0OFa/w9/jY3D7+BJoAE4HcosSi1DwXZXm\n\ty+fiqXmMMui0gPqzoe7RBf+aQI6vBBeAjP/Bu5uAWYEsn1124jI7RLSKAV3hBzhJ7M\n\t44v+X3rLA0W0sWfXkVwC0Yz6m63/5tVXaTdoMpnYGHLa8k6m29MGN6BFYmMwT+LV9S\n\t6TeU2cXH4s4QvnHS1KWGAJaypoNlDj/W14XWKifW/LVe8nMw2uJAJCLUVuy1bCKiMg\n\tD1PXMY9jbC9IdkWIU1fwAAxdDRektEuQXcT3c+ixZ4YKtdPhKrZi0FWLHvnmNXyE4f\n\t6dcD+H3v1PuYQ==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1698226661; x=1698831461;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:message-id:date:subject:cc\n\t:to:from:from:to:cc:subject:date:message-id:reply-to;\n\tbh=4vZ+dJG4sKt2La/skPuj1Yi3Hi7yIIhti5wJH+CS90Q=;\n\tb=ZRmBO0GjHkcFHi48qpSxma6hXavQiUaSWWrio+syxDO0CFWR6VXneV0lYWCDStYC6w\n\ttdzZRujT4swrJBY00nXy0gSCMFOSq24kEJGhPRueGHVN4zFq6X0/kkeglB7wh6Ld+EDT\n\tpNlgc2gT2j8CmCiAJdRjXVFBzW+jb0YpPiNew1c0QXGFKmI2zMXjIpkEFTEIVSFe6YuT\n\tIQxxO9ZyN31RfGxCjihU3JTYcckRVFPmx0WxRNPsa/sjrLeNUaVHjStrgGpicwvvzMbL\n\tvkm7BzgOX1tNrY+IKMBNoqJlypM/rEL1k+jfhxGAIMcvmzcW5kLLcNwGs/BjJDX+vVS2\n\t2zVw=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"ZRmBO0Gj\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1698226661; x=1698831461;\n\th=content-transfer-encoding:mime-version:message-id:date:subject:cc\n\t:to:from:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=4vZ+dJG4sKt2La/skPuj1Yi3Hi7yIIhti5wJH+CS90Q=;\n\tb=XUue2TnnHHMwI89zvwVpMEupl7SvQyRDvc2KgQqVIJDWngMRyQy8SGeAhnPTQ5qAzt\n\tca7x2TTTONRDG27Nw2GzCbRXdrgvPmyJwxCwYgImXsheqgE7Z0jBo7kpfy9xKa+58gBo\n\tXVwmwDzTqSJfaJIDTCyNKvqvRkTEk6iDFFrf3pDb/mDmEWsNCUkncUk5wfCbUZQxHewg\n\twBgbSQkm4mD4MaDc522qUyLLStGHmaWnRv7US92aE8hkZ2gopRir2XvMuFaUGTK1YeTs\n\tsXYZe3+xBinVC/DWk5NnN0mr2hBPGjOoj2myE2B/mbhcLFS2pjTMJtE6mAlimPZLw2Bw\n\tOwCQ==","X-Gm-Message-State":"AOJu0Yyead2ml3cnEBUXaDHcf695urcVTr2XQZv/Hw1wvXnIgyjmRflD\n\tIdtEg0LYJiTTO3J6bzCA3IWdRGJvAKcPMmvafTM=","X-Google-Smtp-Source":"AGHT+IH0X4hsOPC+daGO7w5R6YVZdmH7wf1YcaUEZPEoxp9+z38VLcHGVAcGhe4MRgUx6lZpWGnsqQ==","X-Received":"by 2002:a5d:67c5:0:b0:32d:8183:d130 with SMTP id\n\tn5-20020a5d67c5000000b0032d8183d130mr9600719wrw.38.1698226660751; \n\tWed, 25 Oct 2023 02:37:40 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 25 Oct 2023 10:36:49 +0100","Message-Id":"<20231025093649.25222-1-william.vinnicombe@raspberrypi.com>","X-Mailer":"git-send-email 2.39.2","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH] py: libcamera: Improve python binding\n\tinstallation","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>","From":"William Vinnicombe via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"William Vinnicombe <william.vinnicombe@raspberrypi.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The existing meson.build file installs the bindings to an architecture\nspecific libdir (eg /usr/local/lib/aarch64-linux-gnu/), which is not\npicked up by default python which only looks in the non architecture\nspecific libdir (eg /usr/local/lib/python3.11/). It also will always\nbuild using the system python, rather than building using the same\npython as meson is using. This prevents a user being able to build the\nbindings for a different version of python, without changing their\nsystem python to that version.\n\nModify the build process to use the meson Python module to build the\npython bindings targets, so it installs them to the correct directories\nfor python, and builds them for the version of python that meson is\nrunning with.\n\nSigned-off-by: William Vinnicombe <william.vinnicombe@raspberrypi.com>\n---\n src/py/libcamera/meson.build | 23 ++++++++++++-----------\n 1 file changed, 12 insertions(+), 11 deletions(-)","diff":"diff --git a/src/py/libcamera/meson.build b/src/py/libcamera/meson.build\nindex f58c7198..e9e3f915 100644\n--- a/src/py/libcamera/meson.build\n+++ b/src/py/libcamera/meson.build\n@@ -1,6 +1,8 @@\n # SPDX-License-Identifier: CC0-1.0\n \n-py3_dep = dependency('python3', required : get_option('pycamera'))\n+\n+py = import('python').find_installation('python3', required : get_option('pycamera'))\n+py3_dep = py.dependency(required : get_option('pycamera'))\n \n if not py3_dep.found()\n     pycamera_enabled = false\n@@ -78,15 +80,12 @@ pycamera_args = [\n     '-DPYBIND11_USE_SMART_HOLDER_AS_DEFAULT',\n ]\n \n-destdir = get_option('libdir') / ('python' + py3_dep.version()) / 'site-packages' / 'libcamera'\n-\n-pycamera = shared_module('_libcamera',\n-                         pycamera_sources,\n-                         install : true,\n-                         install_dir : destdir,\n-                         name_prefix : '',\n-                         dependencies : pycamera_deps,\n-                         cpp_args : pycamera_args)\n+pycamera = py.extension_module('_libcamera',\n+                               pycamera_sources,\n+                               install : true,\n+                               subdir : 'libcamera',\n+                               dependencies : pycamera_deps,\n+                               cpp_args : pycamera_args)\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@@ -99,7 +98,9 @@ run_command('ln', '-fsrT', meson.current_source_dir() / 'utils',\n             meson.current_build_dir() / 'utils',\n             check : true)\n \n-install_data(['__init__.py'], install_dir : destdir)\n+py.install_sources(['__init__.py'],\n+                   subdir : 'libcamera',\n+                   pure : false)\n \n # \\todo Generate stubs when building. See https://peps.python.org/pep-0484/#stub-files\n # Note: Depends on pybind11-stubgen. To generate pylibcamera stubs:\n","prefixes":["libcamera-devel"]}