Skip to content

Commit

Permalink
Modernize setuptools support to use pyproject.toml (#184)
Browse files Browse the repository at this point in the history
* Modernize setuptools support to use pyproject.toml

Replace the obsolete `setup.py` script and `setup.cfg` configuration
file with the modern PEP 621 `pyproject.toml` metadata.  This also
implies replacing the custom version/long-description grabbing logic
(that is broken with Python 3.12) with the features nowadays built-in
in setuptools.

Fixes #172

Co-authored-by: Tom Flanagan <[email protected]>
  • Loading branch information
mgorny and Knio committed Nov 5, 2023
1 parent fe1f71e commit 4a66756
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 75 deletions.
31 changes: 15 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,44 @@ jobs:
python: ["3"]
os: ["ubuntu-latest"]
include:
- {python: "2.7", os: "ubuntu-22.04"}
# https://github.blog/changelog/2022-08-09-github-actions-the-ubuntu-18-04-actions-runner-image-is-being-deprecated-and-will-be-removed-by-12-1-22/
# - {python: "3.4", os: "ubuntu-18.04"}
- {python: "3.5", os: "ubuntu-20.04"}
- {python: "3.6", os: "ubuntu-20.04"}
- {python: "3.7", os: "ubuntu-22.04"}
- {python: "3.8", os: "ubuntu-22.04"}
- {python: "3.9", os: "ubuntu-22.04"}
- {python: "3.10", os: "ubuntu-22.04"}
- {python: "3.11", os: "ubuntu-22.04"}
- {python: "3.12", os: "ubuntu-22.04"}
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python }}
- name: "Set up Python ${{ matrix.python }}"
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
- name: "Install dependencies"
run: |
python -m pip install --upgrade pip
# python -m pip install --upgrade pip
python -m pip install pytest
python -m pip install mock
python -m pip install flake8
python -m pip install importlib_metadata
- name: Lint with flake8
python -m pip install importlib_metadata
python -m pip install "setuptools>=62"
python -m pip install wheel
python -m pip install build
- name: "Lint with flake8"
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=80 --statistics
- name: Build and test
- name: "Build and test"
run: |
python setup.py sdist --formats=zip
pip install dist/dominate*.zip
python -m build --no-isolation
pip install dist/dominate*.tar.gz
pytest
- name: Coveralls
env:
env:
COVERAGE_RCFILE: ".github/workflows/.coveragerc"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python -m pip install "coverage"
python -m pip install "coveralls"
python -m pip install coverage
python -m pip install coveralls
coverage run --source=dominate -m pytest
python -m coveralls --service=github || true
34 changes: 0 additions & 34 deletions .travis.yml

This file was deleted.

2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
include README.md
include LICENSE.txt
include pyproject.toml
include setup/setup.py
recursive-include tests *
global-exclude __pycache__
global-exclude *.pyc
17 changes: 12 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
test:
python2 -m pytest .
-python2 -m pytest .
python3 -m pytest .

publish: test
rm dist/ -r
python3 setup.py sdist
python3 setup.py bdist_wheel
publish_old: clean test
python3 setup/setup.py sdist
python3 setup/setup.py bdist_wheel
python3 -m twine upload dist/*

publish: clean test
python3 -m build --no-isolation
python3 -m twine upload dist/*

clean:
-rm dist/ -r
-rm build/ -r
-rm *.egg-info/ -r
2 changes: 1 addition & 1 deletion dominate/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.8.0'
__version__ = '2.9.0'
43 changes: 43 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[build-system]
requires = ["setuptools>=62"]
build-backend = "setuptools.build_meta"

[project]
name = "dominate"
description = "Dominate is a Python library for creating and manipulating HTML documents using an elegant DOM API."
readme = {file = "README.md", content-type = "text/markdown"}
authors = [
{name = "Tom Flanagan", email = "[email protected]"},
{name = "Jake Wharton"},
]
requires-python = ">=3.4"
keywords = ["framework", "templating", "template", "html", "xhtml", "python", "html5"]
license = {text = "LGPL-3.0-or-newer"}
classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
"Operating System :: OS Independent",
"Programming Language :: Python",
"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.12",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Text Processing :: Markup :: HTML",
]
dynamic = ["version"]

[project.urls]
Homepage = "https://github.com/Knio/dominate"
Source = "https://github.com/Knio/dominate"

[tool.setuptools]
packages = ["dominate"]

[tool.setuptools.dynamic]
version = {attr = "dominate._version.__version__"}
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[metadata]
license_file = LICENSE.txt
license_files = ["LICENSE.txt"]

[bdist_wheel]
universal=1

2 changes: 1 addition & 1 deletion setup.py → setup/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
long_description_content_type='text/markdown',
keywords = 'framework templating template html xhtml python html5',

python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
python_requires='>=2.7, <3',
classifiers = [
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)',
Expand Down
14 changes: 1 addition & 13 deletions tests/test_dominate.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
import pytest

import dominate
from dominate import tags
from dominate import util

def test_version():
import dominate
version = '2.8.0'
version = '2.9.0'
assert dominate.version == version
assert dominate.__version__ == version


def test_context():
id1 = dominate.dom_tag._get_thread_context()
id2 = dominate.dom_tag._get_thread_context()
assert id1 == id2

9 changes: 6 additions & 3 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import pytest

import dominate
from dominate.tags import *
from dominate import util


def test_context():
id1 = dominate.dom_tag._get_thread_context()
id2 = dominate.dom_tag._get_thread_context()
assert id1 == id2

def test_include():
import os
try:
Expand Down Expand Up @@ -53,4 +57,3 @@ def test_container():
'''<div>
<h1>a</h1>
</div>'''

0 comments on commit 4a66756

Please sign in to comment.