From 809156bb35852bcaa1c753e0165f1814f2bcedf6 Mon Sep 17 00:00:00 2001 From: Bartek Sokorski Date: Fri, 6 Jan 2023 20:43:48 +0100 Subject: [PATCH 1/2] Move to PEP 621 declarative metadata --- .github/workflows/release.yml | 3 ++- pyproject.toml | 35 +++++++++++++++++++++++++++++++- setup.py | 33 ------------------------------ src/trove_classifiers/version.py | 1 + 4 files changed, 37 insertions(+), 35 deletions(-) delete mode 100644 setup.py create mode 100644 src/trove_classifiers/version.py diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b11e366..d6b68a7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,7 +32,8 @@ jobs: password: ${{ secrets.pypi_password }} - name: Version id: version - run: echo "::set-output name=version::$(python setup.py --version 2>/dev/null)" + run: | + echo version=$(python -c "from trove_classifiers import version; print(version.__version__)" 2>/dev/null) >> $GITHUB_OUTPUT - name: Tag uses: actions/create-release@v1 env: diff --git a/pyproject.toml b/pyproject.toml index 672fc13..23542a4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,40 @@ [build-system] -requires = ["setuptools", "calver"] +requires = ["setuptools >= 61.0"] build-backend = "setuptools.build_meta" +[project] +name = "trove-classifiers" +readme = "README.md" +description = "Canonical source for classifiers on PyPI (pypi.org)." +authors = [{name = "The PyPI Admins", email = "admin@pypi.org"}] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python :: 3", + "Typing :: Typed", +] +keywords = ["classifiers"] +dynamic = ["version"] + +[project.urls] +Homepage = "https://github.com/pypa/trove-classifiers" + +[tool.setuptools] +package-dir = {"" = "src"} +include-package-data = false + +[tool.setuptools.packages.find] +where = ["src"] +namespaces = false + +[tool.setuptools.package-data] +"*" = ["py.typed"] + +[tool.setuptools.dynamic.version] +attr = "trove_classifiers.version.__version__" + + [mypy] strict = true warn_unreachable = true diff --git a/setup.py b/setup.py deleted file mode 100644 index 826eac7..0000000 --- a/setup.py +++ /dev/null @@ -1,33 +0,0 @@ -from io import open -from os import path - -from setuptools import setup, find_packages - -here = path.abspath(path.dirname(__file__)) - -# Get the long description from the README file -with open(path.join(here, "README.md"), encoding="utf-8") as f: - long_description = f.read() - -setup( - name="trove-classifiers", - description="Canonical source for classifiers on PyPI (pypi.org).", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/pypa/trove-classifiers", - author="The PyPI Admins", - author_email="admin@pypi.org", - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python :: 3", - "Typing :: Typed", - ], - keywords="classifiers", - package_dir={"": "src"}, - packages=find_packages(where="src"), - package_data={"": ["py.typed"]}, - use_calver=True, - setup_requires=["calver"], -) diff --git a/src/trove_classifiers/version.py b/src/trove_classifiers/version.py new file mode 100644 index 0000000..09d1db5 --- /dev/null +++ b/src/trove_classifiers/version.py @@ -0,0 +1 @@ +__version__ = "2022.12.22" From 86d6fa64704e06ca17b761b395c341781a113188 Mon Sep 17 00:00:00 2001 From: Bartek Sokorski Date: Sat, 7 Jan 2023 01:48:23 +0100 Subject: [PATCH 2/2] Introduce tox instead of Makefile --- .github/workflows/main.yml | 8 +++---- .github/workflows/release.yml | 10 ++++---- .gitignore | 7 ++++++ CONTRIBUTING.md | 2 +- Makefile | 26 --------------------- pyproject.toml | 5 ++++ requirements/dev.txt | 5 ---- tox.ini | 43 +++++++++++++++++++++++++++++++++++ 8 files changed, 65 insertions(+), 41 deletions(-) delete mode 100644 Makefile delete mode 100644 requirements/dev.txt create mode 100644 tox.ini diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 75771d5..f8545ec 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,9 +14,9 @@ jobs: uses: actions/setup-python@v3 with: python-version: '3.x' - cache: pip - cache-dependency-path: requirements/dev.txt + - name: Install tox + run: pip install tox - name: Lint - run: make lint + run: tox -e lint - name: Test - run: make test + run: tox diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d6b68a7..22b609b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,14 +16,14 @@ jobs: uses: actions/setup-python@v3 with: python-version: '3.x' - cache: pip - cache-dependency-path: .github/workflows/release.yml + - name: Install project + run: pip install .[dev] - name: Lint - run: make lint + run: tox -e lint - name: Test - run: make test + run: tox - name: Install build dependencies - run: pip install -U setuptools wheel build calver + run: pip install -U setuptools wheel build - name: Build run: python -m build . - name: Publish diff --git a/.gitignore b/.gitignore index fe11925..ae59162 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,10 @@ build/ dist/ *.egg-info/ +.tox/ +.venv/ +.env/ +env/ +venv/ +.idea/ +.vscode/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 45a0ff5..6ca1081 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,5 @@ # Contributing -How to contributing to this package. +How to contribute to this package. ## Running tests Run `make test`. This checks whether the auto-generated list of classifiers diff --git a/Makefile b/Makefile deleted file mode 100644 index 81c0d1e..0000000 --- a/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -BINDIR = $(PWD)/.state/env/bin - -.state/env/pyvenv.cfg: requirements/dev.txt - rm -rf .state/env - python -m venv .state/env - - # install/upgrade general requirements - $(BINDIR)/python -m pip install --upgrade pip setuptools wheel - - # install various types of requirements - $(BINDIR)/python -m pip install -r requirements/dev.txt - -test: .state/env/pyvenv.cfg - $(BINDIR)/python -m pip install . - $(BINDIR)/pytest - $(BINDIR)/python -m tests.lib - -lint: .state/env/pyvenv.cfg - $(BINDIR)/black --check bin setup.py src tests - $(BINDIR)/python bin/sort.py src/trove_classifiers/__init__.py - $(BINDIR)/mypy src - -reformat: .state/env/pyvenv.cfg - $(BINDIR)/black tests src - -.PHONY: build test lint reformat diff --git a/pyproject.toml b/pyproject.toml index 23542a4..0961161 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,6 +20,11 @@ dynamic = ["version"] [project.urls] Homepage = "https://github.com/pypa/trove-classifiers" +[project.optional-dependencies] +dev = [ + "tox >= 4.0" +] + [tool.setuptools] package-dir = {"" = "src"} include-package-data = false diff --git a/requirements/dev.txt b/requirements/dev.txt deleted file mode 100644 index 533f3b6..0000000 --- a/requirements/dev.txt +++ /dev/null @@ -1,5 +0,0 @@ -black -jinja2 -natsort -pytest -mypy diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..57fbe1e --- /dev/null +++ b/tox.ini @@ -0,0 +1,43 @@ +[tox] +envlist = + py311 + py310 + py39 + py38 + py37 + lint + reformat + +isolated_build = true +skip_missing_interpreters = true +minversion = 4.0 + +[testenv] +description = run the tests with pytest under {envname} +passenv = + PYTEST_* +deps = + pytest >= 7.1 +commands = + pytest {posargs} + python -m tests.lib + +[testenv:lint] +description = lint the code base +skip_install = true +deps = + black >= 22.12.0 + mypy >= 0.991 + natsort >= 8.2 +commands = + black --check bin src tests + python bin/sort.py src/trove_classifiers/__init__.py + mypy src + +[testenv:reformat] +description = format the code base +skip_install = true +deps = + black >= 22.12.0 +commands = + black tests src