From 181a5befee4e05b668f9a821d1b0453ec3106e82 Mon Sep 17 00:00:00 2001 From: George Leslie-Waksman Date: Sun, 8 Jan 2023 23:40:45 -0800 Subject: [PATCH] Transition from setup.py to pyproject.toml --- .github/workflows/pre-commit.yml | 9 +- .github/workflows/publish.yml | 6 +- .github/workflows/run-tests.yml | 12 +-- .gitignore | 3 + mtg_ssm/__init__.py | 6 +- mtg_ssm/version.py | 2 - mypy.ini | 13 --- pyproject.toml | 137 +++++++++++++++++++++++ requirements.txt | 4 - setup.cfg | 40 ------- setup.py | 64 ----------- test_requirements.in | 28 ----- test_requirements.txt | 180 ------------------------------- 13 files changed, 155 insertions(+), 349 deletions(-) delete mode 100644 mtg_ssm/version.py delete mode 100644 mypy.ini create mode 100644 pyproject.toml delete mode 100644 requirements.txt delete mode 100644 setup.cfg delete mode 100644 setup.py delete mode 100644 test_requirements.in delete mode 100644 test_requirements.txt diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index f9ae639..0c16577 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -9,6 +9,7 @@ on: jobs: pre-commit: runs-on: ubuntu-latest + name: Run all pre-commit checks steps: - uses: actions/checkout@v3 @@ -17,12 +18,8 @@ jobs: python-version: "3.8" cache: pip cache-dependency-path: | - requirements.txt - test_requirements.txt + pyproject.toml - - run: >- - pip install - -r requirements.txt - -r test_requirements.txt + - run: pip install -e .[lxml,dev] - uses: pre-commit/action@v3.0.0 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a3824e2..b8e68ff 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,4 +1,5 @@ -name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI +name: publish +concurrency: publish on: push @@ -27,12 +28,11 @@ jobs: --outdir dist/ - name: Publish distribution 📦 to Test PyPI - # TODO(gwax): use setuptools_scm instead of only pushing tags to test pypi - if: startsWith(github.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@v1.5.0 with: password: ${{ secrets.TEST_PYPI_API_TOKEN }} repository_url: https://test.pypi.org/legacy/ + - name: Publish distribution 📦 to PyPI if: startsWith(github.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@v1.5.0 diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index d22167e..cd2e633 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -25,14 +25,10 @@ jobs: python-version: "${{ matrix.python-version }}" cache: pip cache-dependency-path: | - requirements.txt - test_requirements.txt - - - name: Install requirements - run: >- - pip install - -r requirements.txt - -r test_requirements.txt + pyproject.toml + + - name: Install project + run: pip install -e .[lmxl,dev] - name: Execute pytest run: pytest tests/ diff --git a/.gitignore b/.gitignore index 7d31103..dd2a530 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,9 @@ lcov.info *.lcov +# setuptools_scm generated files +mtg_ssm/_version.py + # Created by https://www.gitignore.io/api/python ### Python ### diff --git a/mtg_ssm/__init__.py b/mtg_ssm/__init__.py index b9e2187..aacc5ce 100644 --- a/mtg_ssm/__init__.py +++ b/mtg_ssm/__init__.py @@ -1,2 +1,6 @@ """Establish mtg_ssm package.""" -from mtg_ssm.version import __version__ + +try: + from ._version import __version__ +except ImportError: + __version__ = "unknown" diff --git a/mtg_ssm/version.py b/mtg_ssm/version.py deleted file mode 100644 index 0979f25..0000000 --- a/mtg_ssm/version.py +++ /dev/null @@ -1,2 +0,0 @@ -"""Version information.""" -__version__ = "2.4.0" diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index 17ca053..0000000 --- a/mypy.ini +++ /dev/null @@ -1,13 +0,0 @@ - -[mypy] -python_version = 3.8 -plugins = pydantic.mypy - -ignore_missing_imports = True -follow_imports = normal -disallow_untyped_defs = True -allow_untyped_globals = False - - -[mypy-mtg_ssm.scryfall.third_party.*] -disallow_untyped_defs = False diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b17b5fa --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,137 @@ +[build-system] +requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"] +build-backend = "setuptools.build_meta" + +[project] +name = "mtg_ssm" +description = "A tool to manage Magic: the Gathering collection spreadsheets" +readme = "README.rst" +authors = [ + {name = "George Leslie-Waksman", email ="waksman@gmail.com"}, + ] +requires-python = ">=3.8" +keywords = [ + "mtg", + "magic", + "collection", + "tracking", + "spreadsheet", +] +license = {text = "MIT"} +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Intended Audience :: End Users/Desktop", + "License :: OSI Approved :: MIT License", + "Operating System :: MacOS", + "Operating System :: Microsoft :: Windows", + "Operating System :: OS Independent", + "Operating System :: POSIX", + "Operating System :: Unix", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Topic :: Games/Entertainment", +] + +dependencies = [ + "appdirs~=1.4", + "openpyxl~=3.0", + "pydantic~=1.9", + "requests~=2.27", +] +dynamic = ["version"] + +[project.urls] +"Homepage" = "https://github.com/gwax/mtg_ssm" +"Bug Tracker" = "https://github.com/gwax/mtg_ssm/issues" + +[project.scripts] +mtg-ssm = "mtg_ssm.ssm:main" + +[project.optional-dependencies] +lxml = [ + "lxml>=3.7.2", +] +dev = [ + "black", + "coverage[toml]", + "doc8", + "flake8", + "flake8-bugbear", + "flake8-comprehensions", + "flake8-mutable", + "flake8-pyproject", + "freezegun", + "isort", + "lxml", + "mypy", + "openpyxl-stubs", + "pip", + "pip-tools", + "Pygments", + "pylint", + "pytest>=6.0", + "pytest-cov", + "pytest-snapshot", + "responses", + "setuptools>=45", + "setuptools-scm[toml]>=6.2", + "types-freezegun", + "types-requests", + "wheel", +] + +[tool.setuptools] +packages = ["mtg_ssm"] + +[tool.setuptools_scm] +write_to = "mtg_ssm/_version.py" + +[tool.mypy] +python_version = "3.8" +plugins = "pydantic.mypy" + +ignore_missing_imports = true +follow_imports = "normal" +disallow_untyped_defs = true +allow_untyped_globals = false + +[tool.flake8] +ignore = ["E203", "E501", "F401", "W503"] +max_complexity = 10 +exclude = [".git", "__pycache__", "build", "dist"] + +[tool.pytest.ini_options] +xfail_strict = true +addopts = "--cov mtg_ssm --cov-report term-missing" +testpaths = ["tests"] + +[tool.coverage.run] +omit = ["tests/**"] + +[tool.coverage.report] +exclude_lines = [ + "def __repr__", + "def __str__", + "if __name__ = .__main__.:", +] + +[tool.isort] +profile = "black" +atomic = true +line_length = 88 +known_first_party = [ + "mtg_ssm", + "tests", +] +known_third_party = [ + "freezegun", + "openpyxl", + "pytest", + "requests", +] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 160639c..0000000 --- a/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -appdirs~=1.4 -openpyxl~=3.0 -pydantic~=1.9 -requests~=2.27 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index d561ab4..0000000 --- a/setup.cfg +++ /dev/null @@ -1,40 +0,0 @@ -[flake8] -ignore = E203,E501,F401,W503 -max_complexity = 10 -exclude = - .git, - __pycache__, - build, - dist - -[tool:pytest] -xfail_strict=true -addopts = - --cov mtg_ssm - --cov-report term-missing -testpaths = tests - -[coverage:run] -omit = - setup.py - tests/** - mtg_ssm/scryfall/third_party/** - -[coverage:report] -exclude_lines = - def __repr__ - def __str__ - if __name__ = .__main__.: - -[isort] -atomic = true -profile = black -line_length = 88 -known_first_party = - mtg_ssm, - tests, -known_third_party = - openpyxl, - requests, - pytest, - freezegun, diff --git a/setup.py b/setup.py deleted file mode 100644 index f9cae4e..0000000 --- a/setup.py +++ /dev/null @@ -1,64 +0,0 @@ -"""Setup script for mtg_ssm.""" - -import sys - -import setuptools - -if sys.version_info < (3, 8): - raise Exception("Python version < 3.8 are not supported.") - -# Get version information without importing the package -__version__ = None -with open("mtg_ssm/version.py", "rt", encoding="utf-8") as versionfile: - exec(versionfile.read()) # pylint: disable=exec-used - -SHORT_DESCRIPTION = "A tool to manage Magic: the Gathering collection spreadsheets." -with open("README.rst", "rt", encoding="utf-8") as readmefile: - LONG_DESCRIPTION = readmefile.read() - -with open("requirements.txt", "rt", encoding="utf-8") as requirementsfile: - DEPENDENCIES = [line.strip() for line in requirementsfile] -with open("test_requirements.txt", "rt", encoding="utf-8") as testrequirementsfile: - TEST_DEPENDENCIES = [line.strip() for line in testrequirementsfile] - -CLASSIFIERS = [ - "Development Status :: 5 - Production/Stable", - "Environment :: Console", - "Intended Audience :: End Users/Desktop", - "License :: OSI Approved :: MIT License", - "Operating System :: MacOS", - "Operating System :: Microsoft :: Windows", - "Operating System :: OS Independent", - "Operating System :: POSIX", - "Operating System :: Unix", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Topic :: Games/Entertainment", -] - -EXTRAS = {"lxml": "lxml>=3.7.2"} - -setuptools.setup( - name="mtg_ssm", - version=__version__, - description=SHORT_DESCRIPTION, - long_description=LONG_DESCRIPTION, - author="George Leslie-Waksman", - author_email="waksman@gwax.com", - url="https://github.com/gwax/mtg_ssm", - packages=setuptools.find_packages(exclude=("tests*",)), - package_data={"mtg_ssm": ["py.typed"]}, - license="MIT", - platforms=["any"], - keywords="mtg magic collection tracking spreadsheet", - classifiers=CLASSIFIERS, - install_requires=DEPENDENCIES, - tests_require=TEST_DEPENDENCIES, - extras_require=EXTRAS, - entry_points={"console_scripts": ["mtg-ssm = mtg_ssm.ssm:main"]}, -) diff --git a/test_requirements.in b/test_requirements.in deleted file mode 100644 index ec5b747..0000000 --- a/test_requirements.in +++ /dev/null @@ -1,28 +0,0 @@ --c requirements.txt --r requirements.txt - -black -coverage -doc8 -flake8 -flake8-bugbear -flake8-comprehensions -flake8-mutable -freezegun -isort -lxml -mypy -openpyxl-stubs -pip -pip-tools -py -Pygments -pylint -pytest -pytest-cov -pytest-snapshot -responses -setuptools -types-freezegun -types-requests -wheel diff --git a/test_requirements.txt b/test_requirements.txt deleted file mode 100644 index 378cee5..0000000 --- a/test_requirements.txt +++ /dev/null @@ -1,180 +0,0 @@ -# -# This file is autogenerated by pip-compile with Python 3.11 -# by the following command: -# -# pip-compile --allow-unsafe test_requirements.in -# -appdirs==1.4.4 - # via - # -c requirements.txt - # -r requirements.txt -astroid==2.12.13 - # via pylint -attrs==22.1.0 - # via - # flake8-bugbear - # pytest -black==22.12.0 - # via -r test_requirements.in -build==0.9.0 - # via pip-tools -certifi==2022.12.7 - # via requests -charset-normalizer==2.1.1 - # via requests -click==8.1.3 - # via - # black - # pip-tools -coverage[toml]==6.5.0 - # via - # -r test_requirements.in - # pytest-cov -dill==0.3.6 - # via pylint -doc8==1.0.0 - # via -r test_requirements.in -docutils==0.19 - # via - # doc8 - # restructuredtext-lint -et-xmlfile==1.1.0 - # via openpyxl -flake8==6.0.0 - # via - # -r test_requirements.in - # flake8-bugbear - # flake8-comprehensions - # flake8-mutable -flake8-bugbear==22.12.6 - # via -r test_requirements.in -flake8-comprehensions==3.10.1 - # via -r test_requirements.in -flake8-mutable==1.2.0 - # via -r test_requirements.in -freezegun==1.2.2 - # via -r test_requirements.in -idna==3.4 - # via requests -iniconfig==1.1.1 - # via pytest -isort==5.11.2 - # via - # -r test_requirements.in - # pylint -lazy-object-proxy==1.8.0 - # via astroid -lxml==4.9.2 - # via -r test_requirements.in -mccabe==0.7.0 - # via - # flake8 - # pylint -mypy==0.991 - # via - # -r test_requirements.in - # openpyxl-stubs -mypy-extensions==0.4.3 - # via - # black - # mypy -openpyxl==3.0.10 - # via - # -c requirements.txt - # -r requirements.txt - # openpyxl-stubs -openpyxl-stubs==0.1.24 - # via -r test_requirements.in -packaging==22.0 - # via - # build - # pytest -pathspec==0.10.3 - # via black -pbr==5.11.0 - # via stevedore -pep517==0.13.0 - # via build -pip==22.3.1 - # via - # -r test_requirements.in - # pip-tools -pip-tools==6.12.0 - # via -r test_requirements.in -platformdirs==2.6.0 - # via - # black - # pylint -pluggy==1.0.0 - # via pytest -py==1.11.0 - # via -r test_requirements.in -pycodestyle==2.10.0 - # via flake8 -pydantic==1.10.2 - # via - # -c requirements.txt - # -r requirements.txt -pyflakes==3.0.1 - # via flake8 -pygments==2.13.0 - # via - # -r test_requirements.in - # doc8 -pylint==2.15.8 - # via -r test_requirements.in -pytest==7.2.0 - # via - # -r test_requirements.in - # pytest-cov - # pytest-snapshot -pytest-cov==4.0.0 - # via -r test_requirements.in -pytest-snapshot==0.9.0 - # via -r test_requirements.in -python-dateutil==2.8.2 - # via freezegun -requests==2.28.1 - # via - # -c requirements.txt - # -r requirements.txt - # responses -responses==0.22.0 - # via -r test_requirements.in -restructuredtext-lint==1.4.0 - # via doc8 -setuptools==65.6.3 - # via - # -r test_requirements.in - # pip-tools -six==1.16.0 - # via python-dateutil -stevedore==4.1.1 - # via doc8 -toml==0.10.2 - # via responses -tomlkit==0.11.6 - # via pylint -types-freezegun==1.1.10 - # via -r test_requirements.in -types-requests==2.28.11.5 - # via -r test_requirements.in -types-toml==0.10.8.1 - # via responses -types-urllib3==1.26.25.4 - # via types-requests -typing-extensions==4.4.0 - # via - # mypy - # openpyxl-stubs - # pydantic -urllib3==1.26.13 - # via - # requests - # responses -wheel==0.38.4 - # via - # -r test_requirements.in - # pip-tools -wrapt==1.14.1 - # via astroid