Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[@casperalgera](https://github.com/casperalgera) [#556](https://github.com/jeertmans/manim-slides/pull/556)
- Added example in the school work section of the gallery.
[@amstrdm](https://github.com/amstrdm) [#557](https://github.com/jeertmans/manim-slides/pull/557)
- Fixed some tests that were failing.
[#550](https://github.com/jeertmans/manim-slides/pull/550)
- Pinned `setuptools<81` for `manimgl` extra, as `setuptools>=81`
dropped support for its API.
[#550](https://github.com/jeertmans/manim-slides/pull/550)

(unreleased-fixed)=
### Fixed

- Fixed potential import issue of ManimGL, importing `manimlib` will parse `sys.argv`
to initialize the config, which can lead to surprising behavior when using the library with
different command line arguments that are not meant to be used by ManimGL.
[#550](https://github.com/jeertmans/manim-slides/pull/550)

(v5.5.1)=
## [v5.5.1](https://github.com/jeertmans/manim-slides/compare/v5.5.0...v5.5.1)
Expand Down
5 changes: 5 additions & 0 deletions manim_slides/checkhealth.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ def checkhealth() -> None:
click.secho("\tmanim not found", bold=True)

try:
# Manimlib parses sys.argv on import, so we clear it temporarily.
old_argv = sys.argv
sys.argv = [__file__]
from manimlib import __version__ as manimlib_version

sys.argv = old_argv

click.echo(f"\tmanimgl (version: {manimlib_version})")
except ImportError:
click.secho("\tmanimgl not found", bold=True)
Expand Down
9 changes: 9 additions & 0 deletions manim_slides/slide/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,17 @@
from manim import LEFT, AnimationGroup, FadeIn, FadeOut
from manim.mobject.mobject import Mobject
else:
import sys

# Manimlib parses sys.argv on import, so we clear it temporarily.
old_argv = sys.argv
sys.argv = [__file__]
from manimlib import LEFT, AnimationGroup, FadeIn, FadeOut

sys.argv = old_argv

del sys

Mobject = Any


Expand Down
10 changes: 8 additions & 2 deletions manim_slides/slide/manimlib.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import sys
from pathlib import Path
from typing import Any, ClassVar, Optional

from manimlib import Scene, ThreeDCamera
# Manimlib parses sys.argv on import, so we clear it temporarily.
old_argv = sys.argv
sys.argv = [__file__]
from manimlib import Scene, ThreeDCamera # noqa: E402

from .base import BaseSlide
sys.argv = old_argv

from .base import BaseSlide # noqa: E402


class Slide(BaseSlide, Scene): # type: ignore[misc]
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ docs = [
]
tests = [
"importlib-metadata>=8.6.1;python_version<'3.10'",
"manim-slides[full,manimgl,pyqt6,pyside6,sphinx-directive]",
"manim-slides[full,manim,manimgl,pyqt6,pyside6,sphinx-directive]",
"pytest>=7.4.0",
"pytest-cov>=4.1.0",
"pytest-env>=0.8.2",
Expand Down Expand Up @@ -80,7 +80,7 @@ full = [
]
magic = ["manim-slides[manim]", "ipython>=8.12.2"]
manim = ["manim>=0.19"]
manimgl = ["manimgl>=1.7.2"]
manimgl = ["manimgl>=1.7.2", "setuptools<81"]
pyqt6 = ["pyqt6>=6.7.0"]
pyqt6-full = ["manim-slides[full,pyqt6]"]
pyside6 = ["pyside6>=6.6.1,!=6.8.1.1"]
Expand Down Expand Up @@ -205,13 +205,13 @@ filterwarnings = [
'ignore::DeprecationWarning:pkg_resources.*:',
'ignore:invalid escape sequence.*:DeprecationWarning',
'ignore:invalid escape sequence.*:SyntaxWarning',
'ignore:urllib3 v2 only supports OpenSSL.*:urllib3.exceptions.NotOpenSSLWarning',
]

[tool.ruff]
extend-exclude = ["manim_slides/resources.py"]
extend-include = ["*.ipynb"]
line-length = 88
target-version = "py39"

[tool.ruff.lint]
extend-ignore = [
Expand Down
2 changes: 1 addition & 1 deletion tests/test_checkhealth.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"names",
list(
chain.from_iterable(
combinations(("manim", "manimlib", "PyQt6", "PySide6"), r=r)
combinations(("manim", "manimlib", "pyqt6", "pyside6"), r=r)
for r in range(0, 5)
)
),
Expand Down
2 changes: 1 addition & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_convert(slides_folder: Path, extension: str) -> None:

@pytest.mark.parametrize(("extension",), [("html",)])
def test_convert_data_uri_deprecated(slides_folder: Path, extension: str) -> None:
runner = CliRunner(mix_stderr=False)
runner = CliRunner()

with runner.isolated_filesystem():
with warnings.catch_warnings(record=True) as w:
Expand Down
14 changes: 12 additions & 2 deletions tests/test_manim.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ def assert_import(

@skip_if_py39
def test_force_api() -> None:
# Manimlib parses sys.argv on import, so we clear it temporarily.
old_argv = sys.argv
sys.argv = [__file__]
pytest.importorskip("manimlib")
sys.argv = old_argv
import manim # noqa: F401

if "manimlib" in sys.modules:
Expand Down Expand Up @@ -62,9 +66,12 @@ def test_invalid_api() -> None:
@skip_if_py39
@pytest.mark.filterwarnings("ignore:assert_import")
def test_manim_and_manimgl_imported() -> None:
# Manimlib parses sys.argv on import, so we clear it temporarily.
old_argv = sys.argv
sys.argv = [__file__]
pytest.importorskip("manimlib")
sys.argv = old_argv
import manim # noqa: F401
import manimlib # noqa: F401

assert_import(
api_name="manim",
Expand All @@ -88,8 +95,11 @@ def test_manim_imported() -> None:

@skip_if_py39
def test_manimgl_imported() -> None:
# Manimlib parses sys.argv on import, so we clear it temporarily.
old_argv = sys.argv
sys.argv = [__file__]
pytest.importorskip("manimlib")
import manimlib # noqa: F401
sys.argv = old_argv

if "manim" in sys.modules:
del sys.modules["manim"]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_present.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_present_unexisting_slide(args: tuple[str, ...]) -> None:
results = runner.invoke(present, ["UnexistingSlide", *args])

assert results.exit_code != 0
assert "UnexistingSlide.json does not exist" in results.stdout
assert "UnexistingSlide.json does not exist" in results.output


def test_present_full_screen(args: tuple[str, ...]) -> None:
Expand Down
4 changes: 4 additions & 0 deletions tests/test_slide.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,13 @@ def init_slide(cls: SlideType) -> Slide:
if issubclass(cls, CESlide):
return cls()
elif issubclass(cls, GLSlide):
# Manimlib parses sys.argv on import, so we clear it temporarily.
old_argv = sys.argv
sys.argv = [__file__]
from manimlib.config import parse_cli

_args = parse_cli()
sys.argv = old_argv
return cls()

raise ValueError(f"Unsupported class {cls}")
Expand Down
Loading
Loading