[PATCH gpgme] Fix prerelease Python sdist tarball creation and add PEP517 support
David Runge
dave at sleepmap.de
Tue Nov 15 18:37:47 CET 2022
Hi again,
I noticed a small mistake in the pyproject.toml file that I provided.
Please find attached a revised version, which also properly states the
build-backend for setuptools.
Best,
David
--
https://sleepmap.de
-------------- next part --------------
From 2d1fc6414e01959856313ce61d59a71774286b04 Mon Sep 17 00:00:00 2001
From: David Runge <dave at sleepmap.de>
Date: Mon, 14 Nov 2022 00:14:47 +0100
Subject: [PATCH 1/2] Simplify and standardize Python sdist creation
lang/python/Makefile.am:
- Substitute `-alpha`, `-beta` and `-rc` version string components with
`a`, `b` and `rc` (respectively), as that is used when Python version
strings are constructed (https://peps.python.org/pep-0440/).
- Rely on the standard `dist/` directory created by `python setup.py
sdist` instead of using a custom one which requires more overhead for
no benefit.
- Remove the use of the invalid `--manifest` option to `python setup.py
sdist` (MANIFEST.in is used automatically).
- Instead of trying to find `gpg` via `gpgconf`, just use `gpg`
directly, when creating a detached signature for the sdist tarball.
- Provide a `clean` target which can be used to remove the `dist/`
directory via `make clean -C lang/python`.
Signed-off-by: David Runge <dave at sleepmap.de>
---
lang/python/Makefile.am | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/lang/python/Makefile.am b/lang/python/Makefile.am
index 845b7b17..99279e74 100644
--- a/lang/python/Makefile.am
+++ b/lang/python/Makefile.am
@@ -23,6 +23,9 @@ EXTRA_DIST = \
gpgme.i \
helpers.c helpers.h private.h
+# Python translates -alpha to a and -beta to b in version strings
+PY_PKG_VER = $(subst -alpha,a,$(subst -beta,b,$(subst -rc,rc,$(VERSION))))
+
SUBDIRS = . tests examples doc src
.PHONY: prepare
@@ -45,23 +48,20 @@ all-local: copystamp
$$PYTHON setup.py build --verbose --build-base="$$(basename "$${PYTHON}")-gpg" ; \
done
-python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz.asc: copystamp
- $(MKDIR_P) python$(PYTHON_VERSION)-gpg-dist
+dist/gpg-$(PY_PKG_VER).tar.gz.asc: copystamp
CPP="$(CPP)" \
CFLAGS="$(CFLAGS)" \
srcdir="$(srcdir)" \
top_builddir="$(top_builddir)" \
- $(PYTHON) setup.py sdist --verbose --dist-dir=python$(PYTHON_VERSION)-gpg-dist \
- --manifest=python$(PYTHON_VERSION)-gpg-dist/MANIFEST
- gpgbin=gpgconf --list-components | grep OpenPGP | sed -e 's/gpg:OpenPGP://g'
- $(gpgbin) --detach-sign --armor python$(PYTHON_VERSION)-gpg-dist/gpg-$(VERSION).tar.gz
+ $(PYTHON) setup.py sdist --verbose
+ gpg --detach-sign --armor dist/gpg-$(PY_PKG_VER).tar.gz
.PHONY: sdist
-sdist: python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz.asc
+sdist: dist/gpg-$(PY_PKG_VER).tar.gz.asc
.PHONY: upload
-upload: python$(PYTHON_VERSION)-gpg-dist/gpg-$(VERSION).tar.gz \
- python$(PYTHON_VERSION)-gpg-dist/gpg-$(VERSION).tar.gz.asc
+upload: dist/gpg-$(PY_PKG_VER).tar.gz \
+ dist/gpg-$(PY_PKG_VER).tar.gz.asc
twine upload $^
CLEANFILES = copystamp \
@@ -69,6 +69,9 @@ CLEANFILES = copystamp \
data.h \
gpg
+clean:
+ rm -rf -- dist
+
# Remove the rest.
#
# 'make distclean' clears the write bit, breaking rm -rf. Fix the
--
2.38.1
-------------- next part --------------
From eb4e4ea274fc50b4433f827959773d178518b139 Mon Sep 17 00:00:00 2001
From: David Runge <dave at sleepmap.de>
Date: Mon, 14 Nov 2022 00:22:01 +0100
Subject: [PATCH 2/2] Add pyproject.toml to list required build-systems
lang/python/pyproject.toml:
Add pyproject.toml file to add the required build-systems (setuptools
and swig). Adding the file with the `[build-system]` table allows PEP517
(https://peps.python.org/pep-0517/) aware build backends to function
properly, by automatically resolving build backends
(https://peps.python.org/pep-0518/).
See https://setuptools.pypa.io/en/latest/build_meta.html for further
reference as to how setuptools handles this.
This change allows to pull in `gpg` via pypi.org using Python project
management software such as flit, poetry and pdm, which are enabled to
build gpg in a virtualenv of a given project.
Signed-off-by: David Runge <dave at sleepmap.de>
---
lang/python/pyproject.toml | 7 +++++++
1 file changed, 7 insertions(+)
create mode 100644 lang/python/pyproject.toml
diff --git a/lang/python/pyproject.toml b/lang/python/pyproject.toml
new file mode 100644
index 00000000..34258d48
--- /dev/null
+++ b/lang/python/pyproject.toml
@@ -0,0 +1,7 @@
+[build-system]
+requires = [
+ "setuptools",
+ "swig",
+]
+
+build-backend = "setuptools.build_meta"
--
2.38.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <https://lists.gnupg.org/pipermail/gnupg-devel/attachments/20221115/d3298c2f/attachment.sig>
More information about the Gnupg-devel
mailing list