mirror of
https://github.com/jeertmans/manim-slides.git
synced 2025-09-19 04:16:02 +08:00
chore(lib): reduce import overhead (#147)
* chore(lib): reduce import overhead This PR should reduce the import time overhead caused by manim imports. To solve this, manim is only imported when Slide or ThreeDSlide is needed. A custom logger is now defined, which copies the one from Manim Community. FFMPEG_BIN is now hardcoded, but should be configurable in the future via the CLI or some config file. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix(lib): remove last .manim import * fix(lib): remove print * chore(lib): fix typo --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
42
manim_slides/logger.py
Normal file
42
manim_slides/logger.py
Normal file
@ -0,0 +1,42 @@
|
||||
"""
|
||||
Logger utils, mostly copied from Manim Community:
|
||||
https://github.com/ManimCommunity/manim/blob/d5b65b844b8ce8ff5151a2f56f9dc98cebbc1db4/manim/_config/logger_utils.py#L29-L101
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from rich.logging import RichHandler
|
||||
|
||||
__all__ = ["logger", "make_logger"]
|
||||
|
||||
HIGHLIGHTED_KEYWORDS = [ # these keywords are highlighted specially
|
||||
"Played",
|
||||
"animations",
|
||||
"scene",
|
||||
"Reading",
|
||||
"Writing",
|
||||
"script",
|
||||
"arguments",
|
||||
"Invalid",
|
||||
"Aborting",
|
||||
"module",
|
||||
"File",
|
||||
"Rendering",
|
||||
"Rendered",
|
||||
]
|
||||
|
||||
|
||||
def make_logger() -> logging.Logger:
|
||||
"""
|
||||
Make a logger similar to the one used by Manim.
|
||||
"""
|
||||
RichHandler.KEYWORDS = HIGHLIGHTED_KEYWORDS
|
||||
rich_handler = RichHandler(
|
||||
show_time=True,
|
||||
)
|
||||
logger = logging.getLogger("manim-slides")
|
||||
logger.addHandler(rich_handler)
|
||||
return logger
|
||||
|
||||
|
||||
logger = logging.getLogger("manim-slides")
|
Reference in New Issue
Block a user