From 41a1151c1a2cd8995b0e68c9d41d8fa6c9d1dc97 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Sat, 14 Jan 2023 10:40:17 +0000 Subject: [PATCH] Adopt PEP-621 --- .flake8 | 4 ++ .gitignore | 1 + MANIFEST.in | 1 - ansi2html/__init__.py | 3 -- docs/source/conf.py | 5 +- pyproject.toml | 58 ++++++++++++++++++++++ setup.cfg | 59 ----------------------- src/ansi2html/__init__.py | 19 ++++++++ {ansi2html => src/ansi2html}/__main__.py | 0 {ansi2html => src/ansi2html}/converter.py | 0 {ansi2html => src/ansi2html}/py.typed | 0 {ansi2html => src/ansi2html}/style.py | 0 {ansi2html => src/ansi2html}/util.py | 0 13 files changed, 83 insertions(+), 67 deletions(-) create mode 100644 .flake8 delete mode 100644 ansi2html/__init__.py delete mode 100644 setup.cfg create mode 100644 src/ansi2html/__init__.py rename {ansi2html => src/ansi2html}/__main__.py (100%) rename {ansi2html => src/ansi2html}/converter.py (100%) rename {ansi2html => src/ansi2html}/py.typed (100%) rename {ansi2html => src/ansi2html}/style.py (100%) rename {ansi2html => src/ansi2html}/util.py (100%) diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..95e3ee9 --- /dev/null +++ b/.flake8 @@ -0,0 +1,4 @@ +[flake8] +format = pylint +# E203: https://github.com/python/black/issues/315 +ignore = E741,W503,W504,H,E501,E203,D diff --git a/.gitignore b/.gitignore index d83ebd5..e06a0cf 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ coverage_html_report .coverage docs/source/_build man/ansi2html.1.xml +src/ansi2html/_version.py diff --git a/MANIFEST.in b/MANIFEST.in index aea554c..8051ee0 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,6 +3,5 @@ include LICENSE include man/asciidoc.conf include man/ansi2html.1 include man/ansi2html.1.txt -include ansi2html/py.typed recursive-include tests * recursive-exclude tests *.pyc diff --git a/ansi2html/__init__.py b/ansi2html/__init__.py deleted file mode 100644 index db1f4fd..0000000 --- a/ansi2html/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from ansi2html.converter import Ansi2HTMLConverter - -__all__ = ["Ansi2HTMLConverter"] diff --git a/docs/source/conf.py b/docs/source/conf.py index ce0e1d9..93f876d 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -4,7 +4,7 @@ # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html -from setuptools_scm import get_version +from ansi2html import __version__ as release # mypy: ignore # noqa: 401 # -- Project information ----------------------------------------------------- @@ -12,9 +12,6 @@ copyright = "2021, Ralph Bean, Robin Schneider and various contributors" author = "Ralph Bean, Robin Schneider and various contributors" -# The full version, including alpha/beta/rc tags -release = get_version(root="../..", relative_to=__file__) - # -- General configuration --------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be diff --git a/pyproject.toml b/pyproject.toml index a17ee9c..285c510 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,6 +2,58 @@ requires = ["setuptools >= 45.0.0", "setuptools_scm[toml] >= 7.0.0"] build-backend = "setuptools.build_meta" +[project] +# https://peps.python.org/pep-0621/#readme +requires-python = ">=3.6" +dynamic = ["version"] +name = "ansi2html" +description = "Checks playbooks for practices and behavior that could potentially be improved" +readme = "README.rst" +authors = [{ "name" = "Ralph Bean", "email" = "rbean@redhat.com" }] +maintainers = [{ "name" = "Ralph Bean", "email" = "rbean@redhat.com" }] +license = { text = "LGPLv3+" } +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Intended Audience :: Developers", + "Intended Audience :: System Administrators", + "License :: OSI Approved :: MIT License", + "Operating System :: MacOS", + "Operating System :: POSIX", + "License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "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", + "Topic :: Software Development :: Quality Assurance", + "Topic :: Software Development :: Testing", + "Topic :: System :: Systems Administration", + "Topic :: Text Processing :: Markup :: HTML", + "Topic :: Text Processing :: Markup", + "Topic :: Text Processing", + "Topic :: Utilities", +] +keywords = ["ansi", "html", "color"] +dependencies = ['importlib-metadata; python_version<"3.8"'] + +[project.urls] +homepage = "https://github.com/pycontribs/ansi2html" +documentation = "https://ansi2html.readthedocs.io/" +repository = "https://github.com/pycontribs/ansi2html" +changelog = "https://github.com/pycontribs/ansi2html/releases" + +[project.scripts] +ansi2html = "ansi2html.__main__:main" + +[project.optional-dependencies] +docs = ["sphinx", "sphinx_rtd_theme"] +test = ["pytest", "pytest-cov"] + [tool.isort] profile = "black" @@ -9,6 +61,11 @@ profile = "black" warn_return_any = true warn_unused_configs = true +[[tool.mypy.overrides]] +module = ["ansi2html._version"] +ignore_missing_imports = true +ignore_errors = true + [tool.pylint."MESSAGES CONTROL"] disable = [ # TODO(ssbarnea): remove temporary skips adding during initial adoption: @@ -41,3 +98,4 @@ output-format = "colorized" [tool.setuptools_scm] local_scheme = "no-local-version" +write_to = "src/ansi2html/_version.py" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 4a034a4..0000000 --- a/setup.cfg +++ /dev/null @@ -1,59 +0,0 @@ -[metadata] -name = ansi2html -url = https://github.com/pycontribs/ansi2html -project_urls = - Bug Tracker = https://github.com/pycontribs/ansi2html/issues - Release Management = https://github.com/pycontribs/ansi2html/releases - CI = https://github.com/pycontribs/ansi2html/actions - Source Code = https://github.com/pycontribs/ansi2html -long_description = file: README.rst -long_description_content_type = text/x-rst -author = Ralph Bean -author_email = rbean@redhat.com -classifiers = - Development Status :: 5 - Production/Stable - License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+) - Intended Audience :: Developers - Intended Audience :: System Administrators - 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 - Topic :: Text Processing - Topic :: Text Processing :: Markup - Topic :: Text Processing :: Markup :: HTML - -[bdist_rpm] -requires = python >= 3.7 - -[options] -use_scm_version = True -python_requires = >=3.7 -packages = find: -include_package_data = True -zip_safe = False -install_requires = - importlib-metadata; python_version<"3.8" - -[options.entry_points] -console_scripts = - ansi2html = ansi2html.__main__:main - -[options.packages.find] -where = . - -[options.extras_require] -docs = - Sphinx - setuptools_scm - sphinx_rtd_theme -test = - pytest - pytest-cov - -[flake8] -format = pylint -# E203: https://github.com/python/black/issues/315 -ignore = E741,W503,W504,H,E501,E203,D diff --git a/src/ansi2html/__init__.py b/src/ansi2html/__init__.py new file mode 100644 index 0000000..dbfe281 --- /dev/null +++ b/src/ansi2html/__init__.py @@ -0,0 +1,19 @@ +from __future__ import annotations + +from ansi2html.converter import Ansi2HTMLConverter + +try: + # pyright: reportMissingImport=false + from ansi2html._version import __version__ # mypy: disable +except ImportError: # pragma: no branch + + try: + import pkg_resources + + __version__ = pkg_resources.get_distribution("ansi2html").version + except Exception: # pylint: disable=broad-except + # this is the fallback SemVer version picked by setuptools_scm when tag + # information is not available. + __version__ = "0.1.dev1" + +__all__ = ("Ansi2HTMLConverter", "__version__") diff --git a/ansi2html/__main__.py b/src/ansi2html/__main__.py similarity index 100% rename from ansi2html/__main__.py rename to src/ansi2html/__main__.py diff --git a/ansi2html/converter.py b/src/ansi2html/converter.py similarity index 100% rename from ansi2html/converter.py rename to src/ansi2html/converter.py diff --git a/ansi2html/py.typed b/src/ansi2html/py.typed similarity index 100% rename from ansi2html/py.typed rename to src/ansi2html/py.typed diff --git a/ansi2html/style.py b/src/ansi2html/style.py similarity index 100% rename from ansi2html/style.py rename to src/ansi2html/style.py diff --git a/ansi2html/util.py b/src/ansi2html/util.py similarity index 100% rename from ansi2html/util.py rename to src/ansi2html/util.py