File tree Expand file tree Collapse file tree 1 file changed +28
-7
lines changed Expand file tree Collapse file tree 1 file changed +28
-7
lines changed Original file line number Diff line number Diff line change 1+ import os
12import sys
3+ from contextlib import contextmanager
24from importlib .util import find_spec
35
6+
7+ @contextmanager
8+ def suppress_stdout ():
9+ with open (os .devnull , "w" ) as devnull :
10+ old_stdout = sys .stdout
11+ sys .stdout = devnull
12+ try :
13+ yield
14+ finally :
15+ sys .stdout = old_stdout
16+
17+
418MANIM_PACKAGE_NAME = "manim"
519MANIM_AVAILABLE = find_spec (MANIM_PACKAGE_NAME ) is not None
620MANIM_IMPORTED = MANIM_PACKAGE_NAME in sys .modules
1731 )
1832 MANIM = True
1933 MANIMGL = False
20- elif MANIM_AVAILABLE and not MANIMGL_IMPORTED :
34+ elif MANIM_IMPORTED :
35+ MANIM = True
36+ MANIMGL = False
37+ elif MANIMGL_IMPORTED :
38+ MANIM = False
39+ MANIMGL = True
40+ elif MANIM_AVAILABLE :
2141 MANIM = True
2242 MANIMGL = False
2343elif MANIMGL_AVAILABLE :
2444 MANIM = False
2545 MANIMGL = True
2646else :
27- raise ImportError (
47+ raise ModuleNotFoundError (
2848 "Either manim (community) or manimgl (3b1b) package must be installed"
2949 )
3050
3757 from manimlib .logger import log as logger
3858
3959else :
40- from manim import Scene , ThreeDScene , config , logger
60+ with suppress_stdout (): # Avoids printing "Manim Community v..."
61+ from manim import Scene , ThreeDScene , config , logger
4162
42- try : # For manim<v0.16.0.post0
43- from manim .constants import FFMPEG_BIN as FFMPEG_BIN
44- except ImportError :
45- FFMPEG_BIN = config .ffmpeg_executable
63+ try : # For manim<v0.16.0.post0
64+ from manim .constants import FFMPEG_BIN as FFMPEG_BIN
65+ except ImportError :
66+ FFMPEG_BIN = config .ffmpeg_executable
You can’t perform that action at this time.
0 commit comments