From 43bb2cc28f936c8d3483bd7b1077d56293ebe5db Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Wed, 20 Apr 2022 22:30:35 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20MAINTAIN:=20Move=20from=20setupt?= =?UTF-8?q?ools=20to=20flit=20for=20package=20build=20(#58)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 16 ++-- .pre-commit-config.yaml | 18 +---- .readthedocs.yml | 2 +- MANIFEST.in | 30 -------- pyproject.toml | 67 ++++++++++++++++- setup.cfg | 74 ------------------- setup.py | 6 -- sphinx_design/extension.py | 7 +- sphinx_design/icons.py | 9 +-- tests/conftest.py | 2 +- tests/test_snippets.py | 4 - .../snippet_post_icon-material-design.xml | 2 +- .../snippet_pre_icon-material-design.xml | 2 +- tox.ini | 4 + 14 files changed, 87 insertions(+), 156 deletions(-) delete mode 100644 MANIFEST.in delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0a27e5e..cb61350 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,12 +68,12 @@ jobs: uses: actions/setup-python@v2 with: python-version: 3.8 - - name: Build package + - name: install flit run: | - pip install wheel - python setup.py sdist bdist_wheel - - name: Publish - uses: pypa/gh-action-pypi-publish@v1.1.0 - with: - user: __token__ - password: ${{ secrets.PYPI_KEY }} + pip install flit~=3.4 + - name: Build and publish + run: | + flit publish + env: + FLIT_USERNAME: __token__ + FLIT_PASSWORD: ${{ secrets.PYPI_KEY }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index da66d71..c0f4e0d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,27 +11,20 @@ exclude: > repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v4.2.0 hooks: - id: check-json - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace - - repo: https://github.com/mgedmin/check-manifest - rev: "0.47" - hooks: - - id: check-manifest - args: [--no-build-isolation] - additional_dependencies: [setuptools>=46.4.0] - - repo: https://github.com/pycqa/isort rev: 5.10.1 hooks: - id: isort - repo: https://github.com/psf/black - rev: 21.12b0 + rev: 22.3.0 hooks: - id: black @@ -42,16 +35,11 @@ repos: additional_dependencies: [flake8-bugbear==21.3.1] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.910-1 + rev: v0.942 hooks: - id: mypy additional_dependencies: [] - - repo: https://github.com/asottile/setup-cfg-fmt - rev: v1.20.0 - hooks: - - id: setup-cfg-fmt - - repo: local hooks: - id: css diff --git a/.readthedocs.yml b/.readthedocs.yml index 16504ca..ccb61ea 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,7 +1,7 @@ version: 2 python: - version: "3" + version: "3.8" install: - method: pip path: . diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index f0a777a..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,30 +0,0 @@ -exclude docs -recursive-exclude docs * -exclude style -recursive-exclude style * -exclude tests -recursive-exclude tests * - -exclude .pre-commit-config.yaml -exclude .readthedocs.yml -exclude tox.ini -exclude codecov.yml -exclude package.json -exclude package-lock.json -exclude git_rebase_theme_branches.sh - -include LICENSE -include CHANGELOG.md -include README.md - -include sphinx_design/py.typed -include sphinx_design/compiled/style.min.css -include sphinx_design/compiled/sd_tabs.js -include sphinx_design/compiled/octicon_LICENSE -include sphinx_design/compiled/octicons.json -include sphinx_design/compiled/material_outlined.json -include sphinx_design/compiled/material_regular.json -include sphinx_design/compiled/material_round.json -include sphinx_design/compiled/material_sharp.json -include sphinx_design/compiled/material_twotone.json -include sphinx_design/compiled/material-icons_LICENSE diff --git a/pyproject.toml b/pyproject.toml index f86c18d..47e66d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,70 @@ [build-system] -requires = ["setuptools>=46.4.0", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["flit_core >=3.4,<4"] +build-backend = "flit_core.buildapi" + +[project] +name = "sphinx_design" +dynamic = ["version"] +description = "A sphinx extension for designing beautiful, view size responsive web components." +authors = [{name = "Chris Sewell", email = "chrisj_sewell@hotmail.com"}] +readme = "README.md" +license = {file = "LICENSE"} +classifiers = [ + "Development Status :: 4 - Beta", + "Framework :: Sphinx :: Extension", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: Implementation :: CPython", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Text Processing :: Markup", + "Topic :: Text Processing :: Markup :: Markdown", + "Topic :: Text Processing :: Markup :: reStructuredText", +] +keywords = ["sphinx", "extension", "material design", "web components"] +requires-python = ">=3.7" +dependencies = ["sphinx>=3,<5"] + +[project.urls] +Homepage = "https://github.com/executablebooks/sphinx-design" +Documentation = "https://sphinx-design.readthedocs.io" + +[project.optional-dependencies] +code_style = ["pre-commit~=2.12"] +rtd = ["myst-parser~=0.17.0"] +testing = [ + "myst-parser~=0.17.0", + "pytest~=6.2", + "pytest-cov", + "pytest-regressions", +] +theme_furo = ["furo==2022.04.07"] +theme_pydata = ["pydata-sphinx-theme~=0.8.1"] +theme_rtd = ["sphinx-rtd-theme~=1.0"] +theme_sbt = ["sphinx-book-theme~=0.3.0"] + +[tool.flit.sdist] +exclude = [ + "docs/", + "style/", + "tests/", +] + +[tool.mypy] +show_error_codes = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true +strict_equality = true + +[[tool.mypy.overrides]] +module = ["docutils.*"] +ignore_missing_imports = true [tool.isort] profile = "black" src_paths = ["sphinx_design", "tests"] +force_sort_within_sections = true diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index cf373b0..0000000 --- a/setup.cfg +++ /dev/null @@ -1,74 +0,0 @@ -[metadata] -name = sphinx_design -version = attr: sphinx_design.__version__ -description = A sphinx extension for designing beautiful, view size responsive web components. -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/executablebooks/sphinx-design -author = Chris Sewell -author_email = chrisj_sewell@hotmail.com -license = MIT -license_file = LICENSE -classifiers = - Development Status :: 4 - Beta - Framework :: Sphinx :: Extension - Intended Audience :: Developers - License :: OSI Approved :: MIT License - 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 :: Implementation :: CPython - Topic :: Software Development :: Libraries :: Python Modules - Topic :: Text Processing :: Markup - Topic :: Text Processing :: Markup :: Markdown - Topic :: Text Processing :: Markup :: reStructuredText -keywords = sphinx extension material design web components -project_urls = - Documentation = https://sphinx-design.readthedocs.io - -[options] -packages = find: -install_requires = - sphinx>=3,<5 - importlib-resources~=3.0.0;python_version < "3.7" -python_requires = ~=3.6 -include_package_data = True - -[options.packages.find] -exclude = - test* - -[options.extras_require] -code_style = - pre-commit~=2.12 -rtd = - myst-parser~=0.16.0 -testing = - myst-parser~=0.16.0 - pytest~=6.2 - pytest-cov - pytest-regressions -theme_furo = - furo==2021.7.5b38 -theme_pydata = - pydata-sphinx-theme~=0.6.0 -theme_rtd = - sphinx-rtd-theme~=0.5.0 -theme_sbt = - sphinx-book-theme~=0.1.2 - -[mypy] -show_error_codes = True -warn_unused_ignores = True -warn_redundant_casts = True -no_implicit_optional = True -strict_equality = True - -[mypy-docutils.*] -ignore_missing_imports = True - -[flake8] -max-line-length = 100 -extend-ignore = E203 diff --git a/setup.py b/setup.py deleted file mode 100644 index 3614126..0000000 --- a/setup.py +++ /dev/null @@ -1,6 +0,0 @@ -# This file is needed for editable installs (`pip install -e .`). -# Can be removed once the following is resolved -# https://github.com/pypa/packaging-problems/issues/256 -from setuptools import setup - -setup() diff --git a/sphinx_design/extension.py b/sphinx_design/extension.py index d9cbad9..648a65e 100644 --- a/sphinx_design/extension.py +++ b/sphinx_design/extension.py @@ -1,12 +1,7 @@ import hashlib +import importlib.resources as resources from pathlib import Path -try: - import importlib.resources as resources -except ImportError: - # python < 3.7 - import importlib_resources as resources # type: ignore[no-redef] - from docutils import nodes from docutils.parsers.rst import directives from sphinx.application import Sphinx diff --git a/sphinx_design/icons.py b/sphinx_design/icons.py index dba42e4..1913910 100644 --- a/sphinx_design/icons.py +++ b/sphinx_design/icons.py @@ -1,14 +1,9 @@ +from functools import lru_cache +import importlib.resources as resources import json import re -from functools import lru_cache from typing import Any, Dict, List, Optional, Sequence, Tuple -try: - import importlib.resources as resources -except ImportError: - # python < 3.7 - import importlib_resources as resources # type: ignore[no-redef] - from docutils import nodes from docutils.parsers.rst import directives from sphinx.application import Sphinx diff --git a/tests/conftest.py b/tests/conftest.py index 9246553..7d3fa8e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,8 +2,8 @@ from pathlib import Path from typing import Any, Dict, Optional -import pytest from docutils import nodes +import pytest from sphinx.testing.path import path as sphinx_path from sphinx.testing.util import SphinxTestApp diff --git a/tests/test_snippets.py b/tests/test_snippets.py index da167a8..047cfb9 100644 --- a/tests/test_snippets.py +++ b/tests/test_snippets.py @@ -34,8 +34,6 @@ def test_snippets_rst( write_assets(builder.src_path) builder.build() pformat = builder.get_doctree("index").pformat() - # fixed in https://github.com/executablebooks/MyST-Parser/pull/465 - pformat = pformat.replace('', "") file_regression.check( pformat, basename=f"snippet_pre_{path.name[:-len(path.suffix)]}", @@ -81,8 +79,6 @@ def test_snippets_rst_post( write_assets(builder.src_path) builder.build() pformat = builder.get_doctree("index", post_transforms=True).pformat() - # fixed in https://github.com/executablebooks/MyST-Parser/pull/465 - pformat = pformat.replace('', "") file_regression.check( pformat, basename=f"snippet_post_{path.name[:-len(path.suffix)]}", diff --git a/tests/test_snippets/snippet_post_icon-material-design.xml b/tests/test_snippets/snippet_post_icon-material-design.xml index f76936f..eaeb579 100644 --- a/tests/test_snippets/snippet_post_icon-material-design.xml +++ b/tests/test_snippets/snippet_post_icon-material-design.xml @@ -2,7 +2,7 @@
Heading - <bullet_list> + <bullet_list bullet="-"> <list_item> <paragraph> A regular icon: diff --git a/tests/test_snippets/snippet_pre_icon-material-design.xml b/tests/test_snippets/snippet_pre_icon-material-design.xml index f76936f..eaeb579 100644 --- a/tests/test_snippets/snippet_pre_icon-material-design.xml +++ b/tests/test_snippets/snippet_pre_icon-material-design.xml @@ -2,7 +2,7 @@ <section ids="heading" names="heading"> <title> Heading - <bullet_list> + <bullet_list bullet="-"> <list_item> <paragraph> A regular icon: diff --git a/tox.ini b/tox.ini index f4e242d..7503ab4 100644 --- a/tox.ini +++ b/tox.ini @@ -70,3 +70,7 @@ commands = --re-ignore docs/_build/.* \ --port 0 --open-browser \ -n -b {posargs:html} docs/ docs/_build/{posargs:html} + +[flake8] +max-line-length = 100 +extend-ignore = E203