Patch Detail
Show a patch.
GET /api/1.1/patches/26215/?format=api
{ "id": 26215, "url": "https://patchwork.libcamera.org/api/1.1/patches/26215/?format=api", "web_url": "https://patchwork.libcamera.org/patch/26215/", "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": "<20260220144008.211492-1-barnabas.pocze@ideasonboard.com>", "date": "2026-02-20T14:40:08", "name": "[v2] py: Fix include order", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "405436d26f190907a4affb76711de11913514c07", "submitter": { "id": 216, "url": "https://patchwork.libcamera.org/api/1.1/people/216/?format=api", "name": "Barnabás Pőcze", "email": "barnabas.pocze@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/26215/mbox/", "series": [ { "id": 5805, "url": "https://patchwork.libcamera.org/api/1.1/series/5805/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5805", "date": "2026-02-20T14:40:08", "name": "[v2] py: Fix include order", "version": 2, "mbox": "https://patchwork.libcamera.org/series/5805/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/26215/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/26215/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 24A80C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 20 Feb 2026 14:40:14 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6DBDF62262;\n\tFri, 20 Feb 2026 15:40:13 +0100 (CET)", "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 0C09F61FBF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 20 Feb 2026 15:40:12 +0100 (CET)", "from pb-laptop.local (185.221.141.206.nat.pool.zt.hu\n\t[185.221.141.206])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1B9EC502\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 20 Feb 2026 15:39:18 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"kH0Moa+z\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1771598358;\n\tbh=bbAgYSczHSVLM2HyTvIprtU+YJgXyaaROcsoYsjv34M=;\n\th=From:To:Subject:Date:From;\n\tb=kH0Moa+zUuXJa+aAbkmaWlIx8FHdnGTkkmIrV/1pIKENygqSdDI0gtNky4pWOBlZ7\n\tN6RPfHbf/FctMAkjRcYfaTCELWcDPhrKFl5cp7vLItbZqOf0Q31RmwpR82ezLkD47m\n\tWf7RoKLQ0WwI3I+y3JZie1pzIjAvBYSeZgDRsAmM=", "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[PATCH v2] py: Fix include order", "Date": "Fri, 20 Feb 2026 15:40:08 +0100", "Message-ID": "<20260220144008.211492-1-barnabas.pocze@ideasonboard.com>", "X-Mailer": "git-send-email 2.53.0", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "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": "Python.h hence the pybind header must be included first since pyconfig.h\nunconditionally overrides certain feature test macros[0]. This was mostly\nhidden by the fact that macro redefinitions with the same value do not\ntrigger compiler warnings. However, glibc 43 has changed certain defaults[1],\ncausing mismatches, leading to compiler warnings.\n\nSo change the include order so that `<pybind11/...>` headers are included\nfirst and then the local `\"py_...\"` headers, and then everything else.\n\nAdjust `.clang-format` and the documentation as well.\n\n[0]: https://docs.python.org/3/c-api/intro.html#include-files\n[1]: https://sourceware.org/git/?p=glibc.git;a=commit;h=a5cc3018f31a125f019685b239c6e5a0bf1a272b\n\nLink: https://github.com/python/cpython/issues/61322\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\nchanges in v2:\n * edit documentation\n\nv1: https://patchwork.libcamera.org/patch/26184/\n---\n .clang-format | 6 ++++++\n Documentation/coding-style.rst | 6 ++++++\n src/py/libcamera/py_camera_manager.h | 4 ++--\n src/py/libcamera/py_color_space.cpp | 6 +++---\n src/py/libcamera/py_controls_generated.cpp.in | 4 ++--\n src/py/libcamera/py_enums.cpp | 4 ++--\n src/py/libcamera/py_formats_generated.cpp.in | 4 ++--\n src/py/libcamera/py_geometry.cpp | 10 +++++-----\n src/py/libcamera/py_helpers.cpp | 8 ++++----\n src/py/libcamera/py_helpers.h | 4 ++--\n src/py/libcamera/py_main.cpp | 15 +++++++--------\n src/py/libcamera/py_main.h | 4 ++--\n src/py/libcamera/py_transform.cpp | 6 +++---\n 13 files changed, 46 insertions(+), 35 deletions(-)\n\n--\n2.53.0", "diff": "diff --git a/.clang-format b/.clang-format\nindex 7fc30f614..7dbeea784 100644\n--- a/.clang-format\n+++ b/.clang-format\n@@ -77,6 +77,12 @@ IncludeCategories:\n - Regex: '<Q([A-Za-z0-9\\-_])+>'\n CaseSensitive: true\n Priority: 9\n+ # Python.h hence pybind11 headers must be included first\n+ # https://docs.python.org/3/c-api/intro.html#include-files\n+ - Regex: '<pybind11/.*>'\n+ Priority: -9\n+ - Regex: '\"py_.*\"'\n+ Priority: -8\n # Headers in <> with an extension. (+system libraries)\n - Regex: '<([A-Za-z0-9\\-_])+\\.h>'\n Priority: 2\ndiff --git a/Documentation/coding-style.rst b/Documentation/coding-style.rst\nindex 3352b75c7..e0864b78d 100644\n--- a/Documentation/coding-style.rst\n+++ b/Documentation/coding-style.rst\n@@ -95,6 +95,12 @@ System and library headers shall be included with angle brackets. Project\n headers shall be included with angle brackets for the libcamera public API\n headers, and with double quotes for internal libcamera headers.\n\n+.. note::\n+ As an exception pybind11 headers and local ``py_*`` headers must be included first\n+ in the Python bindings due to the requirements outlined in the `Python documentation`_.\n+\n+.. _Python documentation: https://docs.python.org/3/c-api/intro.html#include-files\n+\n\n C++ Specific Rules\n ------------------\ndiff --git a/src/py/libcamera/py_camera_manager.h b/src/py/libcamera/py_camera_manager.h\nindex af69b915e..7da65172e 100644\n--- a/src/py/libcamera/py_camera_manager.h\n+++ b/src/py/libcamera/py_camera_manager.h\n@@ -5,12 +5,12 @@\n\n #pragma once\n\n+#include <pybind11/pybind11.h>\n+\n #include <libcamera/base/mutex.h>\n\n #include <libcamera/libcamera.h>\n\n-#include <pybind11/pybind11.h>\n-\n using namespace libcamera;\n\n class PyCameraManager\ndiff --git a/src/py/libcamera/py_color_space.cpp b/src/py/libcamera/py_color_space.cpp\nindex fd5a5dabe..2f4d2d891 100644\n--- a/src/py/libcamera/py_color_space.cpp\n+++ b/src/py/libcamera/py_color_space.cpp\n@@ -5,15 +5,15 @@\n * Python bindings - Color Space classes\n */\n\n-#include <libcamera/color_space.h>\n-#include <libcamera/libcamera.h>\n-\n #include <pybind11/operators.h>\n #include <pybind11/pybind11.h>\n #include <pybind11/stl.h>\n\n #include \"py_main.h\"\n\n+#include <libcamera/color_space.h>\n+#include <libcamera/libcamera.h>\n+\n namespace py = pybind11;\n\n using namespace libcamera;\ndiff --git a/src/py/libcamera/py_controls_generated.cpp.in b/src/py/libcamera/py_controls_generated.cpp.in\nindex 22a132d19..c42a477bb 100644\n--- a/src/py/libcamera/py_controls_generated.cpp.in\n+++ b/src/py/libcamera/py_controls_generated.cpp.in\n@@ -7,12 +7,12 @@\n * This file is auto-generated. Do not edit.\n */\n\n-#include <libcamera/{{header}}>\n-\n #include <pybind11/pybind11.h>\n\n #include \"py_main.h\"\n\n+#include <libcamera/{{header}}>\n+\n namespace py = pybind11;\n\n class Py{{mode|capitalize}}\ndiff --git a/src/py/libcamera/py_enums.cpp b/src/py/libcamera/py_enums.cpp\nindex 9e75ec1a9..715b63880 100644\n--- a/src/py/libcamera/py_enums.cpp\n+++ b/src/py/libcamera/py_enums.cpp\n@@ -5,12 +5,12 @@\n * Python bindings - Enumerations\n */\n\n-#include <libcamera/libcamera.h>\n-\n #include <pybind11/pybind11.h>\n\n #include \"py_main.h\"\n\n+#include <libcamera/libcamera.h>\n+\n namespace py = pybind11;\n\n using namespace libcamera;\ndiff --git a/src/py/libcamera/py_formats_generated.cpp.in b/src/py/libcamera/py_formats_generated.cpp.in\nindex c5fb90639..bd0ccdc3e 100644\n--- a/src/py/libcamera/py_formats_generated.cpp.in\n+++ b/src/py/libcamera/py_formats_generated.cpp.in\n@@ -7,10 +7,10 @@\n * This file is auto-generated. Do not edit.\n */\n\n-#include <libcamera/formats.h>\n-\n #include <pybind11/pybind11.h>\n\n+#include <libcamera/formats.h>\n+\n #include \"py_main.h\"\n\n namespace py = pybind11;\ndiff --git a/src/py/libcamera/py_geometry.cpp b/src/py/libcamera/py_geometry.cpp\nindex c7e303609..d96015f03 100644\n--- a/src/py/libcamera/py_geometry.cpp\n+++ b/src/py/libcamera/py_geometry.cpp\n@@ -5,17 +5,17 @@\n * Python bindings - Geometry classes\n */\n\n-#include <array>\n-\n-#include <libcamera/geometry.h>\n-#include <libcamera/libcamera.h>\n-\n #include <pybind11/operators.h>\n #include <pybind11/pybind11.h>\n #include <pybind11/stl.h>\n\n #include \"py_main.h\"\n\n+#include <array>\n+\n+#include <libcamera/geometry.h>\n+#include <libcamera/libcamera.h>\n+\n namespace py = pybind11;\n\n using namespace libcamera;\ndiff --git a/src/py/libcamera/py_helpers.cpp b/src/py/libcamera/py_helpers.cpp\nindex 8c55ef845..b9142225c 100644\n--- a/src/py/libcamera/py_helpers.cpp\n+++ b/src/py/libcamera/py_helpers.cpp\n@@ -3,14 +3,14 @@\n * Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n */\n\n-#include \"py_helpers.h\"\n-\n-#include <libcamera/libcamera.h>\n-\n #include <pybind11/functional.h>\n #include <pybind11/stl.h>\n #include <pybind11/stl_bind.h>\n\n+#include \"py_helpers.h\"\n+\n+#include <libcamera/libcamera.h>\n+\n namespace py = pybind11;\n\n using namespace libcamera;\ndiff --git a/src/py/libcamera/py_helpers.h b/src/py/libcamera/py_helpers.h\nindex 983969dff..989fae77b 100644\n--- a/src/py/libcamera/py_helpers.h\n+++ b/src/py/libcamera/py_helpers.h\n@@ -5,9 +5,9 @@\n\n #pragma once\n\n-#include <libcamera/libcamera.h>\n-\n #include <pybind11/pybind11.h>\n\n+#include <libcamera/libcamera.h>\n+\n pybind11::object controlValueToPy(const libcamera::ControlValue &cv);\n libcamera::ControlValue pyToControlValue(const pybind11::object &ob, libcamera::ControlType type);\ndiff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp\nindex a983ea75c..d0ef6915b 100644\n--- a/src/py/libcamera/py_main.cpp\n+++ b/src/py/libcamera/py_main.cpp\n@@ -5,6 +5,13 @@\n * Python bindings\n */\n\n+#include <pybind11/functional.h>\n+#include <pybind11/pybind11.h>\n+#include <pybind11/stl.h>\n+#include <pybind11/stl_bind.h>\n+\n+#include \"py_camera_manager.h\"\n+#include \"py_helpers.h\"\n #include \"py_main.h\"\n\n #include <limits>\n@@ -17,14 +24,6 @@\n\n #include <libcamera/libcamera.h>\n\n-#include <pybind11/functional.h>\n-#include <pybind11/pybind11.h>\n-#include <pybind11/stl.h>\n-#include <pybind11/stl_bind.h>\n-\n-#include \"py_camera_manager.h\"\n-#include \"py_helpers.h\"\n-\n namespace py = pybind11;\n\n using namespace libcamera;\ndiff --git a/src/py/libcamera/py_main.h b/src/py/libcamera/py_main.h\nindex 4d594326e..dd31c6d9a 100644\n--- a/src/py/libcamera/py_main.h\n+++ b/src/py/libcamera/py_main.h\n@@ -5,10 +5,10 @@\n\n #pragma once\n\n-#include <libcamera/base/log.h>\n-\n #include <pybind11/pybind11.h>\n\n+#include <libcamera/base/log.h>\n+\n namespace libcamera {\n\n LOG_DECLARE_CATEGORY(Python)\ndiff --git a/src/py/libcamera/py_transform.cpp b/src/py/libcamera/py_transform.cpp\nindex 768260ffc..8719b5ff5 100644\n--- a/src/py/libcamera/py_transform.cpp\n+++ b/src/py/libcamera/py_transform.cpp\n@@ -5,15 +5,15 @@\n * Python bindings - Transform class\n */\n\n-#include <libcamera/transform.h>\n-#include <libcamera/libcamera.h>\n-\n #include <pybind11/operators.h>\n #include <pybind11/pybind11.h>\n #include <pybind11/stl.h>\n\n #include \"py_main.h\"\n\n+#include <libcamera/transform.h>\n+#include <libcamera/libcamera.h>\n+\n namespace py = pybind11;\n\n using namespace libcamera;\n", "prefixes": [ "v2" ] }