diff --git a/.gitignore b/.gitignore index 50f21ea80..4e246356e 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,6 @@ docs/source/config_options.rst .vscode # Downloaded theme files -jupyter-data/share/jupyter/nbconvert/templates/lab/static/index.css -jupyter-data/share/jupyter/nbconvert/templates/lab/static/theme-dark.css -jupyter-data/share/jupyter/nbconvert/templates/lab/static/theme-light.css +share/templates/lab/static/index.css +share/templates/lab/static/theme-dark.css +share/templates/lab/static/theme-light.css diff --git a/buildapi.py b/hatch_build.py similarity index 65% rename from buildapi.py rename to hatch_build.py index 0f7cae0fd..0d5d5f427 100644 --- a/buildapi.py +++ b/hatch_build.py @@ -1,23 +1,9 @@ -"""A build backend that handles installing the template files. - -See https://peps.python.org/pep-0517/#in-tree-build-backends -""" +"""Custom build script for hatch backend""" import os import sys from urllib.request import urlopen -from flit_core.buildapi import build_editable # noqa -from flit_core.buildapi import build_sdist # noqa -from flit_core.buildapi import build_wheel # noqa -from flit_core.buildapi import ( - get_requires_for_build_editable as get_requires_for_build_editable_orig, -) -from flit_core.buildapi import ( - get_requires_for_build_sdist as get_requires_for_build_sdist_orig, -) -from flit_core.buildapi import ( - get_requires_for_build_wheel as get_requires_for_build_wheel_orig, -) +from hatchling.builders.hooks.plugin.interface import BuildHookInterface notebook_css_version = "5.4.0" notebook_css_url = "https://cdn.jupyter.org/notebook/%s/style/style.min.css" % notebook_css_version @@ -50,7 +36,7 @@ osp = os.path here = osp.abspath(osp.dirname(__file__)) -templates_dir = osp.join(here, "jupyter-data", "share", "jupyter", "nbconvert", "templates") +templates_dir = osp.join(here, "share", "templates") def _get_css_file(template_name, url, filename): @@ -88,16 +74,8 @@ def _get_css_files(): _get_css_file(template_name, url, filename) -def get_requires_for_build_wheel(config_settings=None): - _get_css_files() - return get_requires_for_build_wheel_orig(config_settings=config_settings) - - -def get_requires_for_build_sdist(config_settings=None): - _get_css_files() - return get_requires_for_build_sdist_orig(config_settings=config_settings) - - -def get_requires_for_build_editable(config_settings=None): - _get_css_files() - return get_requires_for_build_editable_orig(config_settings=config_settings) +class CustomHook(BuildHookInterface): + def initialize(self, version, build_data): + if self.target_name not in ["wheel", "sdist"]: + return + _get_css_files() diff --git a/nbconvert/_version.py b/nbconvert/_version.py index 332ba3424..d521d3b83 100644 --- a/nbconvert/_version.py +++ b/nbconvert/_version.py @@ -1,3 +1,4 @@ +__version__ = "7.0.0rc0" version_info = (7, 0, 0) pre_info = "rc0" dev_info = "" @@ -64,4 +65,4 @@ def is_canonical(version): raise ValueError(pep440_err) -__version__ = create_valid_version(version_info, pre_input=pre_info, dev_input=dev_info) +assert __version__ == create_valid_version(version_info, pre_input=pre_info, dev_input=dev_info) diff --git a/pyproject.toml b/pyproject.toml index ae51a7970..7a1b26fbf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,6 @@ [build-system] -requires = ["flit_core >=3.2,<4"] -build-backend = "buildapi" -backend-path = ["."] +requires = ["hatchling >=0.25"] +build-backend = "hatchling.build" [project] name = "nbconvert" @@ -91,11 +90,17 @@ all = [ jupyter-nbconvert = "nbconvert.nbconvertapp:main" jupyter-dejavu = "nbconvert.nbconvertapp:dejavu_main" -[tool.flit.sdist] -include = ["buildapi.py", "jupyter-data"] +[tool.hatch.version] +path = "nbconvert/_version.py" -[tool.flit.external-data] -directory = "jupyter-data" +# Used to call hatch_build.py +[tool.hatch.build.hooks.custom] + +[tool.hatch.build.targets.sdist] +artifacts = ["share/templates/lab/static/*.*"] + +[tool.hatch.build.targets.wheel.shared-data] +"share/templates" = "share/jupyter/nbconvert/templates" [tool.pytest.ini_options] markers = "network: marks tests which require network connection" diff --git a/jupyter-data/share/jupyter/nbconvert/templates/asciidoc/conf.json b/share/templates/asciidoc/conf.json similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/asciidoc/conf.json rename to share/templates/asciidoc/conf.json diff --git a/jupyter-data/share/jupyter/nbconvert/templates/asciidoc/index.asciidoc.j2 b/share/templates/asciidoc/index.asciidoc.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/asciidoc/index.asciidoc.j2 rename to share/templates/asciidoc/index.asciidoc.j2 diff --git a/jupyter-data/share/jupyter/nbconvert/templates/base/celltags.j2 b/share/templates/base/celltags.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/base/celltags.j2 rename to share/templates/base/celltags.j2 diff --git a/jupyter-data/share/jupyter/nbconvert/templates/base/display_priority.j2 b/share/templates/base/display_priority.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/base/display_priority.j2 rename to share/templates/base/display_priority.j2 diff --git a/jupyter-data/share/jupyter/nbconvert/templates/base/jupyter_widgets.html.j2 b/share/templates/base/jupyter_widgets.html.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/base/jupyter_widgets.html.j2 rename to share/templates/base/jupyter_widgets.html.j2 diff --git a/jupyter-data/share/jupyter/nbconvert/templates/base/mathjax.html.j2 b/share/templates/base/mathjax.html.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/base/mathjax.html.j2 rename to share/templates/base/mathjax.html.j2 diff --git a/jupyter-data/share/jupyter/nbconvert/templates/base/null.j2 b/share/templates/base/null.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/base/null.j2 rename to share/templates/base/null.j2 diff --git a/jupyter-data/share/jupyter/nbconvert/templates/basic/conf.json b/share/templates/basic/conf.json similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/basic/conf.json rename to share/templates/basic/conf.json diff --git a/jupyter-data/share/jupyter/nbconvert/templates/basic/index.html.j2 b/share/templates/basic/index.html.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/basic/index.html.j2 rename to share/templates/basic/index.html.j2 diff --git a/jupyter-data/share/jupyter/nbconvert/templates/classic/base.html.j2 b/share/templates/classic/base.html.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/classic/base.html.j2 rename to share/templates/classic/base.html.j2 diff --git a/jupyter-data/share/jupyter/nbconvert/templates/classic/conf.json b/share/templates/classic/conf.json similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/classic/conf.json rename to share/templates/classic/conf.json diff --git a/jupyter-data/share/jupyter/nbconvert/templates/classic/index.html.j2 b/share/templates/classic/index.html.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/classic/index.html.j2 rename to share/templates/classic/index.html.j2 diff --git a/jupyter-data/share/jupyter/nbconvert/templates/classic/static/style.css b/share/templates/classic/static/style.css similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/classic/static/style.css rename to share/templates/classic/static/style.css diff --git a/jupyter-data/share/jupyter/nbconvert/templates/compatibility/display_priority.tpl b/share/templates/compatibility/display_priority.tpl similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/compatibility/display_priority.tpl rename to share/templates/compatibility/display_priority.tpl diff --git a/jupyter-data/share/jupyter/nbconvert/templates/compatibility/full.tpl b/share/templates/compatibility/full.tpl similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/compatibility/full.tpl rename to share/templates/compatibility/full.tpl diff --git a/jupyter-data/share/jupyter/nbconvert/templates/lab/base.html.j2 b/share/templates/lab/base.html.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/lab/base.html.j2 rename to share/templates/lab/base.html.j2 diff --git a/jupyter-data/share/jupyter/nbconvert/templates/lab/conf.json b/share/templates/lab/conf.json similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/lab/conf.json rename to share/templates/lab/conf.json diff --git a/jupyter-data/share/jupyter/nbconvert/templates/lab/index.html.j2 b/share/templates/lab/index.html.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/lab/index.html.j2 rename to share/templates/lab/index.html.j2 diff --git a/jupyter-data/share/jupyter/nbconvert/templates/latex/base.tex.j2 b/share/templates/latex/base.tex.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/latex/base.tex.j2 rename to share/templates/latex/base.tex.j2 diff --git a/jupyter-data/share/jupyter/nbconvert/templates/latex/conf.json b/share/templates/latex/conf.json similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/latex/conf.json rename to share/templates/latex/conf.json diff --git a/jupyter-data/share/jupyter/nbconvert/templates/latex/display_priority.j2 b/share/templates/latex/display_priority.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/latex/display_priority.j2 rename to share/templates/latex/display_priority.j2 diff --git a/jupyter-data/share/jupyter/nbconvert/templates/latex/document_contents.tex.j2 b/share/templates/latex/document_contents.tex.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/latex/document_contents.tex.j2 rename to share/templates/latex/document_contents.tex.j2 diff --git a/jupyter-data/share/jupyter/nbconvert/templates/latex/index.tex.j2 b/share/templates/latex/index.tex.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/latex/index.tex.j2 rename to share/templates/latex/index.tex.j2 diff --git a/jupyter-data/share/jupyter/nbconvert/templates/latex/null.j2 b/share/templates/latex/null.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/latex/null.j2 rename to share/templates/latex/null.j2 diff --git a/jupyter-data/share/jupyter/nbconvert/templates/latex/report.tex.j2 b/share/templates/latex/report.tex.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/latex/report.tex.j2 rename to share/templates/latex/report.tex.j2 diff --git a/jupyter-data/share/jupyter/nbconvert/templates/latex/style_bw_ipython.tex.j2 b/share/templates/latex/style_bw_ipython.tex.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/latex/style_bw_ipython.tex.j2 rename to share/templates/latex/style_bw_ipython.tex.j2 diff --git a/jupyter-data/share/jupyter/nbconvert/templates/latex/style_bw_python.tex.j2 b/share/templates/latex/style_bw_python.tex.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/latex/style_bw_python.tex.j2 rename to share/templates/latex/style_bw_python.tex.j2 diff --git a/jupyter-data/share/jupyter/nbconvert/templates/latex/style_ipython.tex.j2 b/share/templates/latex/style_ipython.tex.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/latex/style_ipython.tex.j2 rename to share/templates/latex/style_ipython.tex.j2 diff --git a/jupyter-data/share/jupyter/nbconvert/templates/latex/style_jupyter.tex.j2 b/share/templates/latex/style_jupyter.tex.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/latex/style_jupyter.tex.j2 rename to share/templates/latex/style_jupyter.tex.j2 diff --git a/jupyter-data/share/jupyter/nbconvert/templates/latex/style_python.tex.j2 b/share/templates/latex/style_python.tex.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/latex/style_python.tex.j2 rename to share/templates/latex/style_python.tex.j2 diff --git a/jupyter-data/share/jupyter/nbconvert/templates/markdown/conf.json b/share/templates/markdown/conf.json similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/markdown/conf.json rename to share/templates/markdown/conf.json diff --git a/jupyter-data/share/jupyter/nbconvert/templates/markdown/index.md.j2 b/share/templates/markdown/index.md.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/markdown/index.md.j2 rename to share/templates/markdown/index.md.j2 diff --git a/jupyter-data/share/jupyter/nbconvert/templates/python/conf.json b/share/templates/python/conf.json similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/python/conf.json rename to share/templates/python/conf.json diff --git a/jupyter-data/share/jupyter/nbconvert/templates/python/index.py.j2 b/share/templates/python/index.py.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/python/index.py.j2 rename to share/templates/python/index.py.j2 diff --git a/jupyter-data/share/jupyter/nbconvert/templates/reveal/base.html.j2 b/share/templates/reveal/base.html.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/reveal/base.html.j2 rename to share/templates/reveal/base.html.j2 diff --git a/jupyter-data/share/jupyter/nbconvert/templates/reveal/conf.json b/share/templates/reveal/conf.json similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/reveal/conf.json rename to share/templates/reveal/conf.json diff --git a/jupyter-data/share/jupyter/nbconvert/templates/reveal/index.html.j2 b/share/templates/reveal/index.html.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/reveal/index.html.j2 rename to share/templates/reveal/index.html.j2 diff --git a/jupyter-data/share/jupyter/nbconvert/templates/reveal/static/custom_reveal.css b/share/templates/reveal/static/custom_reveal.css similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/reveal/static/custom_reveal.css rename to share/templates/reveal/static/custom_reveal.css diff --git a/jupyter-data/share/jupyter/nbconvert/templates/rst/conf.json b/share/templates/rst/conf.json similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/rst/conf.json rename to share/templates/rst/conf.json diff --git a/jupyter-data/share/jupyter/nbconvert/templates/rst/index.rst.j2 b/share/templates/rst/index.rst.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/rst/index.rst.j2 rename to share/templates/rst/index.rst.j2 diff --git a/jupyter-data/share/jupyter/nbconvert/templates/script/conf.json b/share/templates/script/conf.json similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/script/conf.json rename to share/templates/script/conf.json diff --git a/jupyter-data/share/jupyter/nbconvert/templates/script/script.j2 b/share/templates/script/script.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/script/script.j2 rename to share/templates/script/script.j2 diff --git a/jupyter-data/share/jupyter/nbconvert/templates/webpdf/conf.json b/share/templates/webpdf/conf.json similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/webpdf/conf.json rename to share/templates/webpdf/conf.json diff --git a/jupyter-data/share/jupyter/nbconvert/templates/webpdf/index.pdf.j2 b/share/templates/webpdf/index.pdf.j2 similarity index 100% rename from jupyter-data/share/jupyter/nbconvert/templates/webpdf/index.pdf.j2 rename to share/templates/webpdf/index.pdf.j2