Skip to content

Commit

Permalink
Handle IPython not being installed in add-on release (#749)
Browse files Browse the repository at this point in the history
* handle IPython not being installed for add-on

* add jupyter install group

* Update citations.yml (#743)

* Update citations.yml

* Update citations.yml
  • Loading branch information
BradyAJohnston authored Feb 24, 2025
1 parent 31aa1b9 commit 976eb66
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
15 changes: 13 additions & 2 deletions molecularnodes/scene/base.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import bpy
from ..entities import Molecule
import tempfile
from IPython.display import Image, display
from pathlib import Path

try:
from IPython.display import Image, display
except ImportError:
Image = None
display = None
IS_EEVEE_NEXT = bpy.app.version[0] == 4 and bpy.app.version[1] >= 2


Expand Down Expand Up @@ -247,4 +251,11 @@ def snapshot(self, path: str | Path | None = None) -> None:
tmp_path = Path(tmpdir) / "snapshot.png"
bpy.context.scene.render.filepath = str(tmp_path)
bpy.ops.render.render(write_still=True, animation=False)
display(Image(tmp_path))
if display and Image:
display(Image(tmp_path))
else:
# Alternative handling like saving to disk
if path:
import shutil

shutil.copy(tmp_path, path)
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Documentation = "https://bradyajohnston.github.io/MolecularNodes"

[project.optional-dependencies]
bpy = ["bpy>=4.2"]
jupyter = ["jupyter", "IPython"]
dev = ["pytest", "pytest-cov", "syrupy", "scipy", "fake-bpy-module", "IPython"]
test = ["pytest", "pytest-cov", "syrupy", "scipy", "IPython"]
docs = ["quartodoc", "tomlkit", "nodepad", "jupyter", "IPython"]
Expand Down

0 comments on commit 976eb66

Please sign in to comment.