summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2022-09-05 11:50:38 +0100
committerSimon McVittie <smcv@collabora.com>2022-09-06 00:32:56 +0100
commit0f725f0a534e2592e7c5b99bcb8eae579a3d5232 (patch)
tree0e2dc80bd703285b6dd8518dc38e372b37fc2e2d
parent2bc8a75c3e0c76647c49b97f7d2df5a106bf9750 (diff)
downloaddbus-python-0f725f0a534e2592e7c5b99bcb8eae579a3d5232.tar.gz
setup.py: Build using Meson instead of Autotools by default
This requires mostly dropping support for Python 3.5 and 3.6, both of which are EOL anyway. Signed-off-by: Simon McVittie <smcv@collabora.com>
-rw-r--r--.gitlab-ci.yml9
-rw-r--r--Makefile.am2
-rw-r--r--NEWS18
-rw-r--r--pyproject.toml50
-rw-r--r--setup.cfg40
-rwxr-xr-xsetup.py100
-rwxr-xr-xtools/ci-install.sh45
7 files changed, 175 insertions, 89 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e6ae8ec..4fadeac 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -46,15 +46,6 @@ variables:
- _autotools/*.log
when: always
-build:python3.5:
- stage: build
- image: "debian:stretch-slim"
- variables:
- ci_suite: stretch
- dbus_ci_system_python: python3
- script: *script
- artifacts: *artifacts
-
build:python3.7:
stage: build
image: "debian:buster-slim"
diff --git a/Makefile.am b/Makefile.am
index 3b00991..3046439 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -39,6 +39,8 @@ EXTRA_DIST = \
examples/unix-fd-service.py \
meson.build \
meson_options.txt \
+ pyproject.toml \
+ setup.cfg \
setup.py \
test/TestSuitePythonService.service.in \
test/compiled.test.in \
diff --git a/NEWS b/NEWS
index fa7f350..d97d381 100644
--- a/NEWS
+++ b/NEWS
@@ -4,17 +4,27 @@ dbus Python Bindings 1.3.0 (UNRELEASED)
Dependencies:
• Python 3, version 3.5 or later, is required.
- A security-supported version (currently 3.6 or later) is recommended.
+ An upstream-supported version (currently 3.7 or later) is strongly
+ recommended, and a future version of dbus-python is likely to require
+ Python 3.7 or later.
Python 2 is no longer supported.
-• Installing from source code can be done with either Autotools or Meson.
-• Installing from PyPI using pip still relies on Autotools for now.
+
+• Installing from source code using Meson requires Python 3.5 or later
+ and Meson 0.56.2 or later. This is now the recommended build system.
+
+• Installing from source code using Autotools requires Python 3.5 or later.
+ The Autotools build system is likely to be removed in a future version.
+
+• Installing from PyPI using pip or from source code via setup.py
+ requires Python 3.7 or later, Meson 0.60.3 or later, meson-python 0.8.1
+ or later, and their dependencies (ninja, patchelf, setuptools, wheel).
API changes:
• dbus.gobject_service, dbus.types.UTF8String and the utf8_strings
keyword argument were only usable with Python 2, and therefore have
been removed, along with the rest of the special cases for Python 2.
- (dbus-python!115; Simon McVittie)
+ (dbus-python!15; Simon McVittie)
Enhancements:
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 0000000..3949d8f
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,50 @@
+# Copyright 2022 Collabora Ltd.
+# SPDX-License-Identifier: MIT
+
+[build-system]
+build-backend = 'mesonpy'
+requires = [
+ 'meson-python>=0.8.1',
+ 'meson>=0.60.0',
+ 'ninja',
+ 'patchelf',
+ 'setuptools',
+ 'wheel',
+]
+
+[project]
+name = 'dbus-python'
+license = { text = 'Expat (MIT/X11)' }
+description = 'Python bindings for libdbus'
+maintainers = [
+ { name = 'The D-Bus maintainers', email = 'dbus@lists.freedesktop.org' },
+]
+requires-python = '>=3.7'
+readme = { file = 'README', content-type = 'text/x-rst' }
+keywords = ['dbus', 'D-Bus']
+classifiers = [
+ 'Development Status :: 7 - Inactive',
+ 'License :: OSI Approved :: MIT License',
+ 'Programming Language :: C',
+ 'Programming Language :: Python :: 3',
+ 'Programming Language :: Python :: Implementation :: CPython',
+ 'Topic :: Software Development :: Object Brokering',
+]
+dynamic = [
+ 'version'
+]
+
+[project.optional-dependencies]
+doc = [
+ 'sphinx',
+ 'sphinx_rtd_theme',
+]
+test = [
+ 'tap.py',
+]
+
+[project.urls]
+homepage = 'http://www.freedesktop.org/wiki/Software/DBusBindings/#python'
+download = 'http://dbus.freedesktop.org/releases/dbus-python/'
+source = 'https://gitlab.freedesktop.org/dbus/dbus-python/'
+tracker = 'https://gitlab.freedesktop.org/dbus/dbus-python/-/issues'
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..1c5a0cb
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,40 @@
+# Copyright 2022 Collabora Ltd.
+# SPDX-License-Identifier: MIT
+
+[options]
+python_requires = >=3.7
+setup_requires =
+ meson-python>=0.8.1
+ meson>=0.60.3
+ ninja
+ patchelf
+ setuptools
+ wheel
+zip_safe = False
+
+[metadata]
+name = dbus-python
+license = Expat (MIT/X11)
+description = Python bindings for libdbus
+maintainer = The D-Bus maintainers
+maintainer_email = dbus@lists.freedesktop.org
+long_description = file: README
+keywords =
+ dbus
+ D-Bus
+classifiers =
+ Development Status :: 7 - Inactive
+ License :: OSI Approved :: MIT License
+ Programming Language :: C
+ Programming Language :: Python :: 3
+ Programming Language :: Python :: Implementation :: CPython
+ Topic :: Software Development :: Object Brokering
+url = http://www.freedesktop.org/wiki/Software/DBusBindings/#python
+download_url = http://dbus.freedesktop.org/releases/dbus-python/
+
+[options.extras_require]
+doc =
+ sphinx
+ sphinx_rtd_theme
+test =
+ tap.py
diff --git a/setup.py b/setup.py
index cc604f1..6edf234 100755
--- a/setup.py
+++ b/setup.py
@@ -33,41 +33,83 @@ import os
import subprocess
import sys
+
+if (
+ os.environ.get('DBUS_PYTHON_USE_AUTOTOOLS', '')
+ or sys.version_info < (3, 7)
+):
+ use_autotools = True
+ setup_requires = ['setuptools', 'wheel']
+else:
+ use_autotools = False
+ setup_requires = ['meson>=0.60.0', 'ninja', 'setuptools', 'wheel']
+
if os.path.exists('.version'):
version = open('.version').read().strip()
-else:
+elif use_autotools:
version = subprocess.check_output(['autoconf', '--trace', 'AC_INIT:$2',
'configure.ac']).decode('utf-8').strip()
+else:
+ with open('meson.build') as reader:
+ for line in reader:
+ if line.strip().replace(' ', '').startswith('version:'):
+ version = line.split(':', 1)[1]
+ version = version.replace(',', '')
+ version = version.replace('"', '')
+ version = version.replace("'", '')
+ break
+ else:
+ raise AssertionError('Cannot find version in meson.build')
class Build(Distribution().get_command_class('build')):
- """Dummy version of distutils build which runs an Autotools build system
- instead.
+ """Dummy version of distutils build which runs an Autotools or Meson
+ build system instead.
"""
def run(self):
srcdir = os.getcwd()
builddir = os.path.join(srcdir, self.build_temp)
- configure = os.path.join(srcdir, 'configure')
mkpath(builddir)
- if not os.path.exists(configure):
- configure = os.path.join(srcdir, 'autogen.sh')
+ if use_autotools:
+ configure = os.path.join(srcdir, 'configure')
+
+ if not os.path.exists(configure):
+ configure = os.path.join(srcdir, 'autogen.sh')
- subprocess.check_call([
- configure,
- '--disable-maintainer-mode',
- 'PYTHON=' + sys.executable,
- # Put the documentation, etc. out of the way: we only want
- # the Python code and extensions
- '--prefix=' + os.path.join(builddir, 'prefix'),
- ],
- cwd=builddir)
- make_args = [
- 'pythondir=' + os.path.join(srcdir, self.build_lib),
- 'pyexecdir=' + os.path.join(srcdir, self.build_lib),
- ]
- subprocess.check_call(['make', '-C', builddir] + make_args)
- subprocess.check_call(['make', '-C', builddir, 'install'] + make_args)
+ subprocess.check_call([
+ configure,
+ '--disable-maintainer-mode',
+ 'PYTHON=' + sys.executable,
+ # Put the documentation, etc. out of the way: we only want
+ # the Python code and extensions
+ '--prefix=' + os.path.join(builddir, 'prefix'),
+ ],
+ cwd=builddir)
+ make_args = [
+ 'pythondir=' + os.path.join(srcdir, self.build_lib),
+ 'pyexecdir=' + os.path.join(srcdir, self.build_lib),
+ ]
+ subprocess.check_call(['make', '-C', builddir] + make_args)
+ subprocess.check_call(['make', '-C', builddir, 'install'] + make_args)
+ else:
+ subprocess.check_call(
+ [
+ sys.executable,
+ '-m', 'mesonbuild.mesonmain',
+ '--prefix=' + os.path.join(builddir, 'prefix'),
+ '-Ddoc=false',
+ '-Dinstalled_tests=false',
+ '-Dpython=' + sys.executable,
+ '-Dpython.platlibdir=' + os.path.join(srcdir, self.build_lib),
+ '-Dpython.purelibdir=' + os.path.join(srcdir, self.build_lib),
+ '-Dtests=false',
+ srcdir,
+ builddir,
+ ]
+ )
+ subprocess.check_call(['meson', 'compile', '-C', builddir])
+ subprocess.check_call(['meson', 'install', '-C', builddir])
class BuildExt(Distribution().get_command_class('build_ext')):
def run(self):
@@ -85,27 +127,13 @@ dbus_glib_bindings = Extension('_dbus_glib_bindings',
setup(
name='dbus-python',
version=version,
- description='Python bindings for libdbus',
- long_description=open('README').read(),
- maintainer='The D-Bus maintainers',
- maintainer_email='dbus@lists.freedesktop.org',
- download_url='http://dbus.freedesktop.org/releases/dbus-python/',
- url='http://www.freedesktop.org/wiki/Software/DBusBindings/#python',
packages=['dbus'],
ext_modules=[dbus_bindings, dbus_glib_bindings],
- license='Expat (MIT/X11)',
- classifiers=[
- 'Development Status :: 7 - Inactive',
- 'License :: OSI Approved :: MIT License',
- 'Programming Language :: C',
- 'Programming Language :: Python :: 3',
- 'Programming Language :: Python :: Implementation :: CPython',
- 'Topic :: Software Development :: Object Brokering',
- ],
cmdclass={
'build': Build,
'build_py': BuildPy,
'build_ext': BuildExt,
},
+ setup_requires=setup_requires,
tests_require=['tap.py'],
)
diff --git a/tools/ci-install.sh b/tools/ci-install.sh
index 93c7c4d..ce9864b 100755
--- a/tools/ci-install.sh
+++ b/tools/ci-install.sh
@@ -63,8 +63,6 @@ else
fi
have_system_meson=
-have_system_sphinx=
-have_system_tappy=
if [ -n "$ci_docker" ]; then
sed \
@@ -131,21 +129,10 @@ case "$ci_distro" in
python3-gi${dbus_ci_system_python_module_suffix} \
python3-pip \
python3-setuptools \
+ python3-sphinx \
+ python3-sphinx-rtd-theme \
python3-tap \
${NULL}
-
- case "$ci_suite" in
- (stretch|bionic)
- ;;
-
- (*)
- $sudo apt-get -qq -y install \
- python3-sphinx \
- python3-sphinx-rtd-theme \
- ${NULL}
- have_system_sphinx=yes
- ;;
- esac
fi
if [ "$ci_in_docker" = yes ]; then
@@ -157,7 +144,7 @@ case "$ci_distro" in
fi
case "$ci_suite" in
- (stretch|bionic|buster|focal|bullseye)
+ (buster|focal|bullseye)
$sudo apt-get -qq -y install dbus
;;
@@ -167,7 +154,7 @@ case "$ci_distro" in
esac
case "$ci_suite" in
- (stretch|bionic|buster|focal)
+ (buster|focal)
;;
(*)
@@ -186,31 +173,9 @@ esac
if [ -n "$have_system_meson" ]; then
:
elif [ -n "${dbus_ci_system_python-}" ]; then
- case "$ci_suite" in
- (stretch|xenial|bionic)
- # 0.56.2 is the last version that supported Python 3.5
- runuser -u user -- "$dbus_ci_system_python" -m pip install --user meson==0.56.2 ninja
- ;;
- (*)
- runuser -u user -- "$dbus_ci_system_python" -m pip install --user meson ninja
- ;;
- esac
+ runuser -u user -- "$dbus_ci_system_python" -m pip install --user meson ninja
else
runuser -u user -- pip install meson ninja
fi
-if [ -n "$have_system_sphinx" ]; then
- :
-elif [ -n "${dbus_ci_system_python-}" ]; then
- runuser -u user -- "$dbus_ci_system_python" -m pip install --user \
- sphinx \
- sphinx_rtd_theme \
- ${NULL}
-else
- runuser -u user -- pip install \
- sphinx \
- sphinx_rtd_theme \
- ${NULL}
-fi
-
# vim:set sw=4 sts=4 et: