From 9a81190f1c3bee7ba7c50e3efff18f7c8fd4770f Mon Sep 17 00:00:00 2001 From: Danny Guinther Date: Thu, 4 Apr 2024 21:02:44 -0400 Subject: [PATCH] Move setup.py configs to pyproject.toml --- .github/workflows/main-build-and-publish.yml | 12 +- .gitignore | 3 + MANIFEST.in | 2 - pyproject.toml | 81 +++++++++++++- requirements.txt | 1 + setup.py | 109 ------------------- whitelist.txt | 1 + 7 files changed, 95 insertions(+), 114 deletions(-) delete mode 100644 MANIFEST.in delete mode 100644 setup.py diff --git a/.github/workflows/main-build-and-publish.yml b/.github/workflows/main-build-and-publish.yml index f433914..e28955e 100644 --- a/.github/workflows/main-build-and-publish.yml +++ b/.github/workflows/main-build-and-publish.yml @@ -31,9 +31,10 @@ jobs: pip install .[all] pip uninstall -y service-oriented pip freeze > requirements.txt - git diff --quiet - if [ ! $? -eq 0 ]; then + + if ! `git diff --quiet`; then echo "pip freeze caused file changes, failing!" + git diff exit 1 fi @@ -42,12 +43,19 @@ jobs: source venv/bin/activate make style + if ! `git diff --quiet`; then + echo "make style caused file changes, failing!" + git diff + exit 1 + fi + - name: Run tests and build package run: | source venv/bin/activate coverage run -m pytest coverage report | tee .meta/coverage/report.txt coverage-badge -f -o .meta/coverage/badge.svg + SETUPTOOLS_SCM_PRETEND_VERSION_FOR_SERVICE_ORIENTED="$(cat VERSION)" python -m build - name: Checkout tdg5/github-action-pack diff --git a/.gitignore b/.gitignore index 68bc17f..d4e162c 100644 --- a/.gitignore +++ b/.gitignore @@ -158,3 +158,6 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ + +# Auto-generated +service_oriented/__version__.py diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 247fb3b..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -include VERSION -include service_oriented/py.typed diff --git a/pyproject.toml b/pyproject.toml index 5d17aab..beb3b36 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,68 @@ [build-system] build-backend = "setuptools.build_meta" -requires = ["setuptools>=69"] +requires = [ + "setuptools>=69", + "setuptools-scm>=8.0.4" +] + +[project] +authors = [ + {name = "Danny Guinther"}, +] +classifiers=[ + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.9", +] +dependencies = [ + "pydantic-settings~=2.1.0", + "pydantic~=2.5.3", + "python-json-logger==2.0.7", + "pyyaml~=6.0.1", +] +description = "Toolkit for building service oriented applications in python" +dynamic = [ + "version", +] +license = {text = "MIT"} +name = "service_oriented" +readme = "README.md" +requires-python = ">3.9.0" + +[project.optional-dependencies] +dev = [ + "black~=24.2.0", + "build~=1.0.3", + "coverage-badge~=1.1.0", + "coverage~=7.4.4", + "dlint~=0.14.1", + "flake8-comprehensions~=3.14.0", + "flake8-eradicate~=1.5.0", + "flake8-pyproject~=1.2.3", + "flake8-spellcheck~=0.28.0", + "flake8-typing-imports~=1.15.0", + "flake8~=7.0.0", + "isort~=5.13.2", + "mypy~=1.8.0", + "pep8-naming~=0.13.3", + "pre-commit~=3.6.0", + "pytest-mock~=3.12.0", + "pytest-watcher~=0.4.2", + "pytest~=7.4.0", + "safety~=2.3.4", + "twine~=4.0.2", + "wheel>=0.42.0", +] + +[project.urls] +Homepage = "https://github.com/tdg5/service-oriented-py" +Source = "https://github.com/tdg5/service-oriented-py" +Tracker = "https://github.com/tdg5/service-oriented-py/issues" [tool.black] include = "service_oriented(_test)?/.*\\.py$" @@ -38,3 +100,20 @@ init_forbid_extra = true [tool.pytest.ini_options] markers = ["integration_test: marks tests as integration tests (deselect with '-m \"not integration_test\"')"] + +[tool.setuptools.package-data] +"service_oriented" = ["py.typed"] + +[tool.setuptools.packages.find] +exclude = ["*.__pycache__.*"] +include = [ + "service_oriented", + "service_oriented.application", + "service_oriented.application.config", + "service_oriented.initializers", + "service_oriented.logging", +] +where = ["."] + +[tool.setuptools_scm] +version_file = "service_oriented/__version__.py" diff --git a/requirements.txt b/requirements.txt index 86c3974..aa35444 100644 --- a/requirements.txt +++ b/requirements.txt @@ -69,6 +69,7 @@ ruamel.yaml==0.18.5 ruamel.yaml.clib==0.2.8 safety==2.3.4 SecretStorage==3.3.3 +setuptools-scm==8.0.4 toml==0.10.2 tomli==2.0.1 twine==4.0.2 diff --git a/setup.py b/setup.py deleted file mode 100644 index 3a5046b..0000000 --- a/setup.py +++ /dev/null @@ -1,109 +0,0 @@ -from os import path -from typing import Dict, List, Tuple - -from setuptools import find_packages, setup - - -VERSION_PATH = path.join(path.abspath(path.dirname(__file__)), "VERSION") - -with open(VERSION_PATH, encoding="utf-8", mode="r") as f: - VERSION = f.read().strip() - -_dependencies = [ - "pydantic-settings~=2.1.0", - "pydantic~=2.5.3", - "python-json-logger==2.0.7", - "pyyaml~=6.0.1", -] - -_dev_dependencies = [ - "black~=24.2.0", - "build~=1.0.3", - "coverage-badge~=1.1.0", - "coverage~=7.4.4", - "dlint~=0.14.1", - "flake8-comprehensions~=3.14.0", - "flake8-eradicate~=1.5.0", - "flake8-pyproject~=1.2.3", - "flake8-spellcheck~=0.28.0", - "flake8-typing-imports~=1.15.0", - "flake8~=7.0.0", - "isort~=5.13.2", - "mypy~=1.8.0", - "pep8-naming~=0.13.3", - "pre-commit~=3.6.0", - "pytest-mock~=3.12.0", - "pytest-watcher~=0.4.2", - "pytest~=7.4.0", - "safety~=2.3.4", - "twine~=4.0.2", - "wheel>=0.42.0", -] - - -def _setup_packages() -> List: - default_packages = [ - "service_oriented", - "service_oriented.application", - "service_oriented.application.config", - "service_oriented.initializers", - "service_oriented.logging", - ] - return find_packages( - ".", - exclude=["*.__pycache__.*"], - include=default_packages, - ) - - -def _setup_extras() -> Dict: - return { - "all": [ - _dependencies, - _dev_dependencies, - ], - "deps": _dependencies, - "dev": _dev_dependencies, - } - - -def _setup_install_requires() -> List: - return _dependencies - - -def _setup_entry_points() -> Dict: - return {} - - -def _setup_long_description() -> Tuple[str, str]: - return open("README.md", "r", encoding="utf-8").read(), "text/markdown" - - -setup( - author="Danny Guinther", - author_email="dannyguinther@gmail.com", - classifiers=[ - "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - ], - description="Toolkit for building service oriented applications in python", - entry_points=_setup_entry_points(), - extras_require=_setup_extras(), - include_package_data=True, - install_requires=_setup_install_requires(), - keywords="[TODO]", - license="MIT", - long_description=_setup_long_description()[0], - long_description_content_type=_setup_long_description()[1], - name="service_oriented", - packages=_setup_packages(), - python_requires=">=3.9.0", - url="https://github.com/tdg5/service-oriented-py", - version=VERSION, -) diff --git a/whitelist.txt b/whitelist.txt index 1119737..9b61527 100644 --- a/whitelist.txt +++ b/whitelist.txt @@ -11,6 +11,7 @@ nonlocal param pydantic pythonjsonlogger +scm unparameterized untyped usefixtures