Skip to content

Commit

Permalink
Use a pyproject.toml for the package and add pre-commit hook to check…
Browse files Browse the repository at this point in the history
… the pyproject.toml
  • Loading branch information
tim-s-ccs committed Nov 1, 2024
1 parent 27abbfb commit aa72153
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 74 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install build twine
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
python setup.py sdist bdist_wheel
python -m build
twine upload dist/*
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ jobs:

- name: Get package version
id: package_version
run: echo "python=$(python setup.py --version)" >> $GITHUB_OUTPUT
run: |
python -m pip install -e .
echo "python=$(python -c 'import importlib.metadata; print(importlib.metadata.version("ccs-govuk-frontend-jinja"))')" >> $GITHUB_OUTPUT
- name: Check if version tag already exists
id: version_tag
Expand Down
36 changes: 19 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: d6d3bd94604578adbd918c5a00d531d98350d86f # v2.3.0
hooks:
- id: detect-private-key
- repo: https://github.com/Yelp/detect-secrets
rev: a3e7998bfa4924b13df3f9cb49070abdbdff8802 # v0.13.1
hooks:
- id: detect-secrets
args: ['--baseline', '.secrets.baseline']
exclude: .*/keys/.*|
(?x)(
^package-lock.json$/|
^Pipfile/|
^pyproject.toml
)
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: detect-private-key

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.22
hooks:
- id: validate-pyproject

- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/tim-s-ccs/ccs-govuk-frontend-jinja/compare/1.2.2...main)
## [Unreleased](https://github.com/tim-s-ccs/ccs-govuk-frontend-jinja/compare/1.3.0...main)

### Changed

- Replace `setup.py` with `pyproject.toml`

## [1.3.0](https://github.com/tim-s-ccs/ccs-govuk-frontend-jinja/releases/tag/1.3.0) - 14/10/2024

Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
prune tests
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ To make a new version:

When the pull request is merged a GitHub Action will tag the new version.

## Pre-commit hooks

This project has a [pre-commit hook][pre-commit hook] to do some general file checks and check the `pyproject.toml`.
Follow the [Quick start][pre-commit quick start] to see how to set this up in your local checkout of this project.

## Licence

Unless stated otherwise, the codebase is released under [the MIT License][mit].
Expand All @@ -110,3 +115,6 @@ of the [Open Government 3.0][ogl] licence.
[mit]: LICENCE
[copyright]: http://www.nationalarchives.gov.uk/information-management/re-using-public-sector-information/uk-government-licensing-framework/crown-copyright/
[ogl]: http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/

[pre-commit hook]: https://pre-commit.com/
[pre-commit quick start]: https://pre-commit.com/#quick-start
33 changes: 33 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "ccs-govuk-frontend-jinja"
dynamic = ["version"]
dependencies = [
'jinja2>=3.0.2',
]
requires-python = ">=3.10,<3.13"
authors = [
{name = "HM Land Registry Developers"},
{name = "CCS Developers"},
]
description = "GOV.UK Frontend Jinja Macros"
readme = "README.md"
license = {file = "LICENSE"}

[project.urls]
Homepage = "https://github.com/tim-s-ccs/ccs-govuk-frontend-jinja"
Repository = "https://github.com/tim-s-ccs/ccs-govuk-frontend-jinja.git"
Issues = "https://github.com/tim-s-ccs/ccs-govuk-frontend-jinja/issues"
Changelog = "https://github.com/tim-s-ccs/ccs-govuk-frontend-jinja/CHANGELOG.md"

[tool.setuptools.dynamic]
version = {attr = "govuk_frontend_jinja.__version__"}

[tool.setuptools.packages.find]
exclude = ["node_modules*"]

[tool.setuptools.package-data]
govuk_frontend_jinja = ["**/*.html"]
50 changes: 0 additions & 50 deletions setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

@task(ns["virtualenv"], ns["requirements_dev"])
def test_mypy(c):
c.run("mypy app/")
c.run("mypy tests/utils/")


ns.add_task(npm_install)
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from app import create_app
from utils.app import create_app


@pytest.fixture
Expand Down
Empty file added tests/utils/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion app/__init__.py → tests/utils/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def create_app():
"govuk_frontend_jinja": FileSystemLoader(
searchpath=os.path.join(
os.path.dirname(__file__),
"../govuk_frontend_jinja/templates"
"../../govuk_frontend_jinja/templates"
)
)
}
Expand Down

0 comments on commit aa72153

Please sign in to comment.