From 5c231404a36d1c98f99ecf6105a2ab9c5ba3488a Mon Sep 17 00:00:00 2001 From: Yegor Yefremov Date: Fri, 23 Oct 2026 09:53:51 +0200 Subject: [PATCH] Convert setup.py to pyproject.toml Move the package metadata to a PEP 621 pyproject.toml, built with the setuptools PEP 517 backend, and drop setup.py. This also removes the setuptools_scm handling: the version is already hardcoded, and the use_scm_version fallback breaks the build with setuptools_scm >= 8.0 whenever setuptools_scm is installed. The license is declared as the SPDX expression Apache-2.0 (PEP 639), which requires setuptools >= 77. Only install the remi and editor packages: find_packages() also installed the tests as a top-level "test" package, which shadows the standard library one. The tests are still shipped in the sdist through MANIFEST.in. Update the version consistency test, the comment next to _FALLBACK_VERSION and the installation instructions accordingly. Fixes #541 Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Yegor Yefremov --- MANIFEST.in | 1 + README.md | 2 +- pyproject.toml | 23 +++++++++++++++++++++++ remi/__init__.py | 2 +- setup.py | 31 ------------------------------- test/test_version.py | 24 ++++++++++++------------ 6 files changed, 38 insertions(+), 45 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/MANIFEST.in b/MANIFEST.in index aec9cb12..036259a7 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,3 +2,4 @@ include remi/res/* include editor/* include editor/res/* include LICENSE +recursive-include test *.py diff --git a/README.md b/README.md index 672d7d75..720789bb 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ pip install remi For the most updated **experimental** version [Download](https://github.com/rawpython/remi/archive/master.zip) or check out Remi from git and install ``` -python setup.py install +pip install . ``` or install directly using pip diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..fda5179e --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,23 @@ +[build-system] +requires = ["setuptools>=77"] +build-backend = "setuptools.build_meta" + +[project] +name = "remi" +# Keep in sync with _FALLBACK_VERSION in remi/__init__.py. +version = "2026.03.24" +description = "Python REMote Interface library" +readme = "README.md" +license = "Apache-2.0" +license-files = ["LICENSE"] +authors = [ + { name = "Davide Rosa", email = "dddomodossola@gmail.com" }, +] +keywords = ["gui-library", "remi", "platform-independent", "ui", "gui"] + +[project.urls] +Homepage = "https://github.com/rawpython/remi" +Download = "https://github.com/rawpython/remi/archive/master.zip" + +[tool.setuptools.packages.find] +include = ["remi*", "editor*"] diff --git a/remi/__init__.py b/remi/__init__.py index 76563717..730ba925 100644 --- a/remi/__init__.py +++ b/remi/__init__.py @@ -34,7 +34,7 @@ # Hardcoded fallback version — used when package metadata is unavailable # (e.g. PyInstaller frozen builds, editable installs without metadata). -# Keep in sync with setup.py. +# Keep in sync with pyproject.toml. _FALLBACK_VERSION = "2026.03.24" __version__ = _FALLBACK_VERSION diff --git a/setup.py b/setup.py deleted file mode 100644 index 263e7aee..00000000 --- a/setup.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -import setuptools -from setuptools import setup - -with open("README.md", "r") as fh: - long_description = fh.read() - -params = { - 'name':"remi", - 'description':"Python REMote Interface library", - 'use_scm_version':{'version_scheme': 'post-release'}, - 'long_description':long_description, - 'long_description_content_type':"text/markdown", - 'url':"https://github.com/rawpython/remi", - 'download_url':"https://github.com/rawpython/remi/archive/master.zip", - 'keywords':["gui-library", "remi", "platform-independent", "ui", "gui"], - 'author':"Davide Rosa", - 'author_email':"dddomodossola@gmail.com", - 'license':"Apache", - 'packages':setuptools.find_packages(), - 'include_package_data':True, - 'setup_requires':['setuptools_scm'], - 'version': '2026.03.24', -} -try: - setup(**params) -except: - del params['setup_requires'] - params['use_scm_version'] = False - setup(**params) diff --git a/test/test_version.py b/test/test_version.py index b91cf5b2..650f9c07 100644 --- a/test/test_version.py +++ b/test/test_version.py @@ -97,22 +97,22 @@ def test_hardcoded_fallback_used(self): # Restore importlib.reload(remi) - def test_fallback_version_matches_setup(self): - """_FALLBACK_VERSION in __init__.py must match the version in setup.py.""" - setup_py = os.path.join(os.path.dirname(__file__), '..', 'setup.py') - setup_py = os.path.normpath(setup_py) - with open(setup_py) as f: + def test_fallback_version_matches_pyproject(self): + """_FALLBACK_VERSION in __init__.py must match the version in pyproject.toml.""" + pyproject = os.path.join(os.path.dirname(__file__), '..', 'pyproject.toml') + pyproject = os.path.normpath(pyproject) + with open(pyproject) as f: content = f.read() - # Extract the version string from setup.py: 'version': '...' + # Extract the version string from pyproject.toml: version = "..." import re - match = re.search(r"'version'\s*:\s*'([^']+)'", content) - self.assertIsNotNone(match, "Could not find 'version' in setup.py") - setup_version = match.group(1) + match = re.search(r'^version\s*=\s*"([^"]+)"', content, re.MULTILINE) + self.assertIsNotNone(match, "Could not find 'version' in pyproject.toml") + pyproject_version = match.group(1) self.assertEqual( remi._FALLBACK_VERSION, - setup_version, - "_FALLBACK_VERSION in __init__.py (%s) does not match setup.py (%s)" - % (remi._FALLBACK_VERSION, setup_version), + pyproject_version, + "_FALLBACK_VERSION in __init__.py (%s) does not match pyproject.toml (%s)" + % (remi._FALLBACK_VERSION, pyproject_version), )