Skip to content

Commit

Permalink
migrate from setup.cfg to pyproject.toml (#118)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
3 people committed May 16, 2024
1 parent b6e64eb commit 9ada618
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 110 deletions.
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
omit = tests/*
13 changes: 13 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[flake8]
max-complexity = 12
max-line-length = 88
exclude =
__pycache__/
.git/
.venv/
.pytest_cache/
show-source = true
statistics = true
count = true
per-file-ignores =
readchar/*_key.py:F403,F405
12 changes: 6 additions & 6 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
cache: pip
- name: Install dependencies
run: |
pip install setuptools wheel twine
pip install build twine
- name: get infos from Tag
run: |
echo "RELEASE_TAG=${RELEASE_TAG}"
Expand All @@ -55,12 +55,12 @@ jobs:
with:
script: core.setFailed('Invalid Tag name used with this release!')

- name: Write Version to __init__
- name: Write Version to pyproject.toml
run: |
sed -i "s/__version__ = .*/__version__ = '$VERSION'/" readchar/__init__.py
sed -i "s/version = \".*\"$/version = \"$VERSION\"/" pyproject.toml
- name: Build sdist and bdist_wheel
run: |
python setup.py sdist bdist_wheel
python -m build
- name: publish to PyPi
env:
TWINE_USERNAME: __token__
Expand All @@ -72,12 +72,12 @@ jobs:
if: ${{ env.VERSION_DEV }}
run: |
v=$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH-dev$((VERSION_DEV+1))
sed -i "s/__version__ = .*/__version__ = \"$v\"/" readchar/__init__.py
sed -i "s/version = \".*\"$/version = \"$v\"/" pyproject.toml
- name: increment patch version
if: ${{ !env.VERSION_DEV }}
run: |
v=$VERSION_MAJOR.$VERSION_MINOR.$((VERSION_PATCH+1))-dev0
sed -i "s/__version__ = .*/__version__ = \"$v\"/" readchar/__init__.py
sed -i "s/version = \".*\"$/version = \"$v\"/" pyproject.toml
- name: commit new version-number
uses: stefanzweifel/git-auto-commit-action@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ jobs:
python-version: '3.x'
cache: pip
- run: |
pip install setuptools wheel
pip install build
- run: |
python setup.py sdist bdist_wheel
python -m build
pytest:
runs-on: ${{ matrix.os }}
Expand Down
4 changes: 4 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[settings]
profile = black
src_paths = readchar,tests
lines_after_imports = 2
7 changes: 0 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ repos:
- name: check python syntax
id: flake8

- repo: https://github.com/asottile/setup-cfg-fmt
rev: v2.5.0
hooks:
- name: format setup.cfg
id: setup-cfg-fmt
args: [--include-version-classifiers]

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.16
hooks:
Expand Down
3 changes: 3 additions & 0 deletions .pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pytest]
testpaths = tests
addopts = -r fEsxwX -s --cov=readchar
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ pre-commit precommit:
@pre-commit run -a

build pack readchar:
@python setup.py sdist bdist_wheel
@python -m build
43 changes: 43 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[build-system]
requires = ["setuptools >= 61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "readchar"
version = "4.1.0-dev3"
requires-python = ">= 3.8"
dependencies = []
authors = [
{ name = "Miguel Ángel García", email="miguelangel.garcia@gmail.com" },
{ name = "Jan Wille", email = "mail@janwille.de" },
]
maintainers = [{ name = "Jan Wille", email = "mail@janwille.de" }]
keywords = ["characters", "keystrokes", "stdin", "command line"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: MIT License",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"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",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Environment :: Console",
"Intended Audience :: Developers",
"Topic :: Software Development",
"Topic :: Software Development :: User Interfaces",
]
description = "Library to easily read single chars and key strokes"
readme = { file = "README.md", content-type = "text/markdown" }
license = { file = "LICENCE" }

[project.urls]
Homepage = "https://pypi.org/project/readchar"
#Documentation = "https://readthedocs.org"
Repository = "https://github.com/magmax/python-readchar"
Issues = "https://github.com/magmax/python-readchar/issues"
Changelog = "https://github.com/magmax/python-readchar/releases"
7 changes: 5 additions & 2 deletions readchar/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"""Library to easily read single chars and key strokes"""
import importlib.metadata

__version__ = "4.0.7-dev0"

__doc__ = """Library to easily read single chars and key strokes"""

__version__ = importlib.metadata.version(__package__)
__all__ = ["readchar", "readkey", "key", "config"]

from sys import platform
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-e .
build
pre-commit
pytest
pytest>=6.0
pytest-cov
wheel
81 changes: 0 additions & 81 deletions setup.cfg

This file was deleted.

10 changes: 0 additions & 10 deletions setup.py

This file was deleted.

0 comments on commit 9ada618

Please sign in to comment.