From a1430c0e41382afcbccc89cbb35e62c9b0de03d2 Mon Sep 17 00:00:00 2001 From: Dulmandakh Date: Tue, 20 Aug 2024 23:04:13 +0800 Subject: [PATCH 1/2] modernize packaging using pyproject.toml --- .github/workflows/release.yml | 8 ++-- pyproject.toml | 80 +++++++++++++++++++++++++++-------- setup.cfg | 2 - setup.py | 38 ----------------- 4 files changed, 66 insertions(+), 62 deletions(-) delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a68e39e80..3fb485840 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,19 +32,17 @@ jobs: uses: actions/cache@v2 with: path: ${{ steps.pip-cache.outputs.dir }} - key: release-${{ hashFiles('**/setup.py') }} + key: release-${{ hashFiles('**/pyproject.toml') }} restore-keys: | release- - name: Install dependencies run: | - python -m pip install -U pip - python -m pip install -U setuptools twine wheel + python -m pip install -U pip build twine - name: Build package run: | - python setup.py --version - python setup.py sdist --format=gztar bdist_wheel + python -m build twine check dist/* - name: Upload packages to Jazzband diff --git a/pyproject.toml b/pyproject.toml index 807ec1784..5aa0c4b5d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,23 +1,69 @@ -[tool.coverage.run] -source = ["sorl"] -omit = [ - "*/sorl-thumbnail/sorl/__init__.py", - "*/sorl/thumbnail/__init__.py", - "*/sorl/thumbnail/conf/__init__.py", - "*/sorl/thumbnail/admin/__init__.py", -] +[build-system] +requires = ["setuptools>=64", "setuptools_scm>=8"] +build-backend = "setuptools.build_meta" -[tool.coverage.report] -exclude_lines = [ - "pragma: no cover", - "if __name__ == .__main__.:", +[project] +name = "sorl-thumbnail" +dynamic = ["version"] +description = "Thumbnails for Django" +readme = "README.rst" +license = {file = "LICENSE"} +keywords = ["django", "thumbnail", "sorl"] +authors = [ + {name = "Mikko Hellsing", email = "mikko@aino.se"}, +] +maintainers = [ + {name = "Jazzband", email = "roadies@jazzband.co"} ] +requires-python = ">= 3.8" +classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Environment :: Web Environment', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: BSD License', + 'Operating System :: OS Independent', + 'Programming Language :: Python', + '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', + 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', + 'Topic :: Multimedia :: Graphics', + 'Framework :: Django', + 'Framework :: Django :: 4.2', + 'Framework :: Django :: 5.0', + 'Framework :: Django :: 5.1', +] + +[project.urls] +Homepage = "https://sorl-thumbnail.readthedocs.io/en/latest/" +Repository = "https://github.com/jazzband/sorl-thumbnail" + + +[tool.coverage.run] + source = ["sorl"] + omit = [ + "*/sorl-thumbnail/sorl/__init__.py", + "*/sorl/thumbnail/__init__.py", + "*/sorl/thumbnail/conf/__init__.py", + "*/sorl/thumbnail/admin/__init__.py", + ] + + [tool.coverage.report] + exclude_lines = [ + "pragma: no cover", + "if __name__ == .__main__.:", + ] + + [tool.pytest.ini_options] + python_files = ["test_*.py", "*tests.py"] + norecursedirs =[".*", "tmp*", "__pycache__"] + testpaths = ["tests"] + django_find_project = false -[tool.pytest.ini_options] -python_files = ["test_*.py", "*tests.py"] -norecursedirs =[".*", "tmp*", "__pycache__"] -testpaths = ["tests"] -django_find_project = false +# below line is required to generating versions with setuptools_scm +[tool.setuptools_scm] [tool.ruff] exclude = [ diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 526aeb281..000000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[bdist_wheel] -universal = 0 diff --git a/setup.py b/setup.py deleted file mode 100644 index 548cfa96a..000000000 --- a/setup.py +++ /dev/null @@ -1,38 +0,0 @@ -from setuptools import find_packages, setup - -setup( - name='sorl-thumbnail', - use_scm_version=True, - description='Thumbnails for Django', - long_description=open('README.rst').read(), - author="Mikko Hellsing", - author_email='mikko@aino.se', - maintainer="Jazzband", - maintainer_email="roadies@jazzband.co", - license="BSD", - url='https://github.com/jazzband/sorl-thumbnail', - packages=find_packages(exclude=['tests', 'tests.*']), - platforms='any', - python_requires='>=3.8', - zip_safe=False, - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Environment :: Web Environment', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: BSD License', - 'Operating System :: OS Independent', - 'Programming Language :: Python', - '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', - 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', - 'Topic :: Multimedia :: Graphics', - 'Framework :: Django', - 'Framework :: Django :: 4.2', - 'Framework :: Django :: 5.0', - 'Framework :: Django :: 5.1', - ], - setup_requires=['setuptools_scm'], -) From 6184f1e6de58c69fe7ab0251ff8b874a84c3ad0d Mon Sep 17 00:00:00 2001 From: Dulmandakh Date: Tue, 20 Aug 2024 23:08:13 +0800 Subject: [PATCH 2/2] coverage won't read setup.cfg --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 3d03c7abc..a04cbf781 100644 --- a/tox.ini +++ b/tox.ini @@ -53,7 +53,7 @@ setenv = pgmagick: DJANGO_SETTINGS_MODULE=tests.settings.pgmagick dbm: DJANGO_SETTINGS_MODULE=tests.settings.dbm commands = - python -m pytest -rw --cov-append --cov-config setup.cfg --cov sorl --cov-report=xml {posargs:} + python -m pytest -rw --cov-append --cov sorl --cov-report=xml {posargs:} [testenv:py38-qa] skip_install = True