Skip to contentSkip to conversation

bindings: python: migrate metadata to pyproject.toml

PATCH Applied Vincent Fazio 2 participants 2 messages Nov 22, 2024 – Nov 27, 2024 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bindings: python: migrate metadata to pyproject.toml

PEP 621 [0] designated pyproject.toml as the standard place to store project metadata.

Setuptools, the build system used by this project, has support for reading metadata from this location. As such, migrate the majority of the metadata out of setup.py.

For now, the external modules are left declared in setup.py because support within pyproject.toml is still experimental [1].

New metadata has been added/updated, namely:
* Add Trove classifiers
* Add a link to the issues page
* Update license from LGPL-2.1 to LGPL-2.1+ to match SPDX identifier

[0]: https://peps.python.org/pep-0621/
[1]: https://setuptools.pypa.io/en/stable/userguide/ext_modules.html#pyproject-toml

---
 bindings/python/pyproject.toml | 43 +++++++++++++++++++++++++++++++++-
 bindings/python/setup.py       | 20 +---------------
 2 files changed, 43 insertions(+), 20 deletions(-)
bindings/python/pyproject.toml +42 -1
index d6f5f9b..dbc0c7d 100644
@@ -2,7 +2,48 @@
 # SPDX-FileCopyrightText: 2023 Phil Howard <[email protected]>
 
 [build-system]
-requires = ["setuptools", "wheel", "packaging"]
+requires = ["setuptools>=69.0.0", "wheel", "packaging"]
+build-backend = "setuptools.build_meta"
+
+[project]
+name = "gpiod"
+dynamic = ["version"]
+description = "Python bindings for libgpiod"
+readme = "README.md"
+license = {text = "LGPL-2.1-or-later"}
+requires-python = ">=3.9.0"
+authors = [
+  {name = "Bartosz Golaszewski", email = "[email protected]"},
+]
+classifiers = [
+  "Development Status :: 5 - Production/Stable",
+  "License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)",
+  "Operating System :: POSIX :: Linux",
+  "Typing :: Typed",
+  "Programming Language :: Python",
+  "Programming Language :: Python :: 3",
+  "Programming Language :: Python :: 3 :: Only",
+  "Programming Language :: Python :: 3.9",
+  "Programming Language :: Python :: 3.10",
+  "Programming Language :: Python :: 3.11",
+  "Programming Language :: Python :: 3.12",
+  "Programming Language :: Python :: 3.13",
+]
+
+[project.urls]
+Homepage = "https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git"
+Issues = "https://github.com/brgl/libgpiod/issues/"
+
+[tool.setuptools]
+platforms = ["linux"]
+include-package-data = false
+
+[tool.setuptools.dynamic]
+version = {attr = "gpiod.version.__version__"}
+
+[tool.setuptools.packages.find]
+include = ["gpiod"]
+namespaces = false
 
 [tool.mypy]
 python_version = "3.9"
bindings/python/setup.py +1 -19
index 0d518af..1af4709 100644
@@ -4,7 +4,7 @@
 from os import getenv, path, unlink
 from shutil import copytree, rmtree
 
-from setuptools import Extension, find_packages, setup
+from setuptools import Extension, setup
 from setuptools.command.build_ext import build_ext as orig_build_ext
 from setuptools.command.sdist import log
 from setuptools.command.sdist import sdist as orig_sdist
@@ -18,11 +18,6 @@ TAR_FILENAME = "libgpiod-{version}.tar.gz"
 ASC_FILENAME = "sha256sums.asc"
 SHA256_CHUNK_SIZE = 2048
 
-# __version__
-with open("gpiod/version.py", "r") as fd:
-    exec(fd.read())
-
-
 def sha256(filename):
     """
     Return a sha256sum for a specific filename, loading the file in chunks
@@ -225,19 +220,6 @@ gpiod_ext = Extension(
 )
 
 setup(
-    name="gpiod",
-    url="https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git",
-    packages=find_packages(exclude=["tests", "tests.*"]),
-    package_data={"gpiod": ["py.typed", "_ext.pyi"]},
-    python_requires=">=3.9.0",
     ext_modules=[gpiod_ext],
     cmdclass={"build_ext": build_ext, "sdist": sdist},
-    version=__version__,
-    author="Bartosz Golaszewski",
-    author_email="[email protected]",
-    description="Python bindings for libgpiod",
-    long_description=open("README.md", "r").read(),
-    long_description_content_type="text/markdown",
-    platforms=["linux"],
-    license="LGPLv2.1",
 )
Signature · 1 line
2.34.1
#1 lore raw

From: Bartosz Golaszewski <[email protected]>

Quoted 8 lines · Vincent Fazio

PEP 621 [0] designated pyproject.toml as the standard place to store project metadata.

Setuptools, the build system used by this project, has support for reading metadata from this location. As such, migrate the majority of the metadata out of setup.py.

[...]

Applied, thanks!

[1/1] bindings: python: migrate metadata to pyproject.toml

      commit: 1ee51f95c5258aceb2776febdd5cc93f6b2a48e5

Best regards,

Signature · 1 line
Bartosz Golaszewski <[email protected]>