From 7f70b81f5da62a631b2093f26cf91a5949b24c34 Mon Sep 17 00:00:00 2001 From: Mark Bird Date: Thu, 26 Feb 2026 16:55:32 +0000 Subject: [PATCH] Modernise build tooling and configuration --- .github/workflows/pypi.yml | 32 ++++++------- .gitignore | 1 + django_readers_debug/__init__.py | 2 - pyproject.toml | 25 ++++++++++ setup.py | 81 -------------------------------- 5 files changed, 42 insertions(+), 99 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index fd2d1c3..fae93cb 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -7,20 +7,20 @@ on: jobs: deploy: runs-on: ubuntu-latest + permissions: + contents: read + id-token: write steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.8' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - python setup.py sdist bdist_wheel - twine upload dist/* + - uses: actions/checkout@v6 + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: "3.12" + - name: Install build dependencies + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade build + - name: Build package + run: python -m build + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.gitignore b/.gitignore index aaa3a42..62df274 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +__pycache__/ *.pyc *.db .coverage diff --git a/django_readers_debug/__init__.py b/django_readers_debug/__init__.py index c4c4b2e..52278b7 100644 --- a/django_readers_debug/__init__.py +++ b/django_readers_debug/__init__.py @@ -3,8 +3,6 @@ import black import inspect -__version__ = "0.0.4" - def safe_repr(item): if isinstance(item, str): diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..fd30930 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,25 @@ +[build-system] +requires = ["setuptools>=77"] +build-backend = "setuptools.build_meta" + +[project] +name = "django-readers-debug" +version = "0.0.4" +description = "A pretty-printer for debugging django-readers queryset functions" +readme = "README.md" +requires-python = ">=3.10" +license = "BSD-3-Clause" +license-files = ["LICENSE"] +authors = [{ name = "DabApps", email = "hello@dabapps.com" }] +dependencies = [ + "black", + "django-readers", +] + +[project.urls] +Homepage = "https://github.com/dabapps/django-readers-debug" +Changelog = "https://github.com/dabapps/django-readers-debug/releases" +Issues = "https://github.com/dabapps/django-readers-debug/issues" + +[tool.setuptools.packages.find] +include = ["django_readers_debug*"] diff --git a/setup.py b/setup.py deleted file mode 100644 index a47e32c..0000000 --- a/setup.py +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from __future__ import print_function -from setuptools import setup -import re -import os - - -name = "django-readers-debug" -package = "django_readers_debug" -description = "A pretty-printer for debugging django-readers queryset functions" -url = "https://github.com/dabapps/django-readers-debug" -author = "DabApps" -author_email = "hello@dabapps.com" -license = "BSD" - -with open("README.md") as f: - readme = f.read() - - -def get_version(package): - """ - Return package version as listed in `__version__` in `init.py`. - """ - init_py = open(os.path.join(package, "__init__.py")).read() - return re.search("^__version__ = ['\"]([^'\"]+)['\"]", init_py, re.MULTILINE).group( - 1 - ) - - -def get_packages(package): - """ - Return root package and all sub-packages. - """ - return [ - dirpath - for dirpath, dirnames, filenames in os.walk(package) - if os.path.exists(os.path.join(dirpath, "__init__.py")) - ] - - -def get_package_data(package): - """ - Return all files under the root package, that are not in a - package themselves. - """ - walk = [ - (dirpath.replace(package + os.sep, "", 1), filenames) - for dirpath, dirnames, filenames in os.walk(package) - if not os.path.exists(os.path.join(dirpath, "__init__.py")) - ] - - filepaths = [] - for base, filenames in walk: - filepaths.extend([os.path.join(base, filename) for filename in filenames]) - return {package: filepaths} - - -setup( - name=name, - version=get_version(package), - url=url, - license=license, - description=description, - long_description=readme, - long_description_content_type="text/markdown", - author=author, - author_email=author_email, - packages=get_packages(package), - package_data=get_package_data(package), - python_requires=">=3.6", - install_requires=[ - "black", - "django-readers", - ], - project_urls={ - "Changelog": "https://github.com/dabapps/django-readers-debug/releases", - "Issues": "https://github.com/dabapps/django-readers-debug/issues", - } -)