mirror of
https://github.com/jeertmans/manim-slides.git
synced 2025-05-19 19:46:49 +08:00

* refactor(lib): change how manim API is imported * chore(lib): delete old files * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * wip: moving all commands * adding animations * fix tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix mypy * fixes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * trying to fix docs * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * wip: docs * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * make it work * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * wip test * tests are working * improving docs * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix index * docs: nicer shift * docs: nicer quickstart example * fix tests * change tests * move coverage to test workflow * fix(tests): remove resolve * strict resolve * change local path test * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * documented changes * cleanup docs * cleanup files * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix(ci): set type --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
64 lines
1.3 KiB
Python
64 lines
1.3 KiB
Python
__all__ = [
|
|
"MANIM",
|
|
"MANIMGL",
|
|
"API_NAME",
|
|
"Slide",
|
|
"ThreeDSlide",
|
|
]
|
|
|
|
|
|
import os
|
|
import sys
|
|
|
|
|
|
class ManimApiNotFoundError(ImportError):
|
|
"""Error raised if specified manim API could be imported."""
|
|
|
|
_msg = "Could not import the specified manim API"
|
|
|
|
def __init__(self) -> None:
|
|
super().__init__(self._msg)
|
|
|
|
|
|
API_NAMES = {
|
|
"manim": "manim",
|
|
"manimce": "manim",
|
|
"manimlib": "manimlib",
|
|
"manimgl": "manimlib",
|
|
}
|
|
|
|
MANIM_API: str = "MANIM_API"
|
|
FORCE_MANIM_API: str = "FORCE_" + MANIM_API
|
|
|
|
API: str = os.environ.get(MANIM_API, "manim").lower()
|
|
|
|
|
|
if API not in API_NAMES:
|
|
raise ImportError(
|
|
f"Specified MANIM_API={API!r} is not in valid options: " f"{API_NAMES}",
|
|
)
|
|
|
|
API_NAME = API_NAMES[API]
|
|
|
|
if not os.environ.get(FORCE_MANIM_API):
|
|
if "manim" in sys.modules:
|
|
API_NAME = "manim"
|
|
elif "manimlib" in sys.modules:
|
|
API_NAME = "manimlib"
|
|
|
|
MANIM: bool = API_NAME == "manim"
|
|
MANIMGL: bool = API_NAME == "manimlib"
|
|
|
|
if MANIM:
|
|
try:
|
|
from .manim import Slide, ThreeDSlide
|
|
except ImportError as e:
|
|
raise ManimApiNotFoundError from e
|
|
elif MANIMGL:
|
|
try:
|
|
from .manimlib import Slide, ThreeDSlide
|
|
except ImportError as e:
|
|
raise ManimApiNotFoundError from e
|
|
else:
|
|
raise ManimApiNotFoundError
|