Skip to content

Commit 9ada618

Browse files
authored
migrate from setup.cfg to pyproject.toml (#118)
* switch to `pyproject.tom` * use `build` command in pipeline as well * fix `pytest.ini` * fix `.coveragerc` * fix `isort.cfg` * fix `.flake8` * run pre-commit * use `build` command in release-pipeline as well * fix release-pipeline dependencies * release-pipline:: fix sed inserting wrong string * increment version after release * add email of author Miguel Ángel García * release-pipline:: fix double equals sign beeing inserted --------- Co-authored-by: Jan Wille <jan.wille@stud.hs-hannover.de> Co-authored-by: Cube707 <Cube707@users.noreply.github.com>
1 parent b6e64eb commit 9ada618

File tree

13 files changed

+81
-110
lines changed

13 files changed

+81
-110
lines changed

.coveragerc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[run]
2+
omit = tests/*

.flake8

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[flake8]
2+
max-complexity = 12
3+
max-line-length = 88
4+
exclude =
5+
__pycache__/
6+
.git/
7+
.venv/
8+
.pytest_cache/
9+
show-source = true
10+
statistics = true
11+
count = true
12+
per-file-ignores =
13+
readchar/*_key.py:F403,F405

.github/workflows/publish.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
cache: pip
3636
- name: Install dependencies
3737
run: |
38-
pip install setuptools wheel twine
38+
pip install build twine
3939
- name: get infos from Tag
4040
run: |
4141
echo "RELEASE_TAG=${RELEASE_TAG}"
@@ -55,12 +55,12 @@ jobs:
5555
with:
5656
script: core.setFailed('Invalid Tag name used with this release!')
5757

58-
- name: Write Version to __init__
58+
- name: Write Version to pyproject.toml
5959
run: |
60-
sed -i "s/__version__ = .*/__version__ = '$VERSION'/" readchar/__init__.py
60+
sed -i "s/version = \".*\"$/version = \"$VERSION\"/" pyproject.toml
6161
- name: Build sdist and bdist_wheel
6262
run: |
63-
python setup.py sdist bdist_wheel
63+
python -m build
6464
- name: publish to PyPi
6565
env:
6666
TWINE_USERNAME: __token__
@@ -72,12 +72,12 @@ jobs:
7272
if: ${{ env.VERSION_DEV }}
7373
run: |
7474
v=$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH-dev$((VERSION_DEV+1))
75-
sed -i "s/__version__ = .*/__version__ = \"$v\"/" readchar/__init__.py
75+
sed -i "s/version = \".*\"$/version = \"$v\"/" pyproject.toml
7676
- name: increment patch version
7777
if: ${{ !env.VERSION_DEV }}
7878
run: |
7979
v=$VERSION_MAJOR.$VERSION_MINOR.$((VERSION_PATCH+1))-dev0
80-
sed -i "s/__version__ = .*/__version__ = \"$v\"/" readchar/__init__.py
80+
sed -i "s/version = \".*\"$/version = \"$v\"/" pyproject.toml
8181
- name: commit new version-number
8282
uses: stefanzweifel/git-auto-commit-action@v4
8383
with:

.github/workflows/run-tests.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ jobs:
4242
python-version: '3.x'
4343
cache: pip
4444
- run: |
45-
pip install setuptools wheel
45+
pip install build
4646
- run: |
47-
python setup.py sdist bdist_wheel
47+
python -m build
4848
4949
pytest:
5050
runs-on: ${{ matrix.os }}

.isort.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[settings]
2+
profile = black
3+
src_paths = readchar,tests
4+
lines_after_imports = 2

.pre-commit-config.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ repos:
3030
- name: check python syntax
3131
id: flake8
3232

33-
- repo: https://github.com/asottile/setup-cfg-fmt
34-
rev: v2.5.0
35-
hooks:
36-
- name: format setup.cfg
37-
id: setup-cfg-fmt
38-
args: [--include-version-classifiers]
39-
4033
- repo: https://github.com/executablebooks/mdformat
4134
rev: 0.7.16
4235
hooks:

.pytest.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[pytest]
2+
testpaths = tests
3+
addopts = -r fEsxwX -s --cov=readchar

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ pre-commit precommit:
1111
@pre-commit run -a
1212

1313
build pack readchar:
14-
@python setup.py sdist bdist_wheel
14+
@python -m build

pyproject.toml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[build-system]
2+
requires = ["setuptools >= 61.0"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "readchar"
7+
version = "4.1.0-dev3"
8+
requires-python = ">= 3.8"
9+
dependencies = []
10+
authors = [
11+
{ name = "Miguel Ángel García", email="miguelangel.garcia@gmail.com" },
12+
{ name = "Jan Wille", email = "mail@janwille.de" },
13+
]
14+
maintainers = [{ name = "Jan Wille", email = "mail@janwille.de" }]
15+
keywords = ["characters", "keystrokes", "stdin", "command line"]
16+
classifiers = [
17+
"Development Status :: 5 - Production/Stable",
18+
"License :: OSI Approved :: MIT License",
19+
"Operating System :: Microsoft :: Windows",
20+
"Operating System :: POSIX :: Linux",
21+
"Programming Language :: Python :: 3",
22+
"Programming Language :: Python :: 3 :: Only",
23+
"Programming Language :: Python :: 3.8",
24+
"Programming Language :: Python :: 3.9",
25+
"Programming Language :: Python :: 3.10",
26+
"Programming Language :: Python :: 3.11",
27+
"Programming Language :: Python :: 3.12",
28+
"Programming Language :: Python :: Implementation :: CPython",
29+
"Environment :: Console",
30+
"Intended Audience :: Developers",
31+
"Topic :: Software Development",
32+
"Topic :: Software Development :: User Interfaces",
33+
]
34+
description = "Library to easily read single chars and key strokes"
35+
readme = { file = "README.md", content-type = "text/markdown" }
36+
license = { file = "LICENCE" }
37+
38+
[project.urls]
39+
Homepage = "https://pypi.org/project/readchar"
40+
#Documentation = "https://readthedocs.org"
41+
Repository = "https://github.com/magmax/python-readchar"
42+
Issues = "https://github.com/magmax/python-readchar/issues"
43+
Changelog = "https://github.com/magmax/python-readchar/releases"

readchar/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
"""Library to easily read single chars and key strokes"""
1+
import importlib.metadata
22

3-
__version__ = "4.0.7-dev0"
3+
4+
__doc__ = """Library to easily read single chars and key strokes"""
5+
6+
__version__ = importlib.metadata.version(__package__)
47
__all__ = ["readchar", "readkey", "key", "config"]
58

69
from sys import platform

0 commit comments

Comments
 (0)