diff --git a/.flake8 b/.flake8 new file mode 100644 index 000000000..7d44b7eca --- /dev/null +++ b/.flake8 @@ -0,0 +1,4 @@ +# TODO: move this to pyproject.toml when supported, see https://github.com/PyCQA/flake8/issues/234 + +[flake8] +extend-ignore = E203, E501 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 906d6846b..fd60d001d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,17 +23,17 @@ jobs: - name: Install dependencies run: | python -m pip install -U pip - python -m pip install -U setuptools twine wheel + python -m pip install -U build hatchling - name: Build package run: | - python setup.py --version - python setup.py sdist --format=gztar bdist_wheel + hatchling version + python -m build twine check dist/* - name: Upload packages to Jazzband if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@master + uses: pypa/gh-action-pypi-publish@release/v1 with: user: jazzband password: ${{ secrets.JAZZBAND_RELEASE_KEY }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7dd8409a8..bc40badda 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -47,7 +47,7 @@ jobs: with: path: ${{ steps.pip-cache.outputs.dir }} key: - ${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.cfg') }}-${{ hashFiles('**/tox.ini') }} + ${{ matrix.python-version }}-v1-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('**/tox.ini') }} restore-keys: | ${{ matrix.python-version }}-v1- @@ -118,7 +118,7 @@ jobs: with: path: ${{ steps.pip-cache.outputs.dir }} key: - ${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.cfg') }}-${{ hashFiles('**/tox.ini') }} + ${{ matrix.python-version }}-v1-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('**/tox.ini') }} restore-keys: | ${{ matrix.python-version }}-v1- @@ -171,7 +171,7 @@ jobs: with: path: ${{ steps.pip-cache.outputs.dir }} key: - ${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.cfg') }}-${{ hashFiles('**/tox.ini') }} + ${{ matrix.python-version }}-v1-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('**/tox.ini') }} restore-keys: | ${{ matrix.python-version }}-v1- @@ -203,7 +203,7 @@ jobs: # Use latest, so it understands all syntax. python-version: "3.10" - - run: python -m pip install --upgrade coverage + - run: python -m pip install --upgrade coverage[toml] - name: Download coverage data. uses: actions/download-artifact@v3 @@ -246,7 +246,7 @@ jobs: with: path: ${{ steps.pip-cache.outputs.dir }} key: - ${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.cfg') }}-${{ hashFiles('**/tox.ini') }} + ${{ matrix.python-version }}-v1-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('**/tox.ini') }} restore-keys: | ${{ matrix.python-version }}-v1- diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index e3d4782fc..000000000 --- a/MANIFEST.in +++ /dev/null @@ -1,6 +0,0 @@ -include LICENSE -include README.rst -include CONTRIBUTING.md -recursive-include debug_toolbar/locale * -recursive-include debug_toolbar/static * -recursive-include debug_toolbar/templates * diff --git a/docs/contributing.rst b/docs/contributing.rst index eea9dfa8f..e66e98f4c 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -152,8 +152,8 @@ The release itself requires the following steps: #. Update supported Python and Django versions: - - ``setup.cfg`` ``python_requires`` and ``install_requires`` options - - ``setup.cfg`` trove classifiers + - ``pyproject.toml`` options ``requires-python``, ``dependencies``, + and ``classifiers`` - ``README.rst`` Commit. @@ -167,12 +167,12 @@ The release itself requires the following steps: Commit. #. Bump version numbers in ``docs/changes.rst``, ``docs/conf.py``, - ``README.rst``, ``debug_toolbar/__init__.py`` and ``setup.cfg``. + ``README.rst``, and ``debug_toolbar/__init__.py``. Add the release date to ``docs/changes.rst``. Commit. #. Tag the new version. -#. ``python setup.py sdist bdist_wheel upload``. +#. ``tox -e packaging``. #. Push the commit and the tag. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..42f3c1b64 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,74 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "django-debug-toolbar" +dynamic = ["version"] +description = "A configurable set of panels that display various debug information about the current request/response." +readme = "README.rst" +license = "BSD-3-Clause" +requires-python = ">=3.7" +authors = [ + { name = "Rob Hudson", email = "rob@cogit8.org" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Web Environment", + "Framework :: Django", + "Framework :: Django :: 3.2", + "Framework :: Django :: 4.0", + "Framework :: Django :: 4.1", + "Intended Audience :: Developers", + "License :: OSI Approved :: BSD License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Topic :: Software Development :: Libraries :: Python Modules", +] +dependencies = [ + "Django >= 3.2.4", + "sqlparse >= 0.2.0", +] + +[project.urls] +Download = "https://pypi.org/project/django-debug-toolbar/" +Homepage = "https://github.com/jazzband/django-debug-toolbar" + +[tool.hatch.version] +path = "debug_toolbar/__init__.py" + +[tool.hatch.build.targets.wheel] +packages = ["debug_toolbar"] + +[tool.hatch.build.targets.sdist] +include = [ + "/debug_toolbar", + "/CONTRIBUTING.md", +] + +[tool.isort] +combine_as_imports = true +profile = "black" + +[tool.coverage.run] +branch = true +parallel = true +source = ["debug_toolbar"] + +[tool.coverage.paths] +source = ["src", ".tox/*/site-packages"] + +[tool.coverage.report] +# Update coverage badge link in README.rst when fail_under changes +fail_under = 93 +show_missing = true + +[tool.coverage.html] +skip_covered = true +skip_empty = true diff --git a/requirements_dev.txt b/requirements_dev.txt index fd82925d9..ade334aba 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -6,7 +6,7 @@ Jinja2 # Testing -coverage +coverage[toml] flake8 html5lib isort @@ -23,4 +23,3 @@ sphinxcontrib-spelling pre-commit transifex-client -wheel diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 1c3c105d5..000000000 --- a/setup.cfg +++ /dev/null @@ -1,72 +0,0 @@ -[metadata] -name = django-debug-toolbar -version = 3.7.0 -description = A configurable set of panels that display various debug information about the current request/response. -long_description = file: README.rst -long_description_content_type = text/x-rst -author = Rob Hudson -author_email = rob@cogit8.org -url = https://github.com/jazzband/django-debug-toolbar -download_url = https://pypi.org/project/django-debug-toolbar/ -license = BSD -license_files = LICENSE -classifiers = - Development Status :: 5 - Production/Stable - Environment :: Web Environment - Framework :: Django - Framework :: Django :: 3.2 - Framework :: Django :: 4.0 - Framework :: Django :: 4.1 - Intended Audience :: Developers - License :: OSI Approved :: BSD License - Operating System :: OS Independent - Programming Language :: Python - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Topic :: Software Development :: Libraries :: Python Modules - -[options] -python_requires = >=3.7 -install_requires = - Django >= 3.2.4 - sqlparse >= 0.2.0 -packages = find: -include_package_data = true -zip_safe = false - -[options.packages.find] -exclude = - example - tests - tests.* - - -[coverage.html] -skip_covered = True -skip_empty = True - -[coverage:run] -branch = True -parallel = True -source = debug_toolbar - -[coverage:paths] -source = - src - .tox/*/site-packages - -[coverage:report] -# Update coverage badge link in README.rst when fail_under changes -fail_under = 93 -show_missing = True - -[flake8] -extend-ignore = E203, E501 - -[isort] -combine_as_imports = true -profile = black diff --git a/setup.py b/setup.py index 229b2ebbb..de31ca34f 100755 --- a/setup.py +++ b/setup.py @@ -1,5 +1,23 @@ #!/usr/bin/env python3 +import sys + from setuptools import setup -setup() +sys.stderr.write( + """\ +=============================== +Unsupported installation method +=============================== +This project no longer supports installation with `python setup.py install`. +Please use `python -m pip install .` instead. +""" +) +sys.exit(1) + +# The code below will never execute, however is required to +# display the "Used by" section on the GitHub repository. +# +# See: https://github.com/github/feedback/discussions/6456 + +setup(name="django-debug-toolbar") diff --git a/tox.ini b/tox.ini index ad2e6c090..b32f82fea 100644 --- a/tox.ini +++ b/tox.ini @@ -1,4 +1,5 @@ [tox] +isolated_build = true envlist = docs packaging @@ -14,7 +15,7 @@ deps = postgis: psycopg2-binary mysql: mysqlclient djmain: https://github.com/django/django/archive/main.tar.gz - coverage + coverage[toml] Jinja2 html5lib pygments @@ -76,12 +77,11 @@ deps = [testenv:packaging] commands = - python setup.py sdist bdist_wheel + python -m build twine check --strict dist/* deps = - readme_renderer + build twine - wheel skip_install = true [gh-actions]