From 12fa55cf522c3e013a609d01680f184875cdd52e Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Sun, 23 Oct 2022 23:22:18 -0400 Subject: [PATCH 1/3] Update package metadata --- .flake8 | 4 ++ .github/workflows/release.yml | 8 ++-- .github/workflows/test.yml | 10 ++--- MANIFEST.in | 6 --- docs/contributing.rst | 8 ++-- pyproject.toml | 74 +++++++++++++++++++++++++++++++++++ requirements_dev.txt | 3 +- setup.cfg | 72 ---------------------------------- setup.py | 6 ++- tox.ini | 8 ++-- 10 files changed, 101 insertions(+), 98 deletions(-) create mode 100644 .flake8 delete mode 100644 MANIFEST.in create mode 100644 pyproject.toml delete mode 100644 setup.cfg 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..c770d87a2 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 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..61b0dc146 100755 --- a/setup.py +++ b/setup.py @@ -1,5 +1,9 @@ #!/usr/bin/env python3 +# 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 from setuptools import setup -setup() +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] From 1cf55d9ec0b2de3f0296ad608a923d780aea83c1 Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Mon, 24 Oct 2022 10:27:02 -0400 Subject: [PATCH 2/3] Update setup.py --- setup.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 61b0dc146..de31ca34f 100755 --- a/setup.py +++ b/setup.py @@ -1,9 +1,23 @@ #!/usr/bin/env python3 + +import sys + +from setuptools import 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 -from setuptools import setup - setup(name="django-debug-toolbar") From 742e9101fadbeee19add04870b1246f800fc677a Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Wed, 2 Nov 2022 15:27:11 -0400 Subject: [PATCH 3/3] Update contributing.rst --- docs/contributing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/contributing.rst b/docs/contributing.rst index c770d87a2..e66e98f4c 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -172,7 +172,7 @@ The release itself requires the following steps: #. Tag the new version. -#. ``tox packaging``. +#. ``tox -e packaging``. #. Push the commit and the tag.