From d895f4a465f5bae37046cca6e8670958a729448c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Correa=20G=C3=B3mez?= Date: Thu, 22 Feb 2024 21:13:51 +0100 Subject: [PATCH] Migrate from setup.py to pyproject.toml (MR 2265) In the process, drop the list of required python packages. This is only needed for pip, as pmbootstrap checks by itself. This way we avoid duplicating the minimum required version. We also don't install the helpers anymore, as modern tooling does not support installing things outside the python package dir --- MANIFEST.in | 2 -- pyproject.toml | 30 ++++++++++++++++++++ setup.py | 76 -------------------------------------------------- 3 files changed, 30 insertions(+), 78 deletions(-) delete mode 100755 setup.py diff --git a/MANIFEST.in b/MANIFEST.in index 1931756a..0e481d1c 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,2 @@ include LICENSE -include helpers/envkernel.sh -include helpers/envkernel.fish recursive-include pmb/data * diff --git a/pyproject.toml b/pyproject.toml index 4f99e226..5e60f34f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,33 @@ +[build-system] +requires = ["setuptools>=61.0.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "pmbootstrap" +dynamic = ["version"] +authors = [ + {name = "postmarketOS Developers", email="info@postmarketos.org"} +] +description = "A sophisticated chroot / build / flash tool to develop and install postmarketOS'" +readme = "README.md" +license = {text = "GPL-3.0-or-later"} + +[project.scripts] +pmbootstrap = "pmb:main" + +[project.optional-dependencies] +test = ["pytest"] +completion = ["argcomplete"] + +[project.urls] +Homepage = "https://www.postmarketos.org" + +[tool.setuptools.dynamic] +version = {attr = "pmb.__version__"} + +[tool.setuptools.packages.find] +exclude = ["aports", "keys", "test", "test.pmb_test"] + [tool.ruff] # E402: module import not on top of file, not possible for testcases # E722: do not use bare except diff --git a/setup.py b/setup.py deleted file mode 100755 index 3ef5d593..00000000 --- a/setup.py +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env python3 - -import re -import ast -import sys - -from setuptools import setup, find_packages -from setuptools.command.test import test as TestCommand - -from codecs import open -from os import path - - -class PyTest(TestCommand): - user_options = [('pytest-args=', 'a', 'Arguments to pass to pytest')] - - def initialize_options(self): - TestCommand.initialize_options(self) - self.pytest_args = '' - - def run_tests(self): - import shlex - import pytest - errno = pytest.main(shlex.split(self.pytest_args)) - sys.exit(errno) - - -here = path.abspath(path.dirname(__file__)) -_version_re = re.compile(r'__version__\s+=\s+(.*)') - -with open(path.join(here, 'pmb/__init__.py'), 'rb') as f: - version = str(ast.literal_eval(_version_re.search( - f.read().decode('utf-8')).group(1))) - -with open(path.join(here, 'README.md'), encoding='utf-8') as f: - long_description = f.read() - - -setup( - name='pmbootstrap', - version=version, - description='A sophisticated chroot / build / flash tool to ' - 'develop and install postmarketOS', - long_description=long_description, - long_description_content_type='text/markdown', - author='postmarketOS Developers', - author_email='info@postmarketos.org', - url='https://www.postmarketos.org', - license='GPLv3', - python_requires='>=3.7', - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', - 'Programming Language :: Python :: 3', - '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', - ], - keywords='postmarketos pmbootstrap', - packages=find_packages(exclude=['aports', 'keys', 'test']), - tests_require=['pytest'], - cmdclass={'test': PyTest}, - extras_require={ - 'completion': ['argcomplete'], - }, - entry_points={ - 'console_scripts': [ - 'pmbootstrap=pmb:main', - ], - }, - include_package_data=True, - data_files=[('share/pmbootstrap/helpers/', ['helpers/envkernel.sh', 'helpers/envkernel.fish'])], -)