All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Hilliard <james.hilliard1@gmail.com>
To: buildroot@buildroot.org
Cc: Eric Le Bihan <eric.le.bihan.dev@free.fr>,
	Xukai Wang <kingxukai@zohomail.com>,
	Julien Olivain <ju.o@free.fr>,
	Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>,
	Guillaume William Brs <guillaume.bressaix@gmail.com>,
	James Hilliard <james.hilliard1@gmail.com>,
	Woodrow Douglass <wdouglass@carnegierobotics.com>,
	Jagan Teki <jagan@amarulasolutions.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Romain Naour <romain.naour@gmail.com>,
	Fabrice Fontaine <fontaine.fabrice@gmail.com>
Subject: [Buildroot] [PATCH 3/5] package/pkg-python: add meson setup type
Date: Mon,  5 Oct 2026 16:38:09 -0600	[thread overview]
Message-ID: <20261005223811.2094796-3-james.hilliard1@gmail.com> (raw)
In-Reply-To: <20261005223811.2094796-1-james.hilliard1@gmail.com>

Use the Meson infrastructure's setup options, compiler flag defaults
and cross-file generator when building Python wheels with meson-python.
Install the resulting wheels through the existing Python infrastructure.

Pass package CONF_OPTS as individual setup-args settings while
preserving quoted and empty values. Retain the Meson build directory
for incremental builds and diagnostics.

Document the new setup type.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
 docs/manual/adding-packages-python.adoc | 31 +++++++++++---
 package/pkg-python.mk                   | 54 ++++++++++++++++++++++++-
 2 files changed, 77 insertions(+), 8 deletions(-)

diff --git a/docs/manual/adding-packages-python.adoc b/docs/manual/adding-packages-python.adoc
index d6bae299a0..2dc773545c 100644
--- a/docs/manual/adding-packages-python.adoc
+++ b/docs/manual/adding-packages-python.adoc
@@ -4,7 +4,7 @@
 === Infrastructure for Python packages
 
 This infrastructure applies to Python packages that use the standard
-Python setuptools, pep517, flit or maturin mechanisms as their build
+Python setuptools, pep517, flit, maturin or meson mechanisms as their build
 system, generally recognizable by the usage of a +setup.py+ script or
 +pyproject.toml+ file.
 
@@ -51,9 +51,9 @@ On line 13, we declare our dependencies, so that they are built
 before the build process of our package starts.
 
 On line 14, we declare the specific Python build system being used. In
-this case the +setuptools+ Python build system is used. The seven
+this case the +setuptools+ Python build system is used. The eight
 supported ones are +flit+, +hatch+, +pep517+, +poetry+, +setuptools+,
-+setuptools-rust+ and +maturin+.
++setuptools-rust+, +maturin+ and +meson+.
 
 Finally, on line 16, we invoke the +python-package+ macro that
 generates all the Makefile rules that actually allow the package to be
@@ -96,14 +96,16 @@ Note that:
 One variable specific to the Python infrastructure is mandatory:
 
 * +PYTHON_FOO_SETUP_TYPE+, to define which Python build system is used
-  by the package. The seven supported values are +flit+, +hatch+,
-  +pep517+, +poetry+, +setuptools+, +setuptools-rust+ and +maturin+.
+  by the package. The eight supported values are +flit+, +hatch+,
+  +pep517+, +poetry+, +setuptools+, +setuptools-rust+, +maturin+
+  and +meson+.
   If you don't know which one is used in your package, look at the
   +setup.py+ or +pyproject.toml+ file in your package source code,
   and see whether it imports things from the +flit+ module or the
   +setuptools+ module. If the package is using a +pyproject.toml+
   file without any build-system requires and with a local in-tree
-  backend-path one should use +pep517+.
+  backend-path one should use +pep517+. Packages using the +mesonpy+
+  build backend should use +meson+.
 
 A few additional variables, specific to the Python infrastructure, can
 optionally be defined, depending on the package's needs. Many of them
@@ -132,6 +134,23 @@ therefore only use a few of them, or none.
   build backend use the +--config-setting=+ (+-C+) flag of the +build+
   module.
 
+* +PYTHON_FOO_CONF_OPTS+, for +meson+ packages, to specify
+  additional options to pass to +meson setup+. These options follow the
+  default options shared with the xref:meson-package-reference[Meson infrastructure].
+  Quote arguments containing spaces as for +FOO_CONF_OPTS+ in that
+  infrastructure. The host variant uses +HOST_PYTHON_FOO_CONF_OPTS+.
+
+* +PYTHON_FOO_CFLAGS+, +PYTHON_FOO_CXXFLAGS+, +PYTHON_FOO_FCFLAGS+ and
+  +PYTHON_FOO_LDFLAGS+, for +meson+ target packages, to override
+  the compiler and linker flags in the generated Meson cross file.
+  They default to +TARGET_CFLAGS+, +TARGET_CXXFLAGS+, +TARGET_FCFLAGS+
+  and +TARGET_LDFLAGS+, respectively.
+
+* +PYTHON_FOO_MESON_EXTRA_BINARIES+ and
+  +PYTHON_FOO_MESON_EXTRA_PROPERTIES+, for +meson+ target
+  packages, to add entries to the Meson cross file. They have the same
+  format as the corresponding variables in the Meson infrastructure.
+
 * +PYTHON_FOO_INSTALL_TARGET_OPTS+, +PYTHON_FOO_INSTALL_STAGING_OPTS+,
   +HOST_PYTHON_FOO_INSTALL_OPTS+ to specify additional options to pass
   to the Python +setup.py+ script (for setuptools packages) or
diff --git a/package/pkg-python.mk b/package/pkg-python.mk
index 32ace4aac1..f040f53bdb 100644
--- a/package/pkg-python.mk
+++ b/package/pkg-python.mk
@@ -285,6 +285,27 @@ HOST_PKG_PYTHON_POETRY_BUILD_CMD = \
 HOST_PKG_PYTHON_POETRY_INSTALL_CMD = \
 	$(HOST_PKG_PYTHON_PEP517_INSTALL_CMD)
 
+# Target meson packages
+PKG_PYTHON_MESON_ENV = \
+	$(PKG_PYTHON_PEP517_ENV)
+
+PKG_PYTHON_MESON_INSTALL_TARGET_CMD = \
+	$(PKG_PYTHON_PEP517_INSTALL_TARGET_CMD)
+
+PKG_PYTHON_MESON_INSTALL_STAGING_CMD = \
+	$(PKG_PYTHON_PEP517_INSTALL_STAGING_CMD)
+
+PKG_PYTHON_MESON_DEPENDENCIES = \
+	$(PKG_PYTHON_PEP517_DEPENDENCIES) \
+	host-python-meson-python
+
+# Host meson packages
+HOST_PKG_PYTHON_MESON_ENV = \
+	$(HOST_PKG_PYTHON_PEP517_ENV)
+
+HOST_PKG_PYTHON_MESON_INSTALL_CMD = \
+	$(HOST_PKG_PYTHON_PEP517_INSTALL_CMD)
+
 ################################################################################
 # inner-python-package -- defines how the configuration, compilation
 # and installation of a Python package should be done, implements a
@@ -311,8 +332,8 @@ endif
 
 $(2)_SETUP_TYPE_UPPER = $$(call UPPERCASE,$$($(2)_SETUP_TYPE))
 
-ifneq ($$(filter-out setuptools setuptools-rust pep517 flit flit-bootstrap hatch maturin poetry,$$($(2)_SETUP_TYPE)),)
-$$(error "Invalid $(2)_SETUP_TYPE. Valid options are 'maturin', 'setuptools', 'setuptools-rust', 'pep517', 'flit', 'hatch' or 'poetry'.")
+ifneq ($$(filter-out setuptools setuptools-rust pep517 flit flit-bootstrap hatch maturin poetry meson,$$($(2)_SETUP_TYPE)),)
+$$(error "Invalid $(2)_SETUP_TYPE. Valid options are 'maturin', 'setuptools', 'setuptools-rust', 'pep517', 'flit', 'hatch', 'poetry' or 'meson'.")
 endif
 ifeq ($(4)-$$($(2)_SETUP_TYPE),target-flit-bootstrap)
 $$(error flit-bootstrap setup type only supported for host packages)
@@ -374,6 +395,35 @@ $(2)_DOWNLOAD_POST_PROCESS = cargo
 $(2)_DOWNLOAD_DEPENDENCIES = host-rustc
 endif # SETUP_TYPE
 
+ifeq ($$($(2)_SETUP_TYPE),meson)
+ifeq ($(4),target)
+$(call PKG_MESON_SET_TARGET_FLAGS,$(2))
+
+ifndef $(2)_CONFIGURE_CMDS
+define $(2)_CONFIGURE_CMDS
+	$$(PKG_MESON_GENERATE_CROSS_FILE)
+endef
+endif
+endif
+
+ifndef $(2)_BUILD_CMDS
+define $(2)_BUILD_CMDS
+	(cd $$($$(PKG)_BUILDDIR)/; \
+		set --; \
+		for arg in $$(PKG_MESON_$(call UPPERCASE,$(4))_OPTS) $$($$(PKG)_CONF_OPTS); do \
+			set -- "$$$$@" "-Csetup-args=$$$$arg"; \
+		done; \
+		$$($(if $(filter host,$(4)),HOST_)PKG_PYTHON_MESON_ENV) \
+		$$($$(PKG)_ENV) \
+		$$(HOST_DIR)/bin/python3 \
+		$$($(if $(filter host,$(4)),HOST_)PKG_PYTHON_PEP517_BUILD_CMD) \
+		-Cbuild-dir=$$($$(PKG)_SRCDIR)/buildroot-build \
+		$$(addprefix -Ccompile-args=,$$(NINJA_OPTS)) \
+		"$$$$@" $$($$(PKG)_BUILD_OPTS))
+endef
+endif
+endif
+
 ifeq ($(4),target)
 #
 # Build step. Only define it if not already defined by the package .mk
-- 
2.53.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  parent reply	other threads:[~2026-10-05 22:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-05 22:38 [Buildroot] [PATCH 1/5] package/pkg-meson: share Meson setup options James Hilliard
2026-10-05 22:38 ` [Buildroot] [PATCH 2/5] package/pkg-meson: share cross-file generation James Hilliard
2026-10-05 22:38 ` James Hilliard [this message]
2026-10-05 22:38 ` [Buildroot] [PATCH 4/5] package/python-numpy: bump to version 2.5.3 James Hilliard
2026-10-05 22:38 ` [Buildroot] [PATCH 5/5] package/python-scipy: bump to version 1.18.1 James Hilliard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261005223811.2094796-3-james.hilliard1@gmail.com \
    --to=james.hilliard1@gmail.com \
    --cc=buildroot@buildroot.org \
    --cc=eric.le.bihan.dev@free.fr \
    --cc=fontaine.fabrice@gmail.com \
    --cc=guillaume.bressaix@gmail.com \
    --cc=gwenhael.goavec-merou@trabucayre.com \
    --cc=jagan@amarulasolutions.com \
    --cc=ju.o@free.fr \
    --cc=kingxukai@zohomail.com \
    --cc=romain.naour@gmail.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=wdouglass@carnegierobotics.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.