From 46e080e0eba3e3a5cd1aedaa39d6ee52785d4d0f Mon Sep 17 00:00:00 2001 From: Mark Bird Date: Thu, 26 Feb 2026 15:34:19 +0000 Subject: [PATCH] Modernise build tooling and configuration --- .github/workflows/pypi.yml | 30 ++++++------- .gitignore | 1 + pyproject.toml | 26 +++++++++++ setup.py | 90 -------------------------------------- zen_queries/__init__.py | 3 -- 5 files changed, 41 insertions(+), 109 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..0e62ebf 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -7,20 +7,18 @@ 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.13" + - name: Build distributions + run: | + python -m pip install --upgrade pip build + python -m build + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.gitignore b/.gitignore index aaa3a42..ec8a6db 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.pyc +__pycache__/ *.db .coverage MANIFEST diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..f988472 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,26 @@ +[build-system] +requires = ["setuptools>=77", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "django-zen-queries" +version = "2.1.0" +description = "Explicit control over query execution in Django applications." +readme = "README.md" +license = "BSD-3-Clause" +license-files = ["LICENSE"] +authors = [ + { name = "DabApps", email = "hello@dabapps.com" }, +] +requires-python = ">=3.10" +dependencies = [ + "Django>=3.2", +] + +[project.urls] +Homepage = "https://github.com/dabapps/django-zen-queries" +Changelog = "https://github.com/dabapps/django-zen-queries/releases" +Issues = "https://github.com/dabapps/django-zen-queries/issues" + +[tool.setuptools.packages.find] +include = ["zen_queries*"] diff --git a/setup.py b/setup.py deleted file mode 100644 index f96e58e..0000000 --- a/setup.py +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from __future__ import print_function -from setuptools import setup -import re -import os -import sys - - -name = "django-zen-queries" -package = "zen_queries" -description = "Explicit control over query execution in Django applications." -url = "https://github.com/dabapps/django-zen-queries" -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} - - -if sys.argv[-1] == "publish": - os.system("python setup.py sdist upload") - args = {"version": get_version(package)} - print("You probably want to also tag the version now:") - print(" git tag -a %(version)s -m 'version %(version)s'" % args) - print(" git push --tags") - sys.exit() - - -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=[ - "Django>=3.2", - ], - project_urls={ - "Changelog": "https://github.com/dabapps/django-zen-queries/releases", - "Issues": "https://github.com/dabapps/django-zen-queries/issues", - } -) diff --git a/zen_queries/__init__.py b/zen_queries/__init__.py index 9d46a49..2698e68 100644 --- a/zen_queries/__init__.py +++ b/zen_queries/__init__.py @@ -7,9 +7,6 @@ from zen_queries.template_response import SimpleTemplateResponse, TemplateResponse from zen_queries.utils import fetch -__version__ = "2.1.0" - - __all__ = [ "queries_disabled", "queries_dangerously_enabled",