diff options
author | Alexey Stepanov <penguinolog@users.noreply.github.com> | 2023-04-03 09:45:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-03 09:45:13 +0200 |
commit | 11a470c3d02a204faf7adf6a361ae8f51989d7dc (patch) | |
tree | 37c0149db33f2d19128c35ae1446e543aa351e63 | |
parent | 0a5518eb04ee6b22d425dacd2be0897916380c7f (diff) | |
download | urwid-11a470c3d02a204faf7adf6a361ae8f51989d7dc.tar.gz |
Update readme and build system (#526)
* Sunset of travis: non-commercial travis is closed
* Use PEP517 driven build
* stop calling tests deprecated way (via setup.py)
* Update readme to allow removing of magic (badges maybe included in package)
* Temporary do not display coverage: coveralls require reconfiguration
* Remove unsupported python mention in readme
Co-authored-by: Aleksei Stepanov <alekseis@nvidia.com>
-rw-r--r-- | .coveragerc | 5 | ||||
-rw-r--r-- | .github/workflows/pythonpackage.yml | 6 | ||||
-rw-r--r-- | .travis.yml | 25 | ||||
-rw-r--r-- | README.rst | 34 | ||||
-rw-r--r-- | classifiers.txt | 19 | ||||
-rw-r--r-- | pyproject.toml | 86 | ||||
-rw-r--r-- | setup.py | 31 | ||||
-rw-r--r-- | test_requirements.txt | 4 | ||||
-rw-r--r-- | tox.ini | 18 | ||||
-rw-r--r-- | urwid/tests/test_event_loops.py | 44 | ||||
-rw-r--r-- | urwid/tests/test_signals.py | 32 |
11 files changed, 174 insertions, 130 deletions
diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 57420f2..0000000 --- a/.coveragerc +++ /dev/null @@ -1,5 +0,0 @@ -[run] -omit = - .tox/* - setup.py - diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 069803e..62cc183 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -20,10 +20,12 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip wheel - pip install twisted trio "tornado<5.0.0" coverage + pip install -r test_requirements.txt + - name: Install package for test + run: pip install -e . - name: Test run: | - coverage run ./setup.py test + coverage run -m unittest discover -s urwid -v coverage report # - name: Coveralls # uses: coverallsapp/github-action@v1
\ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 17e452e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ -language: python -#dist: bionic -matrix: - include: - - python: 3.7 - env: TOXENV=py37 - - python: 3.8 - env: TOXENV=py38 - - python: 3.9 - env: TOXENV=py39 - - python: 3.10 - env: TOXENV=py310 -# - python: 3.11 -# env: TOXENV=py311 -before_install: - - "sudo apt-get update" - - "sudo apt-get install python-gi python3-gi" -install: - - "pip install tox coverage coveralls" -script: - - "tox" - - "coverage report" -after_success: - - "coveralls" - @@ -1,8 +1,6 @@ Urwid ===== -|pypi| |docs| |travis| |coveralls| - -.. content-start +|pypi| |docs| |ci| About ===== @@ -50,19 +48,20 @@ To test code in all Python versions: .. code:: bash - tox # Test all versions specified in tox.ini: - tox -e py36 # Test Python 3.6 only - tox -e py27,py36,pypy # Test Python 2.7, Python 3.6 & pypy + tox # Test all versions specified in tox.ini: + tox -e py39 # Test Python 3.9 only + tox -e py39,py10,pypy3 # Test Python 3.9, Python 3.10 & pypy3 Supported Python versions ========================= -- 2.7 -- 3.5 -- 3.6 - 3.7 - 3.8 -- pypy +- 3.9 +- 3.10 +- 3.11 +- 3.12 +- pypy3 Authors ======= @@ -220,17 +219,18 @@ Contributors `zrax <//github.com/zrax>`_ -.. |pypi| image:: http://img.shields.io/pypi/v/urwid.svg +.. |pypi| image:: https://img.shields.io/pypi/v/urwid :alt: current version on PyPi :target: https://pypi.python.org/pypi/urwid -.. |docs| image:: https://readthedocs.org/projects/urwid/badge/ - :alt: docs link - :target: http://urwid.readthedocs.org/en/latest/ +.. |docs| image:: https://readthedocs.org/projects/urwid/badge/?version=latest + :alt: Documentation Status + :target: https://urwid.readthedocs.io/en/latest/?badge=latest + +.. |ci| image:: https://github.com/urwid/urwid/actions/workflows/pythonpackage.yml/badge.svg?branch=master + :target: https://github.com/urwid/urwid/actions + :alt: CI status -.. |travis| image:: https://travis-ci.org/urwid/urwid.svg?branch=master - :alt: build status - :target: https://travis-ci.org/urwid/urwid/ .. |coveralls| image:: https://coveralls.io/repos/github/urwid/urwid/badge.svg :alt: test coverage diff --git a/classifiers.txt b/classifiers.txt new file mode 100644 index 0000000..a01ca86 --- /dev/null +++ b/classifiers.txt @@ -0,0 +1,19 @@ +Development Status :: 5 - Production/Stable +Environment :: Console +Environment :: Console :: Curses +Intended Audience :: Developers +License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL) +Operating System :: POSIX +Operating System :: Unix +Operating System :: MacOS :: MacOS X +Topic :: Software Development :: Libraries :: Python Modules +Topic :: Software Development :: Widget Sets +Programming Language :: Python :: 3 +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 :: 3 :: Only +Programming Language :: Python :: Implementation :: CPython +Programming Language :: Python :: Implementation :: PyPy
\ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..7b8ae12 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,86 @@ +[build-system] +# Minimum requirements for the build system to execute. +# PEP 508 specifications for PEP 518. +requires = [ + "setuptools >= 61.0.0", + "wheel" +] +build-backend="setuptools.build_meta" + +[project] +name = "urwid" +description = "A full-featured console (xterm et al.) user interface library" +requires-python = ">=3.7.0" +keywords = ["curses", "ui", "widget", "scroll", "listbox", "user interface", "text layout", "console", "ncurses"] +license={text="LGPL-2.1-only"} # Use SPDX classifier +readme = {file = "README.rst", content-type = "text/x-rst"} +authors=[{name="Ian Ward", email="ian@excess.org"}] +dynamic = ["classifiers", "version"] # "dependencies", + +[project.urls] +"Homepage" = "https://urwid.org/" +"Documentation" = "https://urwid.org/manual/index.html" +"Repository" = "https://github.com/urwid/urwid" +"Bug Tracker" = "https://github.com/urwid/urwid/issues" + +[tool.setuptools] +platforms=["unix-like"] +zip-safe = false + +[tool.setuptools.packages.find] +exclude = [ + "doc", + "test", + ".*" +] +include = ["urwid", 'urwid.tests'] +namespaces = false + +[tool.setuptools.dynamic] +#dependencies = {file = ["requirements.txt"]} +classifiers = {file = ["classifiers.txt"]} + +[tool.distutils.bdist_wheel] +universal = 0 + +[tool.isort] +profile = "black" +line_length = 120 + +[tool.coverage.run] +omit = ["urwid/tests/*", ".tox/*", "setup.py"] +branch = true + +[tool.coverage.report] +exclude_lines = [ + # Have to re-enable the standard pragma + "pragma: no cover", + + # Don't complain about missing debug-only code: + "def __repr__", + + # Don't complain if tests don't hit defensive assertion code: + "raise NotImplementedError", + + # Exclude methods marked as abstract + "@abstractmethod", + + # Exclude import statements + "^from\b", + "^import\b", + + # Exclude variable declarations that are executed when file is loaded + "^[a-zA-Z_]+\b\\s=", + + # Code for static analysis is never covered: + "if typing.TYPE_CHECKING:", + + # Fallback code with no installed deps is almost impossible to cover properly + "except ImportError:", + + # Don't complain if non-runnable code isn't run: + "if __name__ == .__main__.:", + + # OS Specific + "if platform.system()", +]
\ No newline at end of file @@ -33,40 +33,11 @@ with open(os.path.join("urwid", "version.py")) as f: release = locals_['__version__'] -with open("README.rst") as f: - long_description = f.read().split('.. content-start\n', 1)[1] - - setup_d = { 'name': "urwid", 'version': release, - 'author': "Ian Ward", - 'author_email': "ian@excess.org", 'ext_modules': [Extension('urwid.str_util', sources=['source/str_util.c'])], - 'packages': ['urwid', 'urwid.tests'], 'url': "https://urwid.org/", 'license': "LGPL", - 'keywords': "curses ui widget scroll listbox user interface text layout console ncurses", - 'platforms': "unix-like", 'description': "A full-featured console (xterm et al.) user interface library", - 'long_description': long_description, 'classifiers': [ - "Development Status :: 5 - Production/Stable", - "Environment :: Console", - "Environment :: Console :: Curses", - "Intended Audience :: Developers", - "License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)", - "Operating System :: POSIX", - "Operating System :: Unix", - "Operating System :: MacOS :: MacOS X", - "Topic :: Software Development :: Libraries :: Python Modules", - "Topic :: Software Development :: Widget Sets", - "Programming Language :: Python :: 3", - "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 :: 3 :: Only", - "Programming Language :: Python :: Implementation :: PyPy", - ], - 'zip_safe': False, + 'url': "https://urwid.org/", 'test_suite': 'urwid.tests', } diff --git a/test_requirements.txt b/test_requirements.txt new file mode 100644 index 0000000..d6c52e6 --- /dev/null +++ b/test_requirements.txt @@ -0,0 +1,4 @@ +tornado<5.0.0 +coverage[toml] +twisted +trio
\ No newline at end of file @@ -1,16 +1,18 @@ [tox] envlist = py3{7,8,9,10,11},pypy3 +skip_missing_interpreters = True [testenv] usedevelop = true -deps = - setuptools - tornado<5.0.0 - coverage - twisted - trio +deps = -r {toxinidir}/test_requirements.txt commands = coverage run -m unittest discover -s urwid -v -[isort] -profile = black
\ No newline at end of file + coverage report + +[testenv:readme] +deps = + twine build +commands = + python -m build + twine check {toxinidir}/dist/*
\ No newline at end of file diff --git a/urwid/tests/test_event_loops.py b/urwid/tests/test_event_loops.py index 261a614..77dbae1 100644 --- a/urwid/tests/test_event_loops.py +++ b/urwid/tests/test_event_loops.py @@ -1,6 +1,8 @@ from __future__ import annotations +import asyncio import os +import sys import unittest import urwid @@ -181,35 +183,31 @@ else: evl.alarm(0.5, lambda: 1 / 0) # Simulate error in event loop self.assertRaises(ZeroDivisionError, evl.run) -try: - import asyncio -except ImportError: - pass -else: - if not hasattr(asyncio, 'ensure_future'): - #-- Python < 3.4.4 (e.g. Debian Jessie) - asyncio.ensure_future = getattr(asyncio, 'async') - class AsyncioEventLoopTest(unittest.TestCase, EventLoopTestMixin): - def setUp(self): - self.evl = urwid.AsyncioEventLoop() +class AsyncioEventLoopTest(unittest.TestCase, EventLoopTestMixin): + def setUp(self): + self.evl = urwid.AsyncioEventLoop() - _expected_idle_handle = None + _expected_idle_handle = None - def test_error(self): - evl = self.evl - evl.alarm(0.5, lambda: 1 / 0) # Simulate error in event loop - self.assertRaises(ZeroDivisionError, evl.run) + def test_error(self): + evl = self.evl + evl.alarm(0.5, lambda: 1 / 0) # Simulate error in event loop + self.assertRaises(ZeroDivisionError, evl.run) - def test_coroutine_error(self): - evl = self.evl + @unittest.skipIf( + sys.implementation.name == "pypy", + "Well known dead wait (lock?) on pypy.", + ) + def test_coroutine_error(self): + evl = self.evl - async def error_coro(): - result = 1 / 0 # Simulate error in coroutine - return result + async def error_coro(): + result = 1 / 0 # Simulate error in coroutine + return result - asyncio.ensure_future(error_coro()) - self.assertRaises(ZeroDivisionError, evl.run) + asyncio.ensure_future(error_coro()) + self.assertRaises(ZeroDivisionError, evl.run) try: diff --git a/urwid/tests/test_signals.py b/urwid/tests/test_signals.py index 1842bd1..05e612f 100644 --- a/urwid/tests/test_signals.py +++ b/urwid/tests/test_signals.py @@ -1,19 +1,7 @@ import unittest +from unittest.mock import Mock -try: - from unittest.mock import Mock -except ImportError: - # Python2, rely on PyPi - from mock import Mock - -from urwid import ( - Edit, - Signals, - connect_signal, - disconnect_signal, - emit_signal, - register_signal, -) +from urwid import Edit, Signals, connect_signal, disconnect_signal, emit_signal, register_signal class SiglnalsTest(unittest.TestCase): @@ -39,12 +27,12 @@ class SiglnalsTest(unittest.TestCase): def test_weak_del(self): emitter = SiglnalsTest.EmClass() - w1 = Mock() - w2 = Mock() - w3 = Mock() + w1 = Mock(name="w1") + w2 = Mock(name="w2") + w3 = Mock(name="w3") - handler1 = Mock() - handler2 = Mock() + handler1 = Mock(name="handler1") + handler2 = Mock(name="handler2") k1 = connect_signal(emitter, 'test', handler1, weak_args=[w1], user_args=[42, "abc"]) k2 = connect_signal(emitter, 'test', handler2, weak_args=[w2, w3], user_args=[8]) @@ -57,7 +45,11 @@ class SiglnalsTest(unittest.TestCase): handler1.reset_mock() handler2.reset_mock() del w1 - self.assertEqual(len(getattr(emitter, Signals._signal_attr)['test']), 1) + self.assertEqual( + len(getattr(emitter, Signals._signal_attr)['test']), + 1, + getattr(emitter, Signals._signal_attr)['test'] + ) emit_signal(emitter, 'test', "Bar") handler1.assert_not_called() handler2.assert_called_once_with(w2, w3, 8, "Bar") |