From add8a63901e9219f857280de1674c90996297482 Mon Sep 17 00:00:00 2001 From: Will Barton Date: Tue, 20 Dec 2022 10:11:52 -0500 Subject: [PATCH] Switch to pyproject.toml With [PEP 621 support added to setuptools](https://github.com/pypa/setuptools/pull/2970) last year, and with pip supporting editable installs as of 21.3, we can move to `pyproject.toml` and deprecate `setup.py`. The file remains for legacy pip support. This change also enables support for Wagtail 3.x by removing the `<3` version pin. This will result in the last release of TreeModelAdmin to support Wagtail < 4. Wagtail 4.x is not yet supported. The version is bumped to 1.5.0 for anticipated release to permit installing with Wagtail 3.x. --- .pre-commit-config.yaml | 7 ++-- pyproject.toml | 67 +++++++++++++++++++++++++++++--- setup.py | 42 +------------------- tox.ini | 17 ++++---- treemodeladmin/tests/settings.py | 33 +++++++++++++--- 5 files changed, 103 insertions(+), 63 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 595d33f..fb9f9d9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,11 +5,10 @@ repos: - id: black args: ["treemodeladmin", "setup.py", "--line-length=79"] exclude: migrations -- repo: https://gitlab.com/pycqa/flake8 - rev: 4.0.1 +- repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.0.188 hooks: - - id: flake8 - additional_dependencies: [flake8-bugbear==22.1.11] + - id: ruff - repo: https://github.com/pycqa/isort rev: 5.10.1 hooks: diff --git a/pyproject.toml b/pyproject.toml index 2d6007c..45008e2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,53 @@ +[project] +name = "wagtail-treemodeladmin" +version = "1.5.0" +description = "TreeModelAdmin for Wagtail" +readme = "README.md" +requires-python = ">=3.8" +license = {text = "CC0"} +authors = [ + {name = "CFPB", email = "tech@cfpb.gov" } +] +dependencies = [ + "wagtail>=2.15,<4", +] +classifiers = [ + "Framework :: Django", + "Framework :: Django :: 3.2", + "Framework :: Django :: 4", + "Framework :: Wagtail", + "Framework :: Wagtail :: 2", + "Framework :: Wagtail :: 3", + "License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication", + "License :: Public Domain", + "Programming Language :: Python", + "Programming Language :: Python :: 3", +] + +[project.optional-dependencies] +testing = [ + "coverage", +] + +[project.urls] +"Homepage" = "https://github.com/cfpb/wagtail-treemodeladmin" +"Bug Reports" = "https://github.com/cfpb/wagtail-treemodeladmin/issues" +"Source" = "https://github.com/cfpb/wagtail-treemodeladmin" + +[build-system] +requires = ["setuptools>=43.0.0", "wheel"] +build-backend = "setuptools.build_meta" + +[tool.setuptools.package-data] +treemodeladmin = [ + "templates/treemodeladmin/*", + "templates/treemodeladmin/includes/*", + "static/treemodeladmin/css/*", +] + [tool.black] line-length = 79 -target-version = ['py36', 'py38'] +target-version = ['py38'] include = '\.pyi?$' exclude = ''' ( @@ -14,8 +61,6 @@ exclude = ''' | dist | migrations | site - | \*.json - | \*.csv )/ ) ''' @@ -37,5 +82,17 @@ sections = [ "LOCALFOLDER" ] -[build-system] -requires = ["setuptools", "wheel"] +[tool.ruff] +exclude = [ + '.git', + '.tox', + '__pycache__', + '*/migrations/*.py', + '*/tests/treemodeladmintest/migrations/*', +] +ignore = [] +select = [ + 'E', + 'F', + 'W', +] diff --git a/setup.py b/setup.py index 2cf95e2..b024da8 100644 --- a/setup.py +++ b/setup.py @@ -1,42 +1,4 @@ -from setuptools import find_packages, setup +from setuptools import setup -install_requires = [ - "wagtail>=2.11,<3", -] -testing_extras = ["coverage>=3.7.0"] - -setup( - name="wagtail-treemodeladmin", - url="https://github.com/cfpb/wagtail-treemodeladmin", - author="CFPB", - author_email="tech@cfpb.gov", - description="TreeModelAdmin for Wagtail", - long_description=open("README.md", "r", encoding="utf-8").read(), - long_description_content_type="text/markdown", - license="CC0", - version="1.5.0", - include_package_data=True, - packages=find_packages(), - package_data={ - "treemodeladmin": [ - "templates/treemodeladmin/*", - "templates/treemodeladmin/includes/*", - "static/treemodeladmin/css/*", - ] - }, - python_requires=">=3.6", - install_requires=install_requires, - extras_require={"testing": testing_extras}, - classifiers=[ - "Framework :: Django", - "Framework :: Django :: 2.2", - "Framework :: Django :: 3.1", - "Framework :: Wagtail", - "Framework :: Wagtail :: 2", - "License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication", - "License :: Public Domain", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - ], -) +setup() diff --git a/tox.ini b/tox.ini index 91afd3f..038f051 100644 --- a/tox.ini +++ b/tox.ini @@ -2,8 +2,7 @@ skipsdist=True envlist= lint, - py{36,39}-dj{22}-wag{211,latest} - py{36,39}-dj{32}-wag{latest} + py{38,311}-dj{3,4}-wag{2,3,4,latest} [testenv] install_command=pip install -e ".[testing]" -U {opts} {packages} @@ -15,17 +14,19 @@ setenv= DJANGO_SETTINGS_MODULE=treemodeladmin.tests.settings basepython= - py36: python3.6 - py39: python3.9 + py38: python3.8 + py311: python3.11 deps= - dj22: Django>=2.2,<2.3 - dj32: Django>=3.2,<3.3 - wag211: wagtail>=2.11,<2.12 + dj3: Django>=3.2,<4 + dj4: Django>=4.1,<5 + wag2: wagtail>=2.15,<3 + wag3: wagtail>=3,<4 + wag4: wagtail>=4,<5 waglatest: wagtail<3 [testenv:lint] -basepython=python3.9 +basepython=python3.8 deps= black flake8 diff --git a/treemodeladmin/tests/settings.py b/treemodeladmin/tests/settings.py index 92524a7..8a5ac5e 100644 --- a/treemodeladmin/tests/settings.py +++ b/treemodeladmin/tests/settings.py @@ -1,5 +1,7 @@ import os +import wagtail + DEBUG = True @@ -26,19 +28,38 @@ "wagtail.contrib.forms", "wagtail.contrib.modeladmin", "wagtail.contrib.settings", - "wagtail.tests.testapp", "wagtail.admin", - "wagtail.core", "wagtail.documents", "wagtail.images", "wagtail.sites", "wagtail.users", ) -WAGTAILADMIN_RICH_TEXT_EDITORS = { - "default": {"WIDGET": "wagtail.admin.rich_text.DraftailRichTextArea"}, - "custom": {"WIDGET": "wagtail.tests.testapp.rich_text.CustomRichTextArea"}, -} +if wagtail.VERSION >= (3, 0): + WAGTAIL_APPS += ( + "wagtail", + "wagtail.test.testapp", + ) + + WAGTAILADMIN_RICH_TEXT_EDITORS = { + "default": {"WIDGET": "wagtail.admin.rich_text.DraftailRichTextArea"}, + "custom": { + "WIDGET": "wagtail.test.testapp.rich_text.CustomRichTextArea" + }, + } + +else: + WAGTAIL_APPS += ( + "wagtail.core", + "wagtail.tests.testapp", + ) + + WAGTAILADMIN_RICH_TEXT_EDITORS = { + "default": {"WIDGET": "wagtail.admin.rich_text.DraftailRichTextArea"}, + "custom": { + "WIDGET": "wagtail.tests.testapp.rich_text.CustomRichTextArea" + }, + } MIDDLEWARE = ( "django.middleware.common.CommonMiddleware",