Skip to content

Commit

Permalink
Fix jupyterlite install errors (#876)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispyles authored Oct 27, 2024
1 parent 79a54b9 commit b81ee3f
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

**v6.0.2:**

* Fixed dependency issues when installing on JupyterLite per [#875](https://github.com/ucbds-infra/otter-grader/issues/875)

**v6.0.1:**

* Updated dependency specifications to support any new minor version within the matching major version
Expand Down
1 change: 0 additions & 1 deletion otter/check/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ def running(self) -> bool:
``bool``: whether this interpreter is running
"""
ipython_interp = str(get_ipython())
print(ipython_interp)
return any(c in ipython_interp for c in self.check_strs)


Expand Down
14 changes: 13 additions & 1 deletion otter/export/exporters/via_html.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
"""PDF via HTML exporter"""

import nbconvert
import os

from typing import Any

from .base_exporter import BaseExporter, TEMPLATE_DIR


# nbconvert can't be used on jupyterlite, so try importing it and raise an error if it's not found
# when the exporter is used
_NBCONVERT_ERROR = None
try:
import nbconvert
except ImportError as e:
nbconvert = None
_NBCONVERT_ERROR = e


class PDFViaHTMLExporter(BaseExporter):
"""
An exporter that uses nbconvert's WebPDF exporter to convert notebooks to PDFs via HTML.
Expand All @@ -21,6 +30,9 @@ class PDFViaHTMLExporter(BaseExporter):

@classmethod
def convert_notebook(cls, nb_path: str, dest: str, **kwargs: Any):
if nbconvert is None:
raise _NBCONVERT_ERROR

options = cls.default_options.copy()
options.update(kwargs)

Expand Down
14 changes: 13 additions & 1 deletion otter/export/exporters/via_latex.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""PDF via LaTeX exporter"""

import nbconvert
import os
import warnings

Expand All @@ -10,6 +9,16 @@
from .base_exporter import BaseExporter, ExportFailedException, TEMPLATE_DIR


# nbconvert can't be used on jupyterlite, so try importing it and raise an error if it's not found
# when the exporter is used
_NBCONVERT_ERROR = None
try:
import nbconvert
except ImportError as e:
nbconvert = None
_NBCONVERT_ERROR = e


class PDFViaLatexExporter(BaseExporter):
"""
An exporter that uses nbconvert's PDF exporter to convert notebooks to PDFs via LaTeX.
Expand All @@ -28,6 +37,9 @@ class PDFViaLatexExporter(BaseExporter):

@classmethod
def convert_notebook(cls, nb_path: str, dest: str, *, xecjk: bool = False, **kwargs: Any):
if nbconvert is None:
raise _NBCONVERT_ERROR

warnings.filterwarnings("ignore", r"invalid escape sequence '\\c'", DeprecationWarning)

options = cls.default_options.copy()
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ ipykernel = { version = "*", optional = true}
ipylab = "^1.0.0"
ipython = "*"
ipywidgets = "^8.1.5"
jinja2 = "^3.1.4"
jinja2 = "^3.1"
jupyter_client = { version = "*", optional = true}
jupytext = "^1.16.4"
nbconvert = { version = ">=6.0.0", extras = ["webpdf"], markers = "sys_platform != 'emscripten' and sys_platform != 'wasi'" }
nbformat = ">=5.0.0"
pandas = ">=2.0.0"
pypdf = { version = "*", optional = true }
python-on-whales = ">=0.72.0,<1.0.0"
pyyaml = "^6.0.2"
requests = "^2.32.3"
pyyaml = "^6"
requests = "^2.31"
rpy2 = { version = "^3.5.16", optional = true }
wrapt = "^1.16.0"

Expand Down

0 comments on commit b81ee3f

Please sign in to comment.