Patch Detail
Show a patch.
GET /api/1.1/patches/19186/?format=api
{ "id": 19186, "url": "https://patchwork.libcamera.org/api/1.1/patches/19186/?format=api", "web_url": "https://patchwork.libcamera.org/patch/19186/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20231026125038.27985-1-william.vinnicombe@raspberrypi.com>", "date": "2023-10-26T12:50:38", "name": "[libcamera-devel,v2] py: libcamera: Improve python binding installation", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "778b312f6428b38013bc5d8001f1d1691634d48e", "submitter": { "id": 131, "url": "https://patchwork.libcamera.org/api/1.1/people/131/?format=api", "name": "William Vinnicombe", "email": "william.vinnicombe@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/19186/mbox/", "series": [ { "id": 4063, "url": "https://patchwork.libcamera.org/api/1.1/series/4063/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4063", "date": "2023-10-26T12:50:38", "name": "[libcamera-devel,v2] py: libcamera: Improve python binding installation", "version": 2, "mbox": "https://patchwork.libcamera.org/series/4063/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/19186/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/19186/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 62184BDCBD\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 26 Oct 2023 12:52:33 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DC6E66297C;\n\tThu, 26 Oct 2023 14:52:32 +0200 (CEST)", "from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com\n\t[IPv6:2a00:1450:4864:20::42a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9357E61DCC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 Oct 2023 14:52:31 +0200 (CEST)", "by mail-wr1-x42a.google.com with SMTP id\n\tffacd0b85a97d-32dff202b4bso623742f8f.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 Oct 2023 05:52:31 -0700 (PDT)", "from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tf5-20020a056000128500b0032179c4a46dsm14125678wrx.100.2023.10.26.05.52.29\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 26 Oct 2023 05:52:30 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1698324752;\n\tbh=FdTsqbbXHuq8fqSQzmbFCKXnuh9m9Fkg9W+FXfUebQ4=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=JDGGj60CYS8Wai2tDeWBMYl4iUzmiD6sFoTvpKrLeUvaAfCiVV/xnpnBYT2crB8oG\n\tp6YFnJA9nSYnE5P3XNRFVNP9IBqd3oDiDTD9jjjN0nfnSfZDwuuJJ+htixEyKYVX2r\n\t9eev+TCSfgzOJxQlmSURbma+WI3icDfwoHvXB9R9/MBd5199/SGeuYdXKOiEsobgHj\n\tfBbM6uEbYgZj47tRvxGHkcYKCXLwmrRTMlg2xOJenf1bwLv7Ov9PgHgzqtyVlcVWuP\n\tQPgL1IAYLFqZGLGLJNeXqY9x603kFXDXV0oSidDeLsKiDMAQYjQ4pvX1nKMFkTrUJQ\n\tUgblDU+zYel+g==", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1698324751; x=1698929551;\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=UIurfkBGZkCyTQeUFfkIh87rwmafCmjvJgYAehe87fc=;\n\tb=Wr7k6omSYveB8a4W/6/83j7PDsuhqtrlyRDIwAFV6JCoJTXZaD6X5OpFFx444Za9qD\n\t+e0Oicu5hqCjSKTXHDiMF5PF6asrzTx05FWOiWRPbc23+Wo4gD97QaHbecii8+yrsr1d\n\tNClKb84EnundYKdereGqXCMFqBWM77mohwnn+EVOgnkbIVjwDwTe0xiQxxYCLFAaKkmX\n\tmIu2/Y1Ju0UFUAD8Dc1q7vf6bVk5rp11+FAOp8V58kTUVTtOUUx2ivSLd6ku9HqDpTA+\n\txG3xj9r746ng2a4xaKgIz9HO7eyLJYi5sjYssg3Rx/LEks8Pjn6hfYeHPD3Ho1XgPiw9\n\tfCHg==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"Wr7k6omS\"; dkim-atps=neutral", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1698324751; x=1698929551;\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=UIurfkBGZkCyTQeUFfkIh87rwmafCmjvJgYAehe87fc=;\n\tb=Z1Hc8Z4emUHDhdCaT19vW5U09I/KqITDJ039Q7ccAfIPnEeIaWgJK3is+OV1EDGk6o\n\tEiz6yCkWftuthJKlSRtS2JLuqWF94tkaP30MHv3G5NhB+yiviLpdhcJnPdntZcMK+ZLd\n\tq/JC1lY3GgAQY6x9HA2VoBa2PBHaTe8EB591CaFRS4A2cGTppuPcCIMlZhjhcPTWloPT\n\tCC6HjeT6AjWvFyWxMDO3EqWZh754PWKUiFfRdCelYWyYyaprRvfB1bSmL17DUsiAfNQY\n\tDaVkoUUs2vmwwLrYQcVcfkt0nz7uTLgQR2+G0YwvSvg7AsQB5RYctYNSxUtw/255PJIy\n\twLOw==", "X-Gm-Message-State": "AOJu0Yxf63ppdeAuZlWPYCdc7AqWVCiGkx4QNc0659UabZZUjtrfbhOW\n\tBmkyVvSw1O/sK8qOvffeyM4IGatBo/4AzAqSu7bYTA==", "X-Google-Smtp-Source": "AGHT+IGewhnOOGlILTjwtBIDAcMbdjRegaFiWjdUSXeP7DVdS6N5Ykdt/fZjd2VI6/hidFpfx7CaAA==", "X-Received": "by 2002:a05:6000:4006:b0:32f:62d5:79f0 with SMTP id\n\tcp6-20020a056000400600b0032f62d579f0mr1439000wrb.48.1698324750558; \n\tThu, 26 Oct 2023 05:52:30 -0700 (PDT)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 26 Oct 2023 13:50:38 +0100", "Message-Id": "<20231026125038.27985-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 v2] 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. For cross-compiling, still use the previous method to\nbuild the bindings, as the host machine version of python should be\nused instead.\n\nSigned-off-by: William Vinnicombe <william.vinnicombe@raspberrypi.com>\n---\n src/py/libcamera/meson.build | 60 +++++++++++++++++++++++++++---------\n 1 file changed, 45 insertions(+), 15 deletions(-)", "diff": "diff --git a/src/py/libcamera/meson.build b/src/py/libcamera/meson.build\nindex f58c7198..128793aa 100644\n--- a/src/py/libcamera/meson.build\n+++ b/src/py/libcamera/meson.build\n@@ -1,10 +1,25 @@\n # SPDX-License-Identifier: CC0-1.0\n \n-py3_dep = dependency('python3', required : get_option('pycamera'))\n-\n-if not py3_dep.found()\n- pycamera_enabled = false\n- subdir_done()\n+if meson.is_cross_build()\n+ py3_dep = dependency('python3', required : get_option('pycamera'))\n+\n+ if not py3_dep.found()\n+ pycamera_enabled = false\n+ subdir_done()\n+ endif\n+else\n+ py = import('python').find_installation('python3', required : get_option('pycamera'))\n+\n+ if not py.found()\n+ pycamera_enabled = false\n+ subdir_done()\n+ else\n+ py3_dep = py.dependency(required : get_option('pycamera'))\n+ if not py3_dep.found()\n+ pycamera_enabled = false\n+ subdir_done()\n+ endif\n+ endif\n endif\n \n pybind11_dep = dependency('pybind11', required : get_option('pycamera'))\n@@ -78,15 +93,24 @@ 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+if meson.is_cross_build()\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+else\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+endif\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 +123,13 @@ 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+if meson.is_cross_build()\n+ install_data(['__init__.py'], install_dir : destdir)\n+else\n+ py.install_sources(['__init__.py'],\n+ subdir : 'libcamera',\n+ pure : false)\n+endif\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", "v2" ] }