From 8fddfb5b08a42ed840c4d940c4b570fc2d7cb507 Mon Sep 17 00:00:00 2001 From: Jan Wille Date: Thu, 16 May 2024 17:16:53 +0200 Subject: [PATCH 01/13] switch to `pyproject.tom` --- .coveragerc | 1 + .flake8 | 12 +++++ .github/workflows/publish.yaml | 8 ++-- .isort.cfg | 3 ++ .pre-commit-config.yaml | 7 --- .pytest.ini | 2 + Makefile | 2 +- pyproject.toml | 43 ++++++++++++++++++ readchar/__init__.py | 7 ++- requirements.txt | 7 +-- setup.cfg | 81 ---------------------------------- setup.py | 10 ----- 12 files changed, 75 insertions(+), 108 deletions(-) create mode 100644 .coveragerc create mode 100644 .flake8 create mode 100644 .isort.cfg create mode 100644 .pytest.ini create mode 100644 pyproject.toml delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..a6ea433 --- /dev/null +++ b/.coveragerc @@ -0,0 +1 @@ +omit = tests/* diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..f6e0c11 --- /dev/null +++ b/.flake8 @@ -0,0 +1,12 @@ +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 diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 95e3d8f..5e0c142 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -55,9 +55,9 @@ 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 = \"haha\"/" pyproject.toml - name: Build sdist and bdist_wheel run: | python setup.py sdist bdist_wheel @@ -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: diff --git a/.isort.cfg b/.isort.cfg new file mode 100644 index 0000000..0206677 --- /dev/null +++ b/.isort.cfg @@ -0,0 +1,3 @@ +profile = black +src_paths = readchar,tests +lines_after_imports = 2 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7dcef56..0535190 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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: diff --git a/.pytest.ini b/.pytest.ini new file mode 100644 index 0000000..008c585 --- /dev/null +++ b/.pytest.ini @@ -0,0 +1,2 @@ +testpaths = tests +addopts = -r fEsxwX -s --cov=readchar diff --git a/Makefile b/Makefile index b964dd0..77e8a58 100644 --- a/Makefile +++ b/Makefile @@ -11,4 +11,4 @@ pre-commit precommit: @pre-commit run -a build pack readchar: - @python setup.py sdist bdist_wheel + @python -m build diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..7eff1b7 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,43 @@ +[build-system] +requires = ["setuptools >= 61.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "readchar" +version = "4.1.0-dev0" +requires-python = ">= 3.8" +dependencies = [] +authors = [ + { name = "Miguel Ángel García" }, + { 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" diff --git a/readchar/__init__.py b/readchar/__init__.py index f902f6e..d7d4165 100644 --- a/readchar/__init__.py +++ b/readchar/__init__.py @@ -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 diff --git a/requirements.txt b/requirements.txt index 19134b3..e06690b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ --e . +build +wheel pre-commit -pytest +pytest>=6.0 pytest-cov -wheel +-e . diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 52295ed..0000000 --- a/setup.cfg +++ /dev/null @@ -1,81 +0,0 @@ -[metadata] -name = readchar -version = attr: readchar.__version__ -description = Library to easily read single chars and key strokes -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/magmax/python-readchar -author_email = miguelangel.garcia@gmail.com -license = MIT -license_files = LICENCE -classifiers = - Development Status :: 5 - Production/Stable - Environment :: Console - Intended Audience :: Developers - 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 - Topic :: Software Development - Topic :: Software Development :: User Interfaces -keywords = - characters - keystrokes - stdin - command line -project_urls = - Download = https://pypi.org/project/readchar/#files - Bug Tracker = https://github.com/magmax/python-readchar/issues - Source Code = https://github.com/magmax/python-readchar - -[options] -packages = find: -install_requires = - setuptools>=41.0 -python_requires = >=3.8 -include_package_data = True -zip_safe = false - -[options.packages.find] -exclude = - .git/ - .github/ - .venv/ - tests/ - -[options.package_data] -readchar = - py.typed - -[tool:pytest] -testpaths = tests -addopts = -r fEsxwX -s --cov=readchar - -[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 - -[tool.coverage.run] -omit = tests/* - -[isort] -profile = black -src_paths = readchar,tests -lines_after_imports = 2 diff --git a/setup.py b/setup.py deleted file mode 100644 index 64becd1..0000000 --- a/setup.py +++ /dev/null @@ -1,10 +0,0 @@ -from setuptools import setup - - -setup( - # The following is only here to make GitHubs dependency detection happy: - name="readchar", - # Author can not be read from setup.cfg as it causes encoding problems during - # windows installs - author="Miguel Ángel García", -) From 7a8e3550d7779a918033a7bb5b30eb1b05faec78 Mon Sep 17 00:00:00 2001 From: Jan Wille Date: Thu, 16 May 2024 17:20:28 +0200 Subject: [PATCH 02/13] use `build` command in pipeline as well --- .github/workflows/run-tests.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index 86d0598..cd12034 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -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 }} From ddcd085416917490e65bec2d99aa745b95ef4251 Mon Sep 17 00:00:00 2001 From: Jan Wille Date: Thu, 16 May 2024 17:22:47 +0200 Subject: [PATCH 03/13] fix `pytest.ini` --- .pytest.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/.pytest.ini b/.pytest.ini index 008c585..f43c620 100644 --- a/.pytest.ini +++ b/.pytest.ini @@ -1,2 +1,3 @@ +[pytest] testpaths = tests addopts = -r fEsxwX -s --cov=readchar From 204d4b4f46061e18650af12c5e5a802605d4f6cb Mon Sep 17 00:00:00 2001 From: Jan Wille Date: Thu, 16 May 2024 17:24:20 +0200 Subject: [PATCH 04/13] fix `.coveragerc` --- .coveragerc | 1 + 1 file changed, 1 insertion(+) diff --git a/.coveragerc b/.coveragerc index a6ea433..c712d25 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1 +1,2 @@ +[run] omit = tests/* From 3482c8a38bab5b4b6cae93e186cf7def4eea4fef Mon Sep 17 00:00:00 2001 From: Jan Wille Date: Thu, 16 May 2024 17:26:58 +0200 Subject: [PATCH 05/13] fix `isort.cfg` --- .isort.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/.isort.cfg b/.isort.cfg index 0206677..5def95d 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -1,3 +1,4 @@ +[settings] profile = black src_paths = readchar,tests lines_after_imports = 2 From 9c7e53be815b4d654cd5ca79f4eb8e61e6acc440 Mon Sep 17 00:00:00 2001 From: Jan Wille Date: Thu, 16 May 2024 17:27:34 +0200 Subject: [PATCH 06/13] fix `.flake8` --- .flake8 | 1 + 1 file changed, 1 insertion(+) diff --git a/.flake8 b/.flake8 index f6e0c11..feb0f84 100644 --- a/.flake8 +++ b/.flake8 @@ -1,3 +1,4 @@ +[flake8] max-complexity = 12 max-line-length = 88 exclude = From 316ce7d9afc5b88cc60cdb98fdc839a49d7073c4 Mon Sep 17 00:00:00 2001 From: Jan Wille Date: Thu, 16 May 2024 17:27:51 +0200 Subject: [PATCH 07/13] run pre-commit --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index e06690b..f49cc3c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ +-e . build -wheel pre-commit pytest>=6.0 pytest-cov --e . +wheel From 158656dd3045bd508eb58d805c071f943ab13925 Mon Sep 17 00:00:00 2001 From: Jan Wille Date: Thu, 16 May 2024 17:43:51 +0200 Subject: [PATCH 08/13] use `build` command in release-pipeline as well --- .github/workflows/publish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 5e0c142..7dff432 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -60,7 +60,7 @@ jobs: sed -i "s/version = \".*\"$/version = \"haha\"/" 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__ From 7f61c38e35f143c13555169a0e96d1ee13fe8bc6 Mon Sep 17 00:00:00 2001 From: Jan Wille Date: Thu, 16 May 2024 17:46:57 +0200 Subject: [PATCH 09/13] fix release-pipeline dependencies --- .github/workflows/publish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 7dff432..b6609f1 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -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}" From 844104fcd06ddbb71bb1464fc2fb48e7c2aae4d4 Mon Sep 17 00:00:00 2001 From: Jan Wille Date: Thu, 16 May 2024 17:50:15 +0200 Subject: [PATCH 10/13] release-pipline:: fix sed inserting wrong string --- .github/workflows/publish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index b6609f1..5306534 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -57,7 +57,7 @@ jobs: - name: Write Version to pyproject.toml run: | - sed -i "s/version = \".*\"$/version = \"haha\"/" pyproject.toml + sed -i "s/version = \".*\"$/version = \"$VERSION\"/" pyproject.toml - name: Build sdist and bdist_wheel run: | python -m build From b13896b2641123ecd77fe4875b7b861ba046b223 Mon Sep 17 00:00:00 2001 From: Cube707 Date: Thu, 16 May 2024 15:54:09 +0000 Subject: [PATCH 11/13] increment version after release --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7eff1b7..46f8340 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "readchar" -version = "4.1.0-dev0" +version = = "4.1.0-dev3" requires-python = ">= 3.8" dependencies = [] authors = [ From 619234bb8cbd5cc6d16320ab7abefa3df0992eb3 Mon Sep 17 00:00:00 2001 From: Jan Wille Date: Thu, 16 May 2024 17:56:08 +0200 Subject: [PATCH 12/13] =?UTF-8?q?add=20email=20of=20author=20Miguel=20?= =?UTF-8?q?=C3=81ngel=20Garc=C3=ADa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 46f8340..4624d13 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,11 +4,11 @@ build-backend = "setuptools.build_meta" [project] name = "readchar" -version = = "4.1.0-dev3" +version = "4.1.0-dev3" requires-python = ">= 3.8" dependencies = [] authors = [ - { name = "Miguel Ángel García" }, + { 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" }] From b13e497aa9d1ecfb1934c10bbe82f78c3682e6ae Mon Sep 17 00:00:00 2001 From: Jan Wille Date: Thu, 16 May 2024 17:58:06 +0200 Subject: [PATCH 13/13] release-pipline:: fix double equals sign beeing inserted --- .github/workflows/publish.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 5306534..4932ed4 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -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\"/" pyproject.toml + 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\"/" pyproject.toml + sed -i "s/version = \".*\"$/version = \"$v\"/" pyproject.toml - name: commit new version-number uses: stefanzweifel/git-auto-commit-action@v4 with: