Skip to content

Commit

Permalink
Merge pull request #114 from Crown-Commercial-Service/use-a-pyproject…
Browse files Browse the repository at this point in the history
…-toml

Use a pyproject.toml for the package and add pre-commit hook to check the pyproject.toml
  • Loading branch information
tim-s-ccs authored Nov 1, 2024
2 parents e63cfed + a488e52 commit 42fbcc8
Show file tree
Hide file tree
Showing 15 changed files with 77 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ ignore = D203,W503,W504
max-complexity = 12
max-line-length = 120
per-file-ignores =
app/__init__.py : E501
tests/utils/app.py : E501
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_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-digitalmarketplace-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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Records breaking changes from major version bumps.

## Unreleased

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

## 2.10.0

Upgrade Digital Marketplace Frontend to v1.3.1
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 @@ -94,6 +94,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 @@ -105,3 +110,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
34 changes: 34 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "ccs-digitalmarketplace-frontend-jinja"
dynamic = ["version"]
dependencies = [
'jinja2>3',
'ccs-govuk-frontend-jinja>=1.4,<2',
'ccs-digitalmarketplace-utils>=68.0.0',
]
requires-python = ">=3.10,<3.13"
authors = [
{name = "CCS Developers"},
]
description = "Jinja templates for Digital Marketplace apps."
readme = "README.md"
license = {file = "LICENSE"}

[project.urls]
Homepage = "https://github.com/Crown-Commercial-Service/ccs-digitalmarketplace-frontend-jinja"
Repository = "https://github.com/Crown-Commercial-Service/ccs-digitalmarketplace-frontend-jinja.git"
Issues = "https://github.com/Crown-Commercial-Service/ccs-digitalmarketplace-frontend-jinja/issues"
Changelog = "https://github.com/Crown-Commercial-Service/ccs-digitalmarketplace-frontend-jinja/CHANGELOG.md"

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

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

[tool.setuptools.package-data]
digitalmarketplace_frontend_jinja = ["**/*.html"]
7 changes: 4 additions & 3 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ botocore==1.34.142
# s3transfer
cachelib==0.13.0
# via flask-session
ccs-digitalmarketplace-apiclient==25.11.0
ccs-digitalmarketplace-apiclient==27.3.0
# via ccs-digitalmarketplace-utils
ccs-digitalmarketplace-utils==68.0.0
ccs-digitalmarketplace-utils==68.1.0
# via ccs-digitalmarketplace-frontend-jinja
ccs-govuk-frontend-jinja==1.3.0
ccs-govuk-frontend-jinja==1.4.0
# via ccs-digitalmarketplace-frontend-jinja
certifi==2024.7.4
# via requests
Expand All @@ -47,6 +47,7 @@ flake8==7.1.1
flask==3.0.3
# via
# -r requirements-dev.in
# ccs-digitalmarketplace-apiclient
# ccs-digitalmarketplace-utils
# flask-gzip
# flask-login
Expand Down
38 changes: 0 additions & 38 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 @@ -28,7 +28,7 @@ def create_app():
"digitalmarketplace_frontend_jinja": FileSystemLoader(
searchpath=os.path.join(
os.path.dirname(__file__),
"../digitalmarketplace_frontend_jinja/templates"
"../../digitalmarketplace_frontend_jinja/templates"
)
)
}
Expand Down
File renamed without changes.

0 comments on commit 42fbcc8

Please sign in to comment.