From 98943d606e179772f1254ec56e5ef5c552ceef30 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Mon, 26 Sep 2022 11:04:45 +0300 Subject: [PATCH] Migrate from setup.* to pyproject.toml --- .flake8 | 2 + .github/workflows/deploy.yml | 5 +-- .github/workflows/test.yml | 4 +- .pre-commit-config.yaml | 25 +++++++----- pyproject.toml | 73 ++++++++++++++++++++++++++++++++++++ setup.cfg | 58 ---------------------------- setup.py | 12 ------ tox.ini | 1 + 8 files changed, 96 insertions(+), 84 deletions(-) create mode 100644 .flake8 create mode 100644 pyproject.toml delete mode 100644 setup.cfg delete mode 100755 setup.py diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..f4546ad --- /dev/null +++ b/.flake8 @@ -0,0 +1,2 @@ +[flake8] +max_line_length = 88 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c2af694..0c72ce1 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -22,9 +22,9 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.x" cache: pip - cache-dependency-path: setup.cfg + cache-dependency-path: pyproject.toml - name: Install dependencies run: | @@ -33,7 +33,6 @@ jobs: - name: Build package run: | - python setup.py --version python -m build twine check --strict dist/* diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bf5d9ba..e0d36a9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,7 @@ jobs: with: python-version: ${{ matrix.python-version }} cache: pip - cache-dependency-path: setup.cfg + cache-dependency-path: pyproject.toml - name: Install dependencies run: | @@ -48,7 +48,7 @@ jobs: success: needs: test runs-on: ubuntu-latest - name: test successful + name: Test successful steps: - name: Success run: echo Test successful diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2b9ebc7..d076c82 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,12 +1,12 @@ repos: - repo: https://github.com/asottile/pyupgrade - rev: v2.34.0 + rev: v2.38.2 hooks: - id: pyupgrade args: [--py37-plus] - repo: https://github.com/psf/black - rev: 22.6.0 + rev: 22.8.0 hooks: - id: black args: [--target-version=py37] @@ -16,7 +16,7 @@ repos: hooks: - id: blacken-docs args: [--target-version=py37] - additional_dependencies: [black==21.12b0] + additional_dependencies: [black==22.8.0] - repo: https://github.com/PyCQA/isort rev: 5.10.1 @@ -24,7 +24,7 @@ repos: - id: isort - repo: https://github.com/PyCQA/flake8 - rev: 4.0.1 + rev: 5.0.4 hooks: - id: flake8 additional_dependencies: [flake8-2020, flake8-implicit-str-concat] @@ -37,15 +37,22 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.3.0 hooks: - - id: check-merge-conflict - id: check-json + - id: check-merge-conflict + - id: check-toml - id: check-yaml + - id: end-of-file-fixer + - id: requirements-txt-fixer - - repo: https://github.com/asottile/setup-cfg-fmt - rev: v1.20.1 + - repo: https://github.com/tox-dev/pyproject-fmt + rev: 0.3.5 hooks: - - id: setup-cfg-fmt - args: [--max-py-version=3.11] + - id: pyproject-fmt + + - repo: https://github.com/abravalheri/validate-pyproject + rev: v0.10.1 + hooks: + - id: validate-pyproject - repo: https://github.com/tox-dev/tox-ini-fmt rev: 0.5.2 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..3e9af83 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,73 @@ +[build-system] +build-backend = "setuptools.build_meta" +requires = [ + "setuptools>=61.2", + "setuptools-scm", +] + +[project] +name = "pylast" +description = "A Python interface to Last.fm and Libre.fm" +readme = "README.md" +keywords = [ + "Last.fm", + "music", + "scrobble", + "scrobbling", +] +license = {text = "Apache-2.0"} +maintainers = [{name = "Hugo van Kemenade"}] +authors = [{name = "Amr Hassan and Contributors", email = "amr.hassan@gmail.com"}] +requires-python = ">=3.7" +dependencies = [ + "httpx", + 'importlib-metadata; python_version < "3.8"', +] +dynamic = [ + "version", +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "License :: OSI Approved :: Apache Software License", + "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", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Topic :: Internet", + "Topic :: Multimedia :: Sound/Audio", + "Topic :: Software Development :: Libraries :: Python Modules", +] +[project.optional-dependencies] +tests = [ + "flaky", + "pytest", + "pytest-cov", + "pytest-random-order", + "pyyaml", +] + +[project.urls] +Changelog = "https://github.com/pylast/pylast/releases" +Homepage = "https://github.com/pylast/pylast" +Source = "https://github.com/pylast/pylast" + + +[tool.isort] +profile = "black" + +[tool.setuptools] +package-dir = {"" = "src"} +license-files = ["LICENSE.txt"] +include-package-data = false + +[tool.setuptools.packages.find] +where = ["src"] +namespaces = false + +[tool.setuptools_scm] +local_scheme = "no-local-version" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 5fa2a3d..0000000 --- a/setup.cfg +++ /dev/null @@ -1,58 +0,0 @@ -[metadata] -name = pylast -description = A Python interface to Last.fm and Libre.fm -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/pylast/pylast -author = Amr Hassan and Contributors -author_email = amr.hassan@gmail.com -maintainer = Hugo van Kemenade -license = Apache-2.0 -license_file = LICENSE.txt -classifiers = - Development Status :: 5 - Production/Stable - License :: OSI Approved :: Apache Software License - 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 - Programming Language :: Python :: 3.11 - Programming Language :: Python :: Implementation :: CPython - Programming Language :: Python :: Implementation :: PyPy - Topic :: Internet - Topic :: Multimedia :: Sound/Audio - Topic :: Software Development :: Libraries :: Python Modules -keywords = - Last.fm - music - scrobble - scrobbling - -[options] -packages = find: -install_requires = - httpx - importlib-metadata;python_version < '3.8' -python_requires = >=3.7 -package_dir = =src -setup_requires = - setuptools-scm - -[options.packages.find] -where = src - -[options.extras_require] -tests = - flaky - pytest - pytest-cov - pytest-random-order - pyyaml - -[flake8] -max_line_length = 88 - -[tool:isort] -profile = black diff --git a/setup.py b/setup.py deleted file mode 100755 index 630d39e..0000000 --- a/setup.py +++ /dev/null @@ -1,12 +0,0 @@ -from setuptools import setup - - -def local_scheme(version: str) -> str: - """Skip the local version (eg. +xyz of 0.6.1.dev4+gdf99fe2) - to be able to upload to Test PyPI""" - return "" - - -setup( - use_scm_version={"local_scheme": local_scheme}, -) diff --git a/tox.ini b/tox.ini index 0f07848..a06262e 100644 --- a/tox.ini +++ b/tox.ini @@ -2,6 +2,7 @@ envlist = lint py{py3, 311, 310, 39, 38, 37} +isolated_build = true [testenv] passenv =