Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] package/pkg-python.mk: add hatch setup type
@ 2024-10-08 22:27 James Hilliard
  2024-10-23 21:01 ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 2+ messages in thread
From: James Hilliard @ 2024-10-08 22:27 UTC (permalink / raw)
  To: buildroot; +Cc: James Hilliard, Thomas Petazzoni

As we have many python packages using the hatch(hatchling) build
system we should add a setup type for it so that we don't have to
manually specify the host-python-hatchling dependency.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
 docs/manual/adding-packages-directory.adoc |  6 ++---
 docs/manual/adding-packages-python.adoc    | 14 +++++-----
 package/pkg-python.mk                      | 31 ++++++++++++++++++++--
 utils/scanpypi                             |  2 ++
 4 files changed, 41 insertions(+), 12 deletions(-)

diff --git a/docs/manual/adding-packages-directory.adoc b/docs/manual/adding-packages-directory.adoc
index 4ca11507e1..cb19f3bac9 100644
--- a/docs/manual/adding-packages-directory.adoc
+++ b/docs/manual/adding-packages-directory.adoc
@@ -429,9 +429,9 @@ different way, using different infrastructures:
    and xref:cmake-package-reference[reference].
 
 * *Makefiles for Python modules*: We have a dedicated infrastructure
-   for Python modules that use the +flit+, +pep517+, +setuptools+,
-   +setuptools-rust+ or +maturin+ mechanisms. We cover them through a
-   xref:python-package-tutorial[tutorial] and a
+   for Python modules that use the +flit+, +hatch+, +pep517+,
+   +setuptools+, +setuptools-rust+ or +maturin+ mechanisms. We cover
+   them through a xref:python-package-tutorial[tutorial] and a
    xref:python-package-reference[reference].
 
 * *Makefiles for Lua modules*: We have a dedicated infrastructure for
diff --git a/docs/manual/adding-packages-python.adoc b/docs/manual/adding-packages-python.adoc
index f33770f95c..790e2899cf 100644
--- a/docs/manual/adding-packages-python.adoc
+++ b/docs/manual/adding-packages-python.adoc
@@ -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 five
-supported ones are +flit+, +pep517+, +setuptools+, +setuptools-rust+
-and +maturin+.
+this case the +setuptools+ Python build system is used. The six
+supported ones are +flit+, +hatch+, +pep517+, +setuptools+,
++setuptools-rust+ and +maturin+.
 
 Finally, on line 16, we invoke the +python-package+ macro that
 generates all the Makefile rules that actually allow the package to be
@@ -96,10 +96,10 @@ 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 five supported values are +flit+, +pep517+ and
-  +setuptools+, +setuptools-rust+ and +maturin+. 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
+  by the package. The five supported values are +flit+, +hatch+,
+  +pep517+ and +setuptools+, +setuptools-rust+ and +maturin+. 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
diff --git a/package/pkg-python.mk b/package/pkg-python.mk
index dea4f39ca0..3c607b5277 100644
--- a/package/pkg-python.mk
+++ b/package/pkg-python.mk
@@ -200,6 +200,33 @@ HOST_PKG_PYTHON_FLIT_BOOTSTRAP_BUILD_CMD = \
 HOST_PKG_PYTHON_FLIT_BOOTSTRAP_INSTALL_CMD = \
 	$(HOST_PKG_PYTHON_PEP517_INSTALL_CMD)
 
+# Target hatch packages
+PKG_PYTHON_HATCH_ENV = \
+	$(PKG_PYTHON_PEP517_ENV)
+
+PKG_PYTHON_HATCH_BUILD_CMD = \
+	$(PKG_PYTHON_PEP517_BUILD_CMD)
+
+PKG_PYTHON_HATCH_INSTALL_TARGET_CMD = \
+	$(PKG_PYTHON_PEP517_INSTALL_TARGET_CMD)
+
+PKG_PYTHON_HATCH_INSTALL_STAGING_CMD = \
+	$(PKG_PYTHON_PEP517_INSTALL_STAGING_CMD)
+
+PKG_PYTHON_HATCH_DEPENDENCIES = \
+	$(PKG_PYTHON_PEP517_DEPENDENCIES) \
+	host-python-hatchling
+
+# Host hatch packages
+HOST_PKG_PYTHON_HATCH_ENV = \
+	$(HOST_PKG_PYTHON_PEP517_ENV)
+
+HOST_PKG_PYTHON_HATCH_BUILD_CMD = \
+	$(HOST_PKG_PYTHON_PEP517_BUILD_CMD)
+
+HOST_PKG_PYTHON_HATCH_INSTALL_CMD = \
+	$(HOST_PKG_PYTHON_PEP517_INSTALL_CMD)
+
 # Target maturin packages
 PKG_PYTHON_MATURIN_ENV = \
 	$(PKG_PYTHON_PEP517_ENV) \
@@ -257,8 +284,8 @@ endif
 
 $(2)_SETUP_TYPE_UPPER = $$(call UPPERCASE,$$($(2)_SETUP_TYPE))
 
-ifneq ($$(filter-out setuptools setuptools-rust pep517 flit flit-bootstrap maturin,$$($(2)_SETUP_TYPE)),)
-$$(error "Invalid $(2)_SETUP_TYPE. Valid options are 'maturin', 'setuptools', 'setuptools-rust', 'pep517' or 'flit'.")
+ifneq ($$(filter-out setuptools setuptools-rust pep517 flit flit-bootstrap hatch maturin,$$($(2)_SETUP_TYPE)),)
+$$(error "Invalid $(2)_SETUP_TYPE. Valid options are 'maturin', 'setuptools', 'setuptools-rust', 'pep517', 'flit' or 'hatch'.")
 endif
 ifeq ($(4)-$$($(2)_SETUP_TYPE),target-flit-bootstrap)
 $$(error flit-bootstrap setup type only supported for host packages)
diff --git a/utils/scanpypi b/utils/scanpypi
index b6a2a92219..5871d97021 100755
--- a/utils/scanpypi
+++ b/utils/scanpypi
@@ -417,6 +417,8 @@ class BuildrootPackage():
                 self.build_backend = build_backend
                 if build_backend == 'flit_core.buildapi':
                     self.setup_metadata['method'] = 'flit'
+                elif build_backend == 'hatchling.build':
+                    self.setup_metadata['method'] = 'hatch'
                 elif build_backend == 'setuptools.build_meta':
                     self.setup_metadata['method'] = 'setuptools'
                 else:
-- 
2.34.1

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Buildroot] [PATCH 1/1] package/pkg-python.mk: add hatch setup type
  2024-10-08 22:27 [Buildroot] [PATCH 1/1] package/pkg-python.mk: add hatch setup type James Hilliard
@ 2024-10-23 21:01 ` Thomas Petazzoni via buildroot
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Petazzoni via buildroot @ 2024-10-23 21:01 UTC (permalink / raw)
  To: James Hilliard; +Cc: buildroot

On Tue,  8 Oct 2024 16:27:24 -0600
James Hilliard <james.hilliard1@gmail.com> wrote:

> As we have many python packages using the hatch(hatchling) build
> system we should add a setup type for it so that we don't have to
> manually specify the host-python-hatchling dependency.
> 
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> ---
>  docs/manual/adding-packages-directory.adoc |  6 ++---
>  docs/manual/adding-packages-python.adoc    | 14 +++++-----
>  package/pkg-python.mk                      | 31 ++++++++++++++++++++--
>  utils/scanpypi                             |  2 ++
>  4 files changed, 41 insertions(+), 12 deletions(-)

Applied to master, thanks.

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-10-23 21:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-08 22:27 [Buildroot] [PATCH 1/1] package/pkg-python.mk: add hatch setup type James Hilliard
2024-10-23 21:01 ` Thomas Petazzoni via buildroot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox