diff --git a/dev-environment.yml b/dev-environment.yml index 9e260ab3..2c2a4099 100644 --- a/dev-environment.yml +++ b/dev-environment.yml @@ -15,5 +15,5 @@ dependencies: - black - voici - pip: - - . + - .[markdown] - jupyterlite-xeus >=2.1.2 diff --git a/jupyterlite_sphinx/jupyterlite_sphinx.py b/jupyterlite_sphinx/jupyterlite_sphinx.py index 76ec2b2c..c0bfa443 100644 --- a/jupyterlite_sphinx/jupyterlite_sphinx.py +++ b/jupyterlite_sphinx/jupyterlite_sphinx.py @@ -28,9 +28,13 @@ new_code_cell, ) -import jupytext import nbformat +try: + import jupytext +except ImportError: + jupytext = None + try: import voici except ImportError: @@ -617,6 +621,11 @@ def run(self): notebook_is_stripped: bool = self.env.config.strip_tagged_cells if notebook_path.suffix.lower() == ".md": + if jupytext is None: + raise ImportError( + "jupyterlite-sphinx requires the jupytext package to process Markdown notebooks. " + 'Install "jupyterlite-sphinx[markdown]" with your package manager of choice.' + ) if self._target_is_stale(notebook_path, target_path): nb = jupytext.read(str(notebook_path)) if notebook_is_stripped: diff --git a/pyproject.toml b/pyproject.toml index b7e4fb3e..d44a323b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,11 +17,13 @@ dependencies = [ "jupyter_server", "jupyterlab_server", "jupyterlite-core >=0.2,<0.8", - "jupytext", "nbformat", "sphinx>=4", ] +[project.optional-dependencies] +markdown = ["jupytext"] + [dependency-groups] dev = [ "hatch",