-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bindings: python: migrate metadata out of setup.py to pyproject.toml #107
Comments
@vfazio was this achieved by your big series I applied today? |
It was not. I was trying to keep the typing related stuff in that series and this is outside of that scope. I think some of this is pretty simple, but i need to make sure that after the migration to pyproject.toml that the wheels and what not still look kosher. |
Got it. |
@brgl I can certainly work on this if you want me to. Is this something you wanted to close out as part of 2.2.3 or 2.3.x? I'm not 100% sure of the binding versioning scheme. My availability to work on this stuff is a little limited with the holidays coming up in the US and other travel plans of mine. (also why i haven't responded to the other issue, i'm way behind on other work, I haven't forgotten about it however). |
The next version is going to be v2.3.0. I think the recent rework deserves a minor release. |
Are there other fixups or changes you want to include before tagging 2.3.0? I would like to help get those resolved for you if I can. |
The migration to pyproject.toml would be handy. :) |
I've got this mostly working. I need to compare the outputs from the migration to previous sdist and wheels to make sure the contents look correct. I'll let you know how that goes. |
I'm going to post a diff here and then explain some things and then post some evidence just to have a discussion before actually posting the patch to the ML especially since my dev environment is different than yours. diff --git a/bindings/python/pyproject.toml b/bindings/python/pyproject.toml
index d6f5f9b..a87055c 100644
--- a/bindings/python/pyproject.toml
+++ b/bindings/python/pyproject.toml
@@ -2,7 +2,48 @@
# SPDX-FileCopyrightText: 2023 Phil Howard <phil@gadgetoid.com>
[build-system]
-requires = ["setuptools", "wheel", "packaging"]
+requires = ["setuptools>=69.0.0"]
+build-backend = "setuptools.build_meta"
+
+[project]
+name = "gpiod"
+dynamic = ["version"]
+description = "Python bindings for libgpiod"
+readme = "README.md"
+license = {text = "LGPL-2.1"}
+requires-python = ">=3.9.0"
+authors = [
+ { name = "Bartosz Golaszewski", email = "brgl@bgdev.pl" },
+]
+classifiers = [
+ "Development Status :: 5 - Production/Stable",
+ "License :: OSI Approved :: GNU Lesser General Public License v2 (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",
+]
+
+[tool.setuptools]
+platforms = ["linux"]
+include-package-data = false
+
+[tool.setuptools.dynamic]
+version = {attr = "gpiod.version.__version__"}
+
+[tool.setuptools.packages.find]
+include = ["gpiod"]
+namespaces = false
+
+[project.urls]
+Homepage = "https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git"
+Issues = "https://github.com/brgl/libgpiod/issues/"
[tool.mypy]
python_version = "3.9"
diff --git a/bindings/python/setup.py b/bindings/python/setup.py
index 0d518af..1af4709 100644
--- a/bindings/python/setup.py
+++ b/bindings/python/setup.py
@@ -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="brgl@bgdev.pl",
- description="Python bindings for libgpiod",
- long_description=open("README.md", "r").read(),
- long_description_content_type="text/markdown",
- platforms=["linux"],
- license="LGPLv2.1",
)
With the above changes, I compared both the 2.2.2 sdist and a 2.2.2 wheel against those generated by For the sdist:
Just the extra files we expect to include and the renamed "internal" For the wheel:
The difference is the empty As mentioned, the sdist and wheel script works:
I tested the resultant wheel by tying two lines together and watching edge events:
The repo's top level default make target continues to build without error. The python tests continue to build and work as well. Rationale behind the changes:
|
it looks like i did LGPL-2.1 and should have done 2.1+ based on the SPDX headers on the files. I will fix that when i actually make the patch. I was going off of the license value formerly in |
Sorry to ping you, @brgl does this seem reasonable? |
Yes, awesome. Are tests still packaged in sdist? |
Yep, they are still packaged in sdist.
|
For good measure, I went ahead and also validated that wheels worked on Alpine too:
I'll post a patch in a bit |
I applied the patch, awesome work, thank you. Everything I could think of still works. |
Awesome, glad i could help out! |
PyPA recommends migrating to pyproject.toml where possible: https://packaging.python.org/en/latest/guides/modernize-setup-py-project/
We have one, but it's sparse. We do not explicitly specify the build-backend:
I don't think we need "wheel" as a dependency to generate wheels (testing shows we don't at least).
As part of the migration, we can specify proper Trove classifiers. Newer versions of setuptools support dynamic fields in the toml file.
More configuration will slowly start landing in the toml file as a result of #97, so we may as well make it comprehensive.
The text was updated successfully, but these errors were encountered: