diff --git a/.gitignore b/.gitignore --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ # Packages *.egg *.egg-info +*.dist-info build eggs parts diff --git a/lang/python/Makefile.am b/lang/python/Makefile.am --- a/lang/python/Makefile.am +++ b/lang/python/Makefile.am @@ -34,40 +34,40 @@ .PHONY: prepare prepare: copystamp -# For VPATH builds we need to copy some files because Python's -# distutils are not VPATH-aware. +# For VPATH builds we need to copy some files because Python +# is not VPATH-aware. copystamp: ln -sf "$(top_srcdir)/src/data.h" . ln -sf "$(top_builddir)/conf/config.h" . ln -sf "$(srcdir)/src" gpg touch $@ -all-local: copystamp +all-local: wheels + +wheels: copystamp set -e ; for PYTHON in $(PYTHONS); do \ CPP="$(CPP)" \ CFLAGS="$(CFLAGS)" \ srcdir="$(srcdir)" \ top_builddir="$(top_builddir)" \ - $$PYTHON setup.py build --verbose --build-base="$$(basename "$${PYTHON}")-gpg" ; \ + $$PYTHON -m build --wheel --no-isolation --outdir=wheels . ; \ done -python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz.asc: copystamp - $(MKDIR_P) python$(PYTHON_VERSION)-gpg-dist +dist/gpg-$(VERSION).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 + $(PYTHON) -m build --sdist --no-isolation . 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 + $(gpgbin) --detach-sign --armor dist/gpg-$(VERSION).tar.gz .PHONY: sdist -sdist: python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz.asc +sdist: dist/gpg-$(VERSION).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-$(VERSION).tar.gz \ + dist/gpg-$(VERSION).tar.gz.asc twine upload $^ CLEANFILES = copystamp \ @@ -75,34 +75,27 @@ data.h \ gpg -# Remove the rest. -# -# 'make distclean' clears the write bit, breaking rm -rf. Fix the -# permissions. clean-local: - rm -rf -- build - for PYTHON in $(PYTHONS); do \ - find "$$(basename "$${PYTHON}")-gpg" -type d ! -perm -200 -exec chmod u+w {} ';' ; \ - rm -rf -- "$$(basename "$${PYTHON}")-gpg" ; \ - done + rm -rf -- build wheels dist gpg.egg-info -install-exec-local: +# Python 2 pip won't install the wheel if the egg-info is present +install-exec-local: wheels + rm -rf -- gpg.egg-info ; \ set -e ; for PYTHON in $(PYTHONS); do \ CPP="$(CPP)" \ CFLAGS="$(CFLAGS)" \ srcdir="$(srcdir)" \ top_builddir="$(top_builddir)" \ - $$PYTHON setup.py \ - build \ - --build-base="$$(basename "$${PYTHON}")-gpg" \ - install \ - --prefix "$(DESTDIR)$(prefix)" \ - --verbose ; \ + $$PYTHON -m pip install \ + --no-index --find-links ./wheels \ + --prefix "$(DESTDIR)$(prefix)" \ + --verbose \ + gpg ; \ done uninstall-local: set -x; GV=$$(echo $(VERSION) | tr - _); for PYTHON in $(PYTHONS); do \ PLATLIB="$(prefix)/$$("$${PYTHON}" -c 'import sysconfig, os; print(os.path.relpath(sysconfig.get_path("platlib", scheme="posix_prefix"), sysconfig.get_config_var("prefix")))')" ; \ rm -rf -- "$(DESTDIR)$${PLATLIB}/gpg" \ - "$(DESTDIR)$${PLATLIB}"/gpg-$$GV-py*.egg-info ; \ + "$(DESTDIR)$${PLATLIB}"/gpg-$$GV.dist-info ; \ done diff --git a/lang/python/doc/src/gpgme-python-howto.org b/lang/python/doc/src/gpgme-python-howto.org --- a/lang/python/doc/src/gpgme-python-howto.org +++ b/lang/python/doc/src/gpgme-python-howto.org @@ -2945,7 +2945,7 @@ =setup.py= file which contains this: #+BEGIN_SRC python -i -from distutils.core import setup +from setuptools import setup from Cython.Build import cythonize setup( diff --git a/lang/python/examples/howto/advanced/cython/setup.py b/lang/python/examples/howto/advanced/cython/setup.py --- a/lang/python/examples/howto/advanced/cython/setup.py +++ b/lang/python/examples/howto/advanced/cython/setup.py @@ -1,4 +1,4 @@ -from distutils.core import setup +from setuptools import setup from Cython.Build import cythonize setup( diff --git a/lang/python/setup.py.in b/lang/python/setup.py.in --- a/lang/python/setup.py.in +++ b/lang/python/setup.py.in @@ -18,8 +18,12 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -from distutils.core import setup, Extension -from distutils.command.build import build +try: + from setuptools import setup, Extension + from setuptools.command.build import build +except ImportError: + from distutils.core import setup, Extension + from distutils.command.build import build import glob import os @@ -225,9 +229,8 @@ build.run(self) -py3 = [] if sys.version_info.major < 3 else ['-py3'] swig_sources = [] -swig_opts = ['-threads'] + py3 + extra_swig_opts +swig_opts = ['-threads'] + extra_swig_opts swige = Extension( 'gpg._gpgme', sources=swig_sources, @@ -282,10 +285,12 @@ 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'Operating System :: POSIX', 'Operating System :: Microsoft :: Windows', 'Topic :: Communications :: Email', diff --git a/m4/ax_python_devel.m4 b/m4/ax_python_devel.m4 --- a/m4/ax_python_devel.m4 +++ b/m4/ax_python_devel.m4 @@ -468,4 +468,4 @@ # # all done! # -]) +]) \ No newline at end of file diff --git a/m4/python.m4 b/m4/python.m4 --- a/m4/python.m4 +++ b/m4/python.m4 @@ -36,12 +36,12 @@ # numbers and dots only. AC_DEFUN([AM_PATH_PYTHON], [ - dnl Find a Python interpreter. Python versions prior to 2.7 are not - dnl supported. Python 3.0 through to Python 3.3 are also not supported. + dnl Find a Python interpreter. Python versions prior to 3.8 are + dnl end-of-life and not supported, with the exception of 2.7 and 3.6 m4_define_default([_AM_PYTHON_INTERPRETER_LIST], [python2 python2.7 dnl python dnl - python3 python3.10 python3.9 python3.8 python3.7 python3.6 python3.5 python3.4 + python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.6 ]) AC_ARG_VAR([PYTHON], [the Python interpreter])