- pip install pytest-cov
     - py.test -q --cov=musicpd test.py
   only:
-    - pushes
+    changes:
+      - musicpd.py
+      - test.py
 
 test-py3.11:
   extends:
 
 build:
   stage: build
+  extends:
+    - .cache_python
   script:
+    - python -m venv venv
+    - source venv/bin/activate
+    - pip install build
     # packaging test
-    - python setup.py bdist_wheel sdist
+    - python3 -m build -s -w
     - pip install dist/*.whl
     - pip install twine
     - twine check dist/*
 
 tag_release:
   stage: build
+  extends:
+    - .cache_python
   script:
-    - python setup.py bdist_wheel sdist
+    - python -m venv venv
+    - source venv/bin/activate
+    - pip install build
+    - python3 -m build -s -w
   artifacts:
     paths:
       - dist/*.whl
 
  * Fixed send_noidle (introduced with e8daa719)
  * Improved Range object to deal with window parameter
  * Add logging
+ * Switch to pyproject.toml (setuptools build system)
 
 Changes in 0.8.0
 ----------------
 
     # Installs sphinx if needed
     python3 -m venv venv && . ./venv/bin/activate
     pip install sphinx
-    # And build
-    python3 setup.py build_sphinx
-    # Or call sphinx
+    # Call sphinx
     sphinx-build -d ./doc/build/doctrees doc/source -b html ./doc/build/html
 
 
 
--- /dev/null
+# SPDX-FileCopyrightText: 2023  kaliko <kaliko@azylum.org>
+# SPDX-License-Identifier: LGPL-3.0-or-later
+[project]
+name = "python-musicpd"
+keywords = ["mpd", "Music Player Daemon"]
+description = "An MPD (Music Player Daemon) client library written in pure Python."
+authors = [
+  { name="Kaliko Jack", email="kaliko@azylum.org" },
+]
+license = {file = "LICENSE.txt"}
+readme = "README.rst"
+requires-python = ">=3.6"
+classifiers = [
+    "Development Status :: 5 - Production/Stable",
+    "Intended Audience :: Developers",
+    "License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
+    "Natural Language :: English",
+    "Operating System :: OS Independent",
+    "Programming Language :: Python :: 3",
+    "Topic :: Software Development :: Libraries :: Python Modules",
+]
+dynamic = ["version"]
+
+[project.optional-dependencies]
+sphinx = ["Sphinx>=5.3.0"]
+
+[project.urls]
+"Homepage" = "https://kaliko.me/python-musicpd/"
+
+[build-system]
+requires = ["setuptools>=61.0.0"]
+
+[tool.setuptools.dynamic]
+version = {attr = "musicpd.VERSION"}
 
+++ /dev/null
-# SPDX-FileCopyrightText: 2012-2021  kaliko <kaliko@azylum.org>
-# SPDX-License-Identifier: LGPL-3.0-or-later
-[sdist]
-formats = gztar,zip
-
-[metadata]
-name = python-musicpd
-description = An MPD (Music Player Daemon) client library written in pure Python.
-version = attr: musicpd.VERSION
-long_description =  file: README.rst
-long_description_content_type = text/x-rst
-license = LGPLv3
-license_file = LICENSE.txt
-author = Kaliko Jack
-author_email = kaliko@azylum.org
-url = https://kaliko.me/python-musicpd/
-download_url = https://pypi.org/project/python-musicpd/
-keywords = mpd, Music Player Daemon
-classifiers =
-    Development Status :: 5 - Production/Stable
-    Intended Audience :: Developers
-    License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
-    Natural Language :: English
-    Operating System :: OS Independent
-    Programming Language :: Python :: 3
-    Topic :: Software Development :: Libraries :: Python Modules
-
-[options]
-python_requires = >=3.6
-py_modules = musicpd
-
-[bdist_wheel]
-universal = 0
-
-[build_sphinx]
-source-dir = doc/source
-build-dir  = build
-all_files  = 1
-
-[pycodestyle]
-max_line_length = 88
 
+++ /dev/null
-#! /usr/bin/env python3
-# coding: utf-8
-# SPDX-FileCopyrightText: 2012-2021  kaliko <kaliko@azylum.org>
-# SPDX-License-Identifier: LGPL-3.0-or-later
-
-from setuptools import setup
-
-setup()
-
-# vim: set expandtab shiftwidth=4 softtabstop=4 textwidth=79: