diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..19bb338 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,71 @@ +[build-system] +requires = [ + "setuptools>=64", + "setuptools-scm>=8", + "wheel", +] +build-backend = "setuptools.build_meta" + +[project] +name = "starterkit_ci" +dynamic = ["version"] + +description = "Helpers for Starterkit Continuous Integration" +readme = "README.md" +requires-python = ">=3.8" + +license = { file = "LICENSE.md" } + +authors = [ + { name = "LHCb Starterkit" }, +] + +keywords = ["Starterkit"] + +classifiers = [ + "Development Status :: 4 - Beta", + "License :: OSI Approved :: BSD License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", +] + +dependencies = [ + "sphinx>=7.0", + "sphinx-rtd-theme>=1.3", + "myst-parser[linkify]>=3.0", + "nbsphinx>=0.9", +] + +[project.urls] +"Homepage" = "https://github.com/lhcb/starterkit_ci" +"Bug Reports" = "https://github.com/lhcb/starterkit-ci/issues" +"Source" = "https://github.com/lhcb/starterkit-ci" + +[project.scripts] +starterkit_ci = "starterkit_ci:parse_args" + +[tool.setuptools] +package-dir = {"" = "src"} +zip-safe = false + +[tool.setuptools.packages.find] +where = ["src"] + +[tool.setuptools.package-data] +starterkit_ci = [ + "sphinx_config/_static/*", + "sphinx_config/_static/**/*", +] + +[tool.setuptools_scm] +version_scheme = "guess-next-dev" +local_scheme = "node-and-date" + +[tool.flake8] +max-line-length = 120 + +[tool.pytest.ini_options] +addopts = "--cov=cirun --cov-report=term-missing" diff --git a/setup.py b/setup.py deleted file mode 100644 index 2d55a24..0000000 --- a/setup.py +++ /dev/null @@ -1,59 +0,0 @@ -from setuptools import setup, find_packages -import os -from os.path import abspath, dirname, join -from io import open - -here = abspath(dirname(__file__)) - -# Get the long description from the README file -with open(join(here, 'README.md'), encoding='utf-8') as f: - long_description = f.read() - -package_data = [] -for root, dirs, files in os.walk(join(here, 'src/starterkit_ci/sphinx_config/_static')): - package_data += [join(root, fn) for fn in files] - -setup( - name='starterkit_ci', - use_scm_version=True, - description='Helpers for Starterkit Continuous Integration', - long_description=long_description, - long_description_content_type='text/markdown', - - url='https://github.com/lhcb/starterkit_ci', - - author='LHCb Starterkit', - classifiers=[ - 'Development Status :: 4 - Beta', - 'License :: OSI Approved :: BSD License', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - ], - keywords='Starterkit', - packages=find_packages('src'), - package_dir={'': 'src'}, - python_requires='>=3.6', - setup_requires=['setuptools_scm'], - install_requires=[ - 'sphinx', - 'sphinx-rtd-theme', - 'recommonmark', - 'sphinx-markdown-parser', - 'nbsphinx', - ], - package_data={ - 'starterkit_ci': package_data, - }, - zip_safe=False, - entry_points={ - 'console_scripts': { - 'starterkit_ci = starterkit_ci:parse_args', - } - }, - project_urls={ - 'Bug Reports': 'https://github.com/lhcb/starterkit-ci/issues', - 'Source': 'https://github.com/lhcb/starterkit-ci', - }, -) diff --git a/src/starterkit_ci/sphinx_config/__init__.py b/src/starterkit_ci/sphinx_config/__init__.py index 8522bda..5abdc5e 100644 --- a/src/starterkit_ci/sphinx_config/__init__.py +++ b/src/starterkit_ci/sphinx_config/__init__.py @@ -1,92 +1,82 @@ import os from os.path import dirname, join -from sphinx_markdown_parser.parser import MarkdownParser -from recommonmark.parser import CommonMarkParser -from sphinx_markdown_parser.transform import AutoStructify - -from . import panels -from . import fix_markdown_file_downloads - +from . import fix_markdown_file_downloads, panels extensions = [ - 'sphinx_rtd_theme', - 'sphinx_markdown_parser', - 'sphinx.ext.mathjax', - 'nbsphinx', + "sphinx_rtd_theme", + "myst_parser", + "sphinx.ext.mathjax", + "nbsphinx", ] + templates_path = [ - '_templates', + "_templates", ] -html_theme = 'sphinx_rtd_theme' + +html_theme = "sphinx_rtd_theme" html_show_sourcelink = True html_theme_options = { - 'collapse_navigation': False, + "collapse_navigation": False, } + exclude_patterns = [ - '**.ipynb_checkpoints', + "**.ipynb_checkpoints", ] + html_context = { - 'display_github': True, - 'github_user': 'lhcb', - 'github_repo': 'starterkit-lessons', - 'github_version': 'master', - 'conf_py_path': '/source/', + "display_github": True, + "github_user": "lhcb", + "github_repo": "starterkit-lessons", + "github_version": "master", + "conf_py_path": "/source/", } -highlight_language = 'none' + + +highlight_language = "none" + html_static_path = [ - f'{dirname(__file__)}/_static', + f"{dirname(__file__)}/_static", ] + linkcheck_ignore = [ - # Expect certificate errors - r'https://lhcb-portal-dirac\.cern\.ch/DIRAC/', - r'https://lhcb-nightlies\.cern\.ch.*', - # 404 if not logged in - r'https://gitlab\.cern\.ch/.*/merge_requests/new', - # Anchors to specific lines are generated with Javascript - r'https://gitlab\.cern\.ch/lhcb/Stripping/blob/.*', - # Seems to be unreliable? - r'http://pdg.*\.lbl\.gov/.*', - # 403 if not logged in - r'https://groups\.cern\.ch/group/lhcb-distributed-analysis/default\.aspx', - # FIXME: The URLs have changed - r'https://research\.cs\.wisc\.edu/htcondor/.*', + r"https://lhcb-portal-dirac\.cern\.ch/DIRAC/", + r"https://lhcb-nightlies\.cern\.ch.*", + r"https://gitlab\.cern\.ch/.*/merge_requests/new", + r"https://lhcb\.cern\.ch/lhcb/Stripping/blob/.*", + r"http://pdg.*\.lbl\.gov/.*", + r"https://groups\.cern\.ch/group/lhcb-distributed-analysis/default\.aspx", + r"https://research\.cs\.wisc\.edu/htcondor/.*", ] + + linkcheck_workers = 32 + starterkit_ci_redirects = {} +source_suffix = { + ".rst": "restructuredtext", + ".md": "markdown", +} + + +myst_enable_extensions = [ + "dollarmath", + "amsmath", + "linkify", + "substitution", +] + + def setup(app): - # Workaround for https://github.com/readthedocs/recommonmark/issues/177 - class CustomCommonMarkParser(CommonMarkParser): - def visit_document(self, node): - pass - - app.add_source_suffix('.md', 'markdown') - #app.add_source_parser(MarkdownParser) - app.add_source_parser(CustomCommonMarkParser) - app.add_config_value('markdown_parser_config', { - 'auto_toc_tree_section': 'Content', - 'enable_auto_toc_tree': True, - 'enable_eval_rst': True, - 'extensions': [ - 'extra', - 'nl2br', - 'sane_lists', - 'smarty', - 'toc', - 'wikilinks', - 'pymdownx.arithmatex', - ], - }, True) - app.add_transform(AutoStructify) fix_markdown_file_downloads.configure_app(app) panels.configure_app(app) for extra_setup_func in setup.extra_setup_funcs: @@ -94,12 +84,10 @@ def visit_document(self, node): # Create redirects for origin, target in starterkit_ci_redirects.items(): - # import pdb - # pdb.set_trace() origin = join(app.outdir, origin) - print('Creating redirect from', origin, 'to', target) + print("Creating redirect from", origin, "to", target) os.makedirs(dirname(origin), exist_ok=True) - with open(origin, 'wt') as fp: + with open(origin, "wt") as fp: fp.write(f'\n') fp.write(f'\n')