From e402a41d6508ab38c21e99ad960332454c275196 Mon Sep 17 00:00:00 2001 From: Jack Rosenthal Date: Sat, 28 Sep 2024 20:58:41 -0600 Subject: [PATCH] Switch from setuptools to hatch --- .github/workflows/docs.yaml | 17 +++---- .github/workflows/lint.yaml | 23 --------- .github/workflows/unit-tests.yaml | 42 +++------------- docs/conf.py | 22 +++++---- kajiki/__init__.py | 1 - kajiki/version.py | 2 - pyproject.toml | 80 +++++++++++++++++++++++++++++++ release_new_version.py | 48 ------------------- setup.py | 76 ----------------------------- 9 files changed, 106 insertions(+), 205 deletions(-) delete mode 100644 .github/workflows/lint.yaml delete mode 100644 kajiki/version.py create mode 100644 pyproject.toml delete mode 100755 release_new_version.py delete mode 100755 setup.py diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 04c4c64..057f39b 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -5,16 +5,13 @@ jobs: name: Build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 - with: - python-version: "3.10" - architecture: x64 - - run: pip install -e ".[docs]" - - run: sphinx-build -a docs/ docs/_build/html + - uses: actions/checkout@v4 + - name: Install Hatch + uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc + - run: hatch run docs:build - run: touch docs/_build/html/.nojekyll - name: Upload Artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: htmldocs path: docs/_build/html @@ -24,9 +21,9 @@ jobs: if: "github.event_name == 'push' && github.ref == 'refs/heads/master'" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Download Artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: htmldocs path: html diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml deleted file mode 100644 index 60c43ac..0000000 --- a/.github/workflows/lint.yaml +++ /dev/null @@ -1,23 +0,0 @@ -name: Lint -on: [push, pull_request] -jobs: - lint: - name: "${{ matrix.tool.name }}" - runs-on: ubuntu-latest - strategy: - matrix: - tool: - - name: black - invocation: black --check --diff . - - name: flake8 - invocation: flake8 . - - name: isort - invocation: isort --check --diff . - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 - with: - python-version: "3.10" - architecture: x64 - - run: "pip install ${{ matrix.tool.name }}" - - run: "${{ matrix.tool.invocation }}" diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml index 5fd9c42..c9f116d 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -2,40 +2,10 @@ name: Unit Tests on: [push, pull_request] jobs: unit-tests: - name: "Python ${{ matrix.versions.python }}" - runs-on: "${{ matrix.versions.os }}" - strategy: - matrix: - versions: - - python: 3.4.10 - os: ubuntu-18.04 - - python: 3.5.10 - os: ubuntu-20.04 - - python: 3.6.15 - os: ubuntu-20.04 - - python: 3.7.12 - os: ubuntu-20.04 - - python: 3.8.12 - os: ubuntu-20.04 - - python: 3.9.12 - os: ubuntu-20.04 - - python: 3.10.4 - os: ubuntu-20.04 - - python: 3.11.0-alpha - 3.11.0 - os: ubuntu-20.04 - - python: pypy-3.6 - os: ubuntu-20.04 - - python: pypy-3.7 - os: ubuntu-20.04 - - python: pypy-3.8 - os: ubuntu-20.04 - - python: pypy-3.9 - os: ubuntu-20.04 + runs-on: "ubuntu-24.04" steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 - with: - python-version: "${{ matrix.versions.python }}" - architecture: x64 - - run: pip install -e ".[testing]" - - run: pytest -v + - uses: actions/checkout@v4 + - name: Install Hatch + uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc + - name: Run Tests + run: hatch test -a diff --git a/docs/conf.py b/docs/conf.py index 59b3557..2069d36 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -9,12 +9,10 @@ # All configuration values have a default; values that are commented out # serve to show the default. -from kajiki import version as _version +import site +import subprocess -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -# sys.path.append(os.path.abspath('..')) +site.addsitedir("..") # -- General configuration ----------------------------------------------------- @@ -51,11 +49,17 @@ # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. -# -# The short X.Y version. -version = _version.__version__ + # The full version, including alpha/beta/rc tags. -release = _version.__release__ +release = subprocess.run( + ["hatch", "version"], + check=True, + stdout=subprocess.PIPE, + encoding="utf-8", +).stdout.strip() + +# The short X.Y version. +version = ".".join(release.split(".", 2)[:-1]) # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/kajiki/__init__.py b/kajiki/__init__.py index 7874404..c596914 100644 --- a/kajiki/__init__.py +++ b/kajiki/__init__.py @@ -4,7 +4,6 @@ from .template import Template from .text import TextTemplate from .util import expose, flattener -from .version import __release__, __version__ from .xml_template import XMLTemplate __all__ = [ diff --git a/kajiki/version.py b/kajiki/version.py deleted file mode 100644 index d16ee77..0000000 --- a/kajiki/version.py +++ /dev/null @@ -1,2 +0,0 @@ -__version__ = "0.8" -__release__ = "0.9.3.dev1" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..94b24d6 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,80 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "kajiki" +version = "1.0.0.dev1" +description = "Fast XML-based template engine with Genshi syntax and Jinja blocks" +readme = "README.rst" +license = "MIT" +requires-python = ">=3.9" +authors = [ + { name = "Rick Copeland", email = "rick446@usa.net" }, + { name = "Nando Florestan", email = "nandoflorestan@gmail.com" }, + { name = "Alessandro Molina", email = "amol@turbogears.org" }, + { name = "Jack Rosenthal", email = "jack@rosenth.al" }, +] +maintainers = [ + { name = "Jack Rosenthal", email = "jack@rosenth.al" }, +] +keywords = [ + "chameleon", + "engine", + "genshi", + "html", + "jinja", + "jinja2", + "mako", + "template", + "templating", + "xhtml", + "xml", +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Web Environment", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Programming Language :: Python", + "Topic :: Internet :: WWW/HTTP :: Dynamic Content", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Text Processing :: Markup :: HTML", + "Topic :: Text Processing :: Markup :: XML", +] +dependencies = [ + "linetable", +] + +[project.urls] +Homepage = "https://github.com/jackrosenthal/kajiki" + +[tool.hatch.build.targets.sdist] +include = [ + "/kajiki", + "/tests", +] + +[[tool.hatch.envs.hatch-test.matrix]] +python = ["3.9", "3.10", "3.11", "3.12"] + +[tool.hatch.envs.default] +installer = "uv" +python = "3.12" + +[tool.hatch.envs.docs] +dependencies = [ + "sphinx", +] + +[tool.hatch.envs.docs.scripts] +build = "sphinx-build -M html docs docs/_build" diff --git a/release_new_version.py b/release_new_version.py deleted file mode 100755 index 5fe2784..0000000 --- a/release_new_version.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python - -"""Script that releases a new version of the software.""" - -from releaser import Releaser # easy_install -UZ releaser -from releaser.git_steps import * -from releaser.steps import * - -# These settings are used by multiple release steps below. -config = dict( - github_user="jackrosenthal", # TODO infer from .git/config - github_repository="kajiki", - branch="master", # Only release new versions in this git branch - changes_file="CHANGES.rst", - version_file="kajiki/version.py", # The version number is in this file - version_keyword="release", # Part of the variable name in that file - log_file="release.log.utf-8.tmp", - verbosity="info", # debug | info | warn | error -) - -# You can customize your release process below. -# Comment out any steps you don't desire and add your own steps. -Releaser( - config, - Shell("pytest"), # First of all ensure tests pass - # CheckRstFiles, # Documentation: recursively verify ALL .rst files, or: - # CheckRstFiles('CHANGES.rst', 'LICENSE.rst'), # just a few. - # TODO IMPLEMENT CompileAndVerifyTranslations, - # TODO IMPLEMENT BuildSphinxDocumentation, - # TODO IMPLEMENT Tell the user to upload the built docs (give URL) - EnsureGitClean, # There are no uncommitted changes in tracked files. - EnsureGitBranch, # I must be in the branch specified in config - InteractivelyEnsureChangesDocumented, # Did you update CHANGES.rst? - # ================= All checks pass. RELEASE! =========================== - SetVersionNumberInteractively, # Ask for version and write to source code - # TODO IMPLEMENT CHANGES file: add heading for current version (below dev) - GitCommitVersionNumber, - GitTag, # Locally tag the current commit with the new version number - InteractivelyApproveDistribution, # Generate sdist, let user verify it - InteractivelyApproveWheel, # Generate wheel, let user verify it - PypiUpload, # Make and upload a source .tar.gz to https://pypi.org - PypiUploadWheel, # Make and upload source wheel to https://pypi.org - # =========== Post-release: set development version and push ============ - SetFutureVersion, # Writes incremented version, now with 'dev' suffix - GitCommitVersionNumber("future_version", msg="Bump version to {0} after release"), - GitPush, # Cannot be undone. If successful, previous steps won't roll back - GitPushTags, -).release() diff --git a/setup.py b/setup.py deleted file mode 100755 index 719c23d..0000000 --- a/setup.py +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env python - -import os - -from setuptools import find_packages, setup - -# http://peak.telecommunity.com/DevCenter/setuptools#developer-s-guide - -# Get version info -__version__ = None -__release__ = None -exec(open("kajiki/version.py").read()) - - -def content_of(*files): - here = os.path.abspath(os.path.dirname(__file__)) - content = [] - for f in files: - with open(os.path.join(here, f)) as stream: - content.append(stream.read()) - return "\n".join(content) - - -setup( - name="kajiki", - version=__release__, - description="Fast XML-based template engine with Genshi syntax and " "Jinja blocks", - long_description=content_of("README.rst", "CHANGES.rst"), - classifiers=[ # http://pypi.python.org/pypi?:action=list_classifiers - "Development Status :: 5 - Production/Stable", - "Environment :: Web Environment", - "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", - "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", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy", - "Topic :: Internet :: WWW/HTTP :: Dynamic Content", - "Topic :: Software Development :: Libraries :: Python Modules", - "Topic :: Text Processing :: Markup :: HTML", - "Topic :: Text Processing :: Markup :: XML", - ], - keywords="templating engine template genshi jinja jinja2 mako " - "chameleon xml html xhtml", - author="Rick Copeland", - author_email="rick446@usa.net", - maintainer="Jack Rosenthal", - maintainer_email="jack@rosenth.al", - url="https://github.com/jackrosenthal/kajiki", - license="MIT", - packages=find_packages(exclude=["ez_setup", "examples", "tests"]), - include_package_data=True, - zip_safe=False, - python_requires=">=3.4", - install_requires=["linetable"], - extras_require={ - "testing": ["babel", "pytest"], - "docs": ["sphinx"], - }, - entry_points=""" - [console_scripts] - kajiki = kajiki.__main__:main - - [babel.extractors] - kajiki = kajiki.i18n:extract - """, -)