Migrate from setup.* to pyproject.toml

This commit is contained in:
Hugo van Kemenade 2022-09-26 11:04:45 +03:00
parent 54a9f04f8f
commit 98943d606e
8 changed files with 96 additions and 84 deletions

2
.flake8 Normal file
View file

@ -0,0 +1,2 @@
[flake8]
max_line_length = 88

View file

@ -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/*

View file

@ -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

View file

@ -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

73
pyproject.toml Normal file
View file

@ -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 <amr.hassan@gmail.com> 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"

View file

@ -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 <amr.hassan@gmail.com> 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

View file

@ -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},
)

View file

@ -2,6 +2,7 @@
envlist =
lint
py{py3, 311, 310, 39, 38, 37}
isolated_build = true
[testenv]
passenv =