Skip to content

Commit e51468a

Browse files
Make jupytext an optional dependency (#336)
* Add "markdown" extra dependency * Guard `jupytext` import and raise helpful error * Remove extra quotes from environment file * Avoid restricting installation instructions to be specific to `pip`/PyPI --------- Co-authored-by: Matt Fisher <3608264+mfisher87@users.noreply.github.com>
1 parent 39d5920 commit e51468a

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

dev-environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ dependencies:
1515
- black
1616
- voici
1717
- pip:
18-
- .
18+
- .[markdown]
1919
- jupyterlite-xeus >=2.1.2

jupyterlite_sphinx/jupyterlite_sphinx.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@
2828
new_code_cell,
2929
)
3030

31-
import jupytext
3231
import nbformat
3332

33+
try:
34+
import jupytext
35+
except ImportError:
36+
jupytext = None
37+
3438
try:
3539
import voici
3640
except ImportError:
@@ -617,6 +621,11 @@ def run(self):
617621
notebook_is_stripped: bool = self.env.config.strip_tagged_cells
618622

619623
if notebook_path.suffix.lower() == ".md":
624+
if jupytext is None:
625+
raise ImportError(
626+
"jupyterlite-sphinx requires the jupytext package to process Markdown notebooks. "
627+
'Install "jupyterlite-sphinx[markdown]" with your package manager of choice.'
628+
)
620629
if self._target_is_stale(notebook_path, target_path):
621630
nb = jupytext.read(str(notebook_path))
622631
if notebook_is_stripped:

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ dependencies = [
1717
"jupyter_server",
1818
"jupyterlab_server",
1919
"jupyterlite-core >=0.2,<0.8",
20-
"jupytext",
2120
"nbformat",
2221
"sphinx>=4",
2322
]
2423

24+
[project.optional-dependencies]
25+
markdown = ["jupytext"]
26+
2527
[dependency-groups]
2628
dev = [
2729
"hatch",

0 commit comments

Comments
 (0)