build,python: Build Python bindings without distutils

* m4/python.m4: Add python3.12 and 3.11 as valid interpreters, remove
EOL 3.4, 3.5, 3.7 (keep 3.6 because some distributions still ship and
maintain it).
* lang/python/Makefile.am (clean-local): Remove dist and gpg.egg-info
created by Python 3.9+ on make install.
* lang/python/setup.py.in: switch from distutils to setuptools where
possible, remove obsolete and deprecated -py3 option of swig, add
classifiers up to 3.12, remove 3.4, 3.5, 3.7.
* lang/python/doc/src/gpgme-python-howto.org: replace distutils with
setuptools
* lang/python/examples/howto/advanced/cython/setup.py: replace distutils
with setuptools
--

This fixes building the Python bindings for Python 3.12 where distutils
has been removed.

Based on D545
This commit is contained in:
Ben Greiner 2024-05-29 15:17:58 +02:00 committed by Ingo Klöcker
parent 986c5f0b94
commit 5844d9e700
No known key found for this signature in database
GPG Key ID: F5A5D1692277A1E9
5 changed files with 18 additions and 13 deletions

View File

@ -80,7 +80,7 @@ CLEANFILES = copystamp \
# 'make distclean' clears the write bit, breaking rm -rf. Fix the # 'make distclean' clears the write bit, breaking rm -rf. Fix the
# permissions. # permissions.
clean-local: clean-local:
rm -rf -- build rm -rf -- build dist gpg.egg-info
for PYTHON in $(PYTHONS); do \ for PYTHON in $(PYTHONS); do \
find "$$(basename "$${PYTHON}")-gpg" -type d ! -perm -200 -exec chmod u+w {} ';' ; \ find "$$(basename "$${PYTHON}")-gpg" -type d ! -perm -200 -exec chmod u+w {} ';' ; \
rm -rf -- "$$(basename "$${PYTHON}")-gpg" ; \ rm -rf -- "$$(basename "$${PYTHON}")-gpg" ; \

View File

@ -2945,7 +2945,7 @@ Save that into a file called =keycount.pyx= and then create a
=setup.py= file which contains this: =setup.py= file which contains this:
#+BEGIN_SRC python -i #+BEGIN_SRC python -i
from distutils.core import setup from setuptools import setup
from Cython.Build import cythonize from Cython.Build import cythonize
setup( setup(

View File

@ -1,4 +1,4 @@
from distutils.core import setup from setuptools import setup
from Cython.Build import cythonize from Cython.Build import cythonize
setup( setup(

View File

@ -18,6 +18,10 @@
# License along with this library; if not, write to the Free Software # License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
try:
from setuptools import setup, Extension
from setuptools.command.build import build
except ImportError:
from distutils.core import setup, Extension from distutils.core import setup, Extension
from distutils.command.build import build from distutils.command.build import build
@ -225,9 +229,8 @@ class BuildExtFirstHack(build):
build.run(self) build.run(self)
py3 = [] if sys.version_info.major < 3 else ['-py3']
swig_sources = [] swig_sources = []
swig_opts = ['-threads'] + py3 + extra_swig_opts swig_opts = ['-threads'] + extra_swig_opts
swige = Extension( swige = Extension(
'gpg._gpgme', 'gpg._gpgme',
sources=swig_sources, sources=swig_sources,
@ -282,10 +285,12 @@ GPGME and these bindings is available here:
'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6', '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 :: POSIX',
'Operating System :: Microsoft :: Windows', 'Operating System :: Microsoft :: Windows',
'Topic :: Communications :: Email', 'Topic :: Communications :: Email',

View File

@ -36,12 +36,12 @@
# numbers and dots only. # numbers and dots only.
AC_DEFUN([AM_PATH_PYTHON], AC_DEFUN([AM_PATH_PYTHON],
[ [
dnl Find a Python interpreter. Python versions prior to 2.7 are not dnl Find a Python interpreter. Python versions prior to 3.8 are
dnl supported. Python 3.0 through to Python 3.3 are also not supported. dnl end-of-life and not supported, with the exception of 2.7 and 3.6.
m4_define_default([_AM_PYTHON_INTERPRETER_LIST], m4_define_default([_AM_PYTHON_INTERPRETER_LIST],
[python2 python2.7 dnl [python2 python2.7 dnl
python 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]) AC_ARG_VAR([PYTHON], [the Python interpreter])