Skip to content

Commit fcbc443

Browse files
Alir3z4KOLANICH
andauthored
Modernization of wheel building process (#436)
* Added `pyproject.toml` according to `PEP 517`. * Removed `setup.py` - it is no longer needed. * Started using `setuptools_scm` for a better version number containing git commit hash. * Started using `setuptools_scm` for fetching version automatically from git tags. * Migrated the metadata into `PEP 621`-compliant `pyproject.toml`. * Final cleanups on modernization of build process. * Adding verbosity and printing the hash of the build on PyPI publishing. --------- Co-authored-by: KOLANICH <kolan_n@mail.ru>
1 parent 14c8b25 commit fcbc443

File tree

10 files changed

+119
-76
lines changed

10 files changed

+119
-76
lines changed

.github/workflows/pypi.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ jobs:
2828
2929
- name: Publish package distributions to PyPI
3030
uses: pypa/gh-action-pypi-publish@release/v1
31+
with:
32+
verbose: true
33+
print-hash: true

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/html2text/_version.py
2+
13
*.py[co]
24
*.bak
35
build

README.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,41 @@ Hello, [world](https://www.google.com/earth/)!
6262
`html2text` is available on pypi
6363
https://pypi.org/project/html2text/
6464

65-
```
65+
```shell
6666
$ pip install html2text
6767
```
6868

69+
## Development
6970

70-
## How to run unit tests
71+
### How to run unit tests
7172

72-
tox
73+
```shell
74+
$ tox
75+
```
7376

7477
To see the coverage results:
7578

76-
coverage html
79+
```shell
80+
$ coverage html
81+
```
7782

7883
then open the `./htmlcov/index.html` file in your browser.
7984

85+
86+
### Code Quality & Pre Commit
87+
88+
The CI runs several linting steps, including:
89+
90+
- mypy
91+
- Flake8
92+
- Black
93+
94+
To make sure the code passes the CI linting steps, run:
95+
96+
```shell
97+
$ tox -e pre-commit
98+
```
99+
80100
## Documentation
81101

82102
Documentation lives [here](https://github.com/Alir3z4/html2text/blob/master/docs/usage.md)

docs/usage.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ $ pip install html2text
2121
Clone the repository from https://github.com/Alir3z4/html2text
2222

2323
```
24-
$ git clone --depth 1 https://github.com/Alir3z4/html2text.git
25-
$ python setup.py build
26-
$ python setup.py install
24+
$ git clone --depth 50 https://github.com/Alir3z4/html2text.git
25+
$ python -m build -nwx
26+
$ python -m pip install --upgrade ./dist/*.whl
2727
```
2828

2929

html2text/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from . import config
1212
from ._typing import OutCallback
13+
from ._version import __version_tuple__
1314
from .elements import AnchorElement, ListElement
1415
from .utils import (
1516
control_character_replacements,
@@ -28,8 +29,7 @@
2829
unifiable_n,
2930
)
3031

31-
__version__ = (2024, 2, 26)
32-
32+
__version__ = __version_tuple__
3333

3434
# TODO:
3535
# Support decoded entities with UNIFIABLE.

html2text/cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import argparse
22
import sys
33

4-
from . import HTML2Text, __version__, config
4+
from . import HTML2Text, config
5+
from ._version import __version_tuple__ as __version__
56

67

78
def main() -> None:

pyproject.toml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
[build-system]
2+
requires = ["setuptools>=61.2", "setuptools_scm[toml]>=3.4.3"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "html2text"
7+
description = "Turn HTML into equivalent Markdown-structured text."
8+
readme = "README.md"
9+
authors = [{name = "Aaron Swartz", email = "me@aaronsw.com"}]
10+
maintainers = [{name = "Alireza Savand", email = "alireza.savand@gmail.com"}]
11+
license = "GPL-3.0-or-later"
12+
classifiers = [
13+
"Development Status :: 5 - Production/Stable",
14+
"Intended Audience :: Developers",
15+
"Operating System :: OS Independent",
16+
"Programming Language :: Python",
17+
"Programming Language :: Python :: 3",
18+
"Programming Language :: Python :: 3.9",
19+
"Programming Language :: Python :: 3.10",
20+
"Programming Language :: Python :: 3.11",
21+
"Programming Language :: Python :: 3.12",
22+
"Programming Language :: Python :: 3.13",
23+
"Programming Language :: Python :: 3 :: Only",
24+
"Programming Language :: Python :: Implementation :: CPython",
25+
"Programming Language :: Python :: Implementation :: PyPy",
26+
]
27+
urls = {Homepage = "https://github.com/Alir3z4/html2text/"}
28+
requires-python = ">=3.9"
29+
dynamic = ["version"]
30+
31+
[project.scripts]
32+
html2text = "html2text.cli:main"
33+
34+
[tool.setuptools]
35+
zip-safe = false
36+
packages = ["html2text"]
37+
platforms = ["OS Independent"]
38+
include-package-data = false
39+
40+
[tool.setuptools.package-data]
41+
html2text = ["py.typed"]
42+
43+
[tool.setuptools_scm]
44+
write_to = "html2text/_version.py"
45+
46+
[tool.black]
47+
line-length = 88
48+
target-version = ['py313']
49+
extend-exclude = '''
50+
/(
51+
html2text/_version.py
52+
)
53+
'''
54+
55+
[tool.flake8] # you will need Flake8-pyproject
56+
max_line_length = "88"
57+
extend-ignore = "E203"
58+
59+
[tool.isort]
60+
profile = "black"
61+
combine_as_imports = true
62+
extend_skip = ["html2text/_version.py"]
63+
64+
[tool.mypy]
65+
python_version = "3.9"

setup.cfg

Lines changed: 0 additions & 53 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

tox.ini

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,37 @@ setenv =
1818

1919
[testenv:black]
2020
basepython = python3
21-
commands =
22-
black --target-version py38 --line-length 88 --check --diff .
23-
deps =
24-
black
21+
commands = black --check --diff .
22+
deps = black
2523
skip_install = true
2624

2725
[testenv:flake8]
2826
basepython = python3
29-
commands =
30-
flake8 --max-line-length 88
27+
commands = flake8
3128
deps =
3229
flake8
30+
Flake8-pyproject
3331
skip_install = true
3432

3533
[testenv:isort]
3634
basepython = python3
37-
commands =
38-
isort --check-only --diff .
39-
deps =
40-
isort
35+
commands = isort --check-only --diff .
36+
deps = isort
4137
skip_install = true
4238

4339
[testenv:mypy]
4440
commands = mypy --strict html2text
4541
deps = mypy
42+
43+
[testenv:pre-commit]
44+
basepython = python3
45+
commands =
46+
isort --atomic .
47+
flake8
48+
black .
49+
deps =
50+
isort
51+
flake8
52+
Flake8-pyproject
53+
black
4654
skip_install = true

0 commit comments

Comments
 (0)