From e850eb4960e0bcdf600afd317f77f29f4a34e70f Mon Sep 17 00:00:00 2001 From: "kujiu (@uberwald)" Date: Sun, 17 Sep 2023 15:01:53 +0200 Subject: [PATCH] New package structure, Sphinx 8+ compatibility --- AUTHORS | 1 + pyproject.toml | 100 ++++++++++++++++++ requirements.txt | 2 - setup.cfg | 28 ----- setup.py | 76 ------------- sphinx_pyppeteer_builder/__init__.py | 8 +- sphinx_pyppeteer_builder/pyppeteer_builder.py | 2 +- 7 files changed, 106 insertions(+), 111 deletions(-) create mode 100644 pyproject.toml delete mode 100644 requirements.txt delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/AUTHORS b/AUTHORS index 09461b9..a224df5 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,3 +1,4 @@ (in chronological order) * Kujiu + * PtitGNU diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..cbee92e --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,100 @@ +[build-system] +requires = ["flit_core>=3.2"] +build-backend = "flit_core.buildapi" + +[project] +name = "sphinx_pyppeteer_builder" +version = "1.0.0" +requires-python = ">=3.8" +dependencies = [ + "Sphinx>=7.0.0", + "pyppeteer" +] +license = {text = "EUPL-1.2"} +authors = [ + {name = "Nerv Project ASBL", email = "contact@nerv-project.eu"}, + {name = "kujiu"}, + {name = "ptitgnu"} +] +maintainers = [ + {name = "Nerv Project ASBL", email = "contact@nerv-project.eu"}, + {name = "kujiu"}, + {name = "ptitgnu"} +] +description = "A Sphinx PDF builder using pyppeteer" +readme = {file = "README.rst", content-type = "text/x-rst"} +keywords=["sphinx", "doc", "pdf", "pyppeteer"] +classifiers=[ + "Framework :: Sphinx", + "Framework :: Sphinx :: Extension", + "Development Status :: 5 - Production/Stable", + "License :: OSI Approved :: European Union Public Licence 1.2 (EUPL 1.2)", + "Environment :: Console", + "Environment :: Web Environment", + "Intended Audience :: Developers", + "Programming Language :: Python :: 3", + "Operating System :: OS Independent", + "Topic :: Documentation", + "Topic :: Software Development :: Documentation", +] + +[project.urls] +homepage = "https://www.nerv-project.eu" +repository = "https://procrastinator.nerv-project.eu/nerv-project/sphinx_pyppeteer_builder" +issues = "https://procrastinator.nerv-project.eu/nerv-project/sphinx_pyppeteer_builder/issues" +editor = "https://www.nerv-project.eu" +changelog = "https://procrastinator.nerv-project.eu/nerv-project/sphinx_pyppeteer_builder/raw/branch/main/CHANGES.rst" + +[project.entry-points."sphinx.builders"] +pyppeteer = "sphinx_pyppeteer_builder" + +[project.optional-dependencies] +tests = [ + "pytest", + "flake8", + "pylint", + "pytest-cov" +] +setup = [ + "Sphinx", + "pytest-runner", + "flake8", + "pylint", + "babel", + "flit", +] + +[project.scripts] + +[tool.pytest.ini_options] +minversion = "6.0" +addopts = "-ra -q" +testpaths = [ + "tests", +] + +[tool.babel.extract_messages] +mapping_file = "babel.cfg" +output_file = "locale/sphinx.pot" +keywords = ["_", "__", "l_", "lazy_gettext", "gettext", "ngettext"] +add_comments = "Translators:" + +[tool.babel.init_catalog] +domain = "sphinx" +input_file = "locale/sphinx.pot" +output_dir = "locale/" + +[tool.babel.update_catalog] +domain = "sphinx" +input_file = "locale/sphinx.pot" +output_dir = "locale/" + +[tool.babel.compile_catalog] +domain = "sphinx" +directory = "locale/" + +[tool.flit.sdist] +include = [ + "*.py", +] + diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index f8397a2..0000000 --- a/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -Sphinx>=3.0.0 -pyppeteer diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index d1b0e8f..0000000 --- a/setup.cfg +++ /dev/null @@ -1,28 +0,0 @@ -[metadata] -description-file = README.rst -license-files = - LICENSE - LICENSE-de - LICENSE-fr - LICENSE-nl - - -[extract_messages] -mapping_file = babel.cfg -output_file = sphinx_pyppeteer_builder/locale/sphinx.pot -keywords = _ l_ lazy_gettext gettext ngettext -add_comments = Translators: - -[init_catalog] -domain = sphinx -input_file = sphinx_pyppeteer_builder/locale/sphinx.pot -output_dir = sphinx_pyppeteer_builder/locale/ - -[update_catalog] -domain = sphinx -input_file = sphinx_pyppeteer_builder/locale/sphinx.pot -output_dir = sphinx_pyppeteer_builder/locale/ - -[compile_catalog] -domain = sphinx -directory = sphinx_pyppeteer_builder/locale/ diff --git a/setup.py b/setup.py deleted file mode 100644 index 2bbf3c0..0000000 --- a/setup.py +++ /dev/null @@ -1,76 +0,0 @@ -from setuptools import setup -import distutils - - -class TranslateCommand(distutils.cmd.Command): - description = "Translation" - - user_options = [] - sub_commands = [ - ('extract_messages', None), - ('update_catalog', None), - ('compile_catalog', None), - ] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - for cmd_name in self.get_sub_commands(): - self.run_command(cmd_name) - - -with open("README.rst", "r") as fh: - long_description = fh.read() - -setup( - name="sphinx_pyppeteer_builder", - version="0.1.1", - url="https://procrastinator.nerv-project.eu/nerv-project/sphinx_pyppeteer_builder", - license="EUPL 1.2", - author="Kujiu", - author_email="kujiu-pypi@kujiu.org", - description="A Sphinx PDF builder using pyppeteer", - long_description=long_description, - long_description_content_type="text/x-rst", - packages=["sphinx_pyppeteer_builder"], - cmdclass={ - 'translate': TranslateCommand, - }, - package_data={ - "sphinx_pyppeteer_builder": [ - "locale/*/LC_MESSAGES/*.mo", - "locale/*/LC_MESSAGES/*.po", - ] - }, - entry_points={"sphinx.builders": ["pyppeteer = sphinx_pyppeteer_builder"]}, - install_requires=[ - "sphinx>=3.0.0", - "pyppeteer", - ], - classifiers=[ - "Framework :: Sphinx", - "Framework :: Sphinx :: Extension", - "Development Status :: 4 - Beta", - "License :: OSI Approved :: European Union Public Licence 1.2 (EUPL 1.2)", - "Environment :: Console", - "Environment :: Web Environment", - "Intended Audience :: Developers", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Operating System :: OS Independent", - "Topic :: Documentation", - "Topic :: Software Development :: Documentation", - ], - keywords="sphinx doc pdf pyppeteer", - project_urls={ - "Source": "https://procrastinator.nerv-project.eu/nerv-project/sphinx_pyppeteer_builder", - "Issues": "https://procrastinator.nerv-project.eu/nerv-project/sphinx_pyppeteer_builder/issues", - }, -) diff --git a/sphinx_pyppeteer_builder/__init__.py b/sphinx_pyppeteer_builder/__init__.py index b21e8bc..c2e1627 100644 --- a/sphinx_pyppeteer_builder/__init__.py +++ b/sphinx_pyppeteer_builder/__init__.py @@ -7,9 +7,9 @@ from typing import Dict, Any from sphinx.application import Sphinx from sphinx.util.osutil import make_filename - -version = (0, 1, 1) - +import pkg_resources +__version__ = pkg_resources.get_distribution(__package__).version +__version_info__ = tuple(int(v) for v in __version__.split('.')) DEFAULT_PDF_OPTIONS = { 'printBackground': True, @@ -109,7 +109,7 @@ def setup(app: Sphinx) -> Dict[str, Any]: ) return { - 'version': version, + 'version': __version__, 'parallel_read_safe': True, 'parallel_write_safe': True, } diff --git a/sphinx_pyppeteer_builder/pyppeteer_builder.py b/sphinx_pyppeteer_builder/pyppeteer_builder.py index ac67f61..cb7ce10 100644 --- a/sphinx_pyppeteer_builder/pyppeteer_builder.py +++ b/sphinx_pyppeteer_builder/pyppeteer_builder.py @@ -5,7 +5,7 @@ import asyncio from typing import Dict, Set, Tuple from sphinx.builders.singlehtml import SingleFileHTMLBuilder -from sphinx.util import progress_message, logging +from sphinx.util.display import progress_message, logging from sphinx.util.osutil import os_path from sphinx.locale import __