diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 99ead71..ecdfc07 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -28,3 +28,6 @@ jobs: - name: Publish package distributions to PyPI uses: pypa/gh-action-pypi-publish@release/v1 + with: + verbose: true + print-hash: true diff --git a/.gitignore b/.gitignore index 889669a..eab326c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +/html2text/_version.py + *.py[co] *.bak build diff --git a/README.md b/README.md index 9b7f607..15ff7a4 100644 --- a/README.md +++ b/README.md @@ -62,21 +62,41 @@ Hello, [world](https://www.google.com/earth/)! `html2text` is available on pypi https://pypi.org/project/html2text/ -``` +```shell $ pip install html2text ``` +## Development -## How to run unit tests +### How to run unit tests - tox +```shell +$ tox +``` To see the coverage results: - coverage html +```shell +$ coverage html +``` then open the `./htmlcov/index.html` file in your browser. + +### Code Quality & Pre Commit + +The CI runs several linting steps, including: + +- mypy +- Flake8 +- Black + +To make sure the code passes the CI linting steps, run: + +```shell +$ tox -e pre-commit +``` + ## Documentation Documentation lives [here](https://github.com/Alir3z4/html2text/blob/master/docs/usage.md) diff --git a/docs/usage.md b/docs/usage.md index 09a1ab3..3bef7f8 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -21,9 +21,9 @@ $ pip install html2text Clone the repository from https://github.com/Alir3z4/html2text ``` -$ git clone --depth 1 https://github.com/Alir3z4/html2text.git -$ python setup.py build -$ python setup.py install +$ git clone --depth 50 https://github.com/Alir3z4/html2text.git +$ python -m build -nwx +$ python -m pip install --upgrade ./dist/*.whl ``` diff --git a/html2text/__init__.py b/html2text/__init__.py index 5471f9f..621fa74 100644 --- a/html2text/__init__.py +++ b/html2text/__init__.py @@ -10,6 +10,7 @@ from . import config from ._typing import OutCallback +from ._version import __version_tuple__ from .elements import AnchorElement, ListElement from .utils import ( control_character_replacements, @@ -28,8 +29,7 @@ unifiable_n, ) -__version__ = (2024, 2, 26) - +__version__ = __version_tuple__ # TODO: # Support decoded entities with UNIFIABLE. diff --git a/html2text/cli.py b/html2text/cli.py index 202a77f..e19a099 100644 --- a/html2text/cli.py +++ b/html2text/cli.py @@ -1,7 +1,8 @@ import argparse import sys -from . import HTML2Text, __version__, config +from . import HTML2Text, config +from ._version import __version_tuple__ as __version__ def main() -> None: diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..6e6aa6c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,65 @@ +[build-system] +requires = ["setuptools>=61.2", "setuptools_scm[toml]>=3.4.3"] +build-backend = "setuptools.build_meta" + +[project] +name = "html2text" +description = "Turn HTML into equivalent Markdown-structured text." +readme = "README.md" +authors = [{name = "Aaron Swartz", email = "me@aaronsw.com"}] +maintainers = [{name = "Alireza Savand", email = "alireza.savand@gmail.com"}] +license = "GPL-3.0-or-later" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", +] +urls = {Homepage = "https://github.com/Alir3z4/html2text/"} +requires-python = ">=3.9" +dynamic = ["version"] + +[project.scripts] +html2text = "html2text.cli:main" + +[tool.setuptools] +zip-safe = false +packages = ["html2text"] +platforms = ["OS Independent"] +include-package-data = false + +[tool.setuptools.package-data] +html2text = ["py.typed"] + +[tool.setuptools_scm] +write_to = "html2text/_version.py" + +[tool.black] +line-length = 88 +target-version = ['py313'] +extend-exclude = ''' +/( + html2text/_version.py +) +''' + +[tool.flake8] # you will need Flake8-pyproject +max_line_length = "88" +extend-ignore = "E203" + +[tool.isort] +profile = "black" +combine_as_imports = true +extend_skip = ["html2text/_version.py"] + +[tool.mypy] +python_version = "3.9" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index d2d5921..0000000 --- a/setup.cfg +++ /dev/null @@ -1,53 +0,0 @@ -[metadata] -name = html2text -version = attr: html2text.__version__ -description = Turn HTML into equivalent Markdown-structured text. -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/Alir3z4/html2text/ -author = Aaron Swartz -author_email = me@aaronsw.com -maintainer = Alireza Savand -maintainer_email = alireza.savand@gmail.com -license = GNU GPL 3 -classifiers = - Development Status :: 5 - Production/Stable - Intended Audience :: Developers - License :: OSI Approved :: GNU General Public License (GPL) - Operating System :: OS Independent - Programming Language :: Python - Programming Language :: Python :: 3 - 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 :: 3 :: Only - Programming Language :: Python :: Implementation :: CPython - Programming Language :: Python :: Implementation :: PyPy -platform = OS Independent - -[options] -zip_safe = False -packages = html2text -python_requires = >=3.8 - -[options.entry_points] -console_scripts = - html2text = html2text.cli:main - -[options.package_data] -html2text = py.typed - -[flake8] -max_line_length = 88 -extend-ignore = E203 -extend-exclude = env/ - -[isort] -combine_as_imports = True -profile = black -extend_skip = env/ - -[mypy] -python_version = 3.8 diff --git a/setup.py b/setup.py deleted file mode 100644 index 6068493..0000000 --- a/setup.py +++ /dev/null @@ -1,3 +0,0 @@ -from setuptools import setup - -setup() diff --git a/tox.ini b/tox.ini index d2e10f6..ceadecc 100644 --- a/tox.ini +++ b/tox.ini @@ -18,29 +18,37 @@ setenv = [testenv:black] basepython = python3 -commands = - black --target-version py38 --line-length 88 --check --diff . -deps = - black +commands = black --check --diff . +deps = black skip_install = true [testenv:flake8] basepython = python3 -commands = - flake8 --max-line-length 88 +commands = flake8 deps = flake8 + Flake8-pyproject skip_install = true [testenv:isort] basepython = python3 -commands = - isort --check-only --diff . -deps = - isort +commands = isort --check-only --diff . +deps = isort skip_install = true [testenv:mypy] commands = mypy --strict html2text deps = mypy + +[testenv:pre-commit] +basepython = python3 +commands = + isort --atomic . + flake8 + black . +deps = + isort + flake8 + Flake8-pyproject + black skip_install = true