Skip to content

The animation engine for agents: blazingly fast math and 3D videos with Manim's Python API, on a Rust GPU core.

Python

Align repository tooling and contribution contracts with the release

Sina Atalayd6b1067a745d
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 00000000..c3d0fd55
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,3 @@
+# Source fingerprints identify the same bytes on every checkout, including Windows.
+# Git detects binary files and leaves their bytes intact.
+* text=auto eol=lf
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index 3789f311..d34abfd6 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -44,8 +44,8 @@ The Developer Guide has everything a change needs:
## Pull requests
- Keep a pull request to one change, and link the issue it resolves.
-- A fix or a feature comes with a test that shows it, and a user-visible change with a line
- under "Unreleased" in the changelog.
+- A fix or a feature comes with a test that shows it. After the first release, a user-visible
+ change also gets a line under "Unreleased" in the changelog.
- Before you open it, run `just check` and `just test`, and say in the pull request what you
ran and what you looked at. If the change could slow rendering down, run `just bench main`
and put its table in it.
diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml
index b5043901..82ce954f 100644
--- a/.github/ISSUE_TEMPLATE/bug.yml
+++ b/.github/ISSUE_TEMPLATE/bug.yml
@@ -64,6 +64,7 @@ body:
options:
- macOS
- Linux
+ - Windows
- Other
validations:
required: true
diff --git a/.github/ISSUE_TEMPLATE/documentation.yml b/.github/ISSUE_TEMPLATE/documentation.yml
index 21a5883b..e6f9ddef 100644
--- a/.github/ISSUE_TEMPLATE/documentation.yml
+++ b/.github/ISSUE_TEMPLATE/documentation.yml
@@ -7,7 +7,7 @@ body:
attributes:
label: Page
description: The page's address, if the problem is on a page.
- placeholder: https://manimgx.academa.ai/guide/quickstart/ # TODO: the docs domain
+ placeholder: https://manimgx.academa.ai/user-guide/quickstart/
- type: textarea
id: problem
attributes:
diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml
index de310496..a7bbbf85 100644
--- a/.github/ISSUE_TEMPLATE/question.yml
+++ b/.github/ISSUE_TEMPLATE/question.yml
@@ -2,7 +2,6 @@ name: Question
description: Ask how to do something with manimgx.
labels: [question]
body:
- # TODO: the docs domain
- type: markdown
attributes:
value: >-
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index fbd5d245..fa8c3740 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -1,9 +1,6 @@
-# One pull request per ecosystem, grouping its updates. A release waits a week first: most
-# compromised releases are caught within days. Security updates don't wait.
+# Group weekly dependency updates by ecosystem, with a seven-day release cooldown.
version: 2
updates:
- # The workflows pin their actions by commit; Dependabot moves the pins to new releases. A
- # pinned action gets no security alerts, so its updates are checked every week.
- package-ecosystem: github-actions
directory: /
schedule:
@@ -14,12 +11,10 @@ updates:
actions:
patterns: ["*"]
- # uv.lock follows new releases; a requirement in pyproject.toml changes only when a new
- # release falls outside it
- package-ecosystem: uv
directory: /
schedule:
- interval: monthly
+ interval: weekly
versioning-strategy: increase-if-necessary
cooldown:
default-days: 7
@@ -27,55 +22,50 @@ updates:
python:
patterns: ["*"]
- # the engine's crates
- package-ecosystem: cargo
directory: /rust
schedule:
- interval: monthly
+ interval: weekly
cooldown:
default-days: 7
groups:
rust:
patterns: ["*"]
- # the hooks' repositories (the local hooks run the locked tools, and are skipped)
- package-ecosystem: pre-commit
directory: /
schedule:
- interval: monthly
+ interval: weekly
cooldown:
default-days: 7
groups:
pre-commit:
patterns: ["*"]
- # the Docker image's base and its uv (docker/Dockerfile)
- package-ecosystem: docker
directory: /docker
schedule:
- interval: monthly
+ interval: weekly
cooldown:
default-days: 7
groups:
docker:
patterns: ["*"]
- # the browser package's compiler, bundler types, and formatter
- package-ecosystem: bun
directory: /browser
schedule:
- interval: monthly
+ interval: weekly
cooldown:
default-days: 7
groups:
browser-package:
patterns: ["*"]
- # the corpus review panel's web app
- package-ecosystem: bun
directory: /tests/integration/review/web
schedule:
- interval: monthly
+ interval: weekly
cooldown:
default-days: 7
groups:
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index f589a152..556b5b63 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -16,4 +16,5 @@ https://github.com/academa-labs/manimgx/blob/main/.github/CONTRIBUTING.md
<!-- Which AI tools helped, and with what. Write "None" if none did. -->
- [ ] I have reviewed every line of this change, and I can explain it.
-- [ ] A user-visible change has a line under "Unreleased" in `docs/content/changelog.md`.
+- [ ] After the first release, a user-visible change has a line under "Unreleased" in
+ `docs/content/changelog.md`.
diff --git a/.gitignore b/.gitignore
index 242b4da3..3f11b4d7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,8 @@ __pycache__/
*.py[cod]
build/
dist/
+/sources/
+/release-sources/
# Docs: the built site, its cache, the rendered examples, the generated gallery and the command
# line's reference
@@ -22,6 +24,7 @@ docs/content/reference/rendering/command-line.md
# Compiled extension module (rebuilt by maturin; never committed)
*.so
*.pyd
+/src/manimgx/dxcompiler.dll
# Test / lint / type-check caches
.pytest_cache/
diff --git a/AGENTS.md b/AGENTS.md
index 28657962..ad654260 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -17,6 +17,7 @@ this is the short version.
hygiene). It must pass.
- `just test [PYTEST ARGS]`: the suite, in parallel; `just test-thorough`: the unit tests'
properties on 2,000 examples each; `just mutate`: mutation testing (`[tool.mutmut]`).
+- `just test-rust`: the Rust core and native libraries; the Python suite tests the bindings.
- `just test-typescript`: the browser package's tests, including its compiled worker and
public declarations.
- `just corpus …`: render, compare and review the integration corpus (`just corpus --help`).
diff --git a/CITATION.cff b/CITATION.cff
index 3e1f0277..31f89649 100644
--- a/CITATION.cff
+++ b/CITATION.cff
@@ -10,8 +10,8 @@ abstract: >-
videos from Python scenes. Scenes use the API of Manim Community Edition, and manimgx
annotates all of it with types, so a type checker finds errors before a render. A Rust core
draws each frame on the GPU, typesets text and LaTeX mathematics with Typst, and encodes the
- video and its sound to MP4. The engine calculates each frame at its exact time, so a scene
- is the same at all frame rates. A check command runs a scene without video, prints its
+ video and its sound to MP4. The engine evaluates animations at each frame's authored time.
+ The inspect command runs a scene without video, prints its
timeline and layout problems, for example text over other text, and writes a storyboard. In
a web browser, Pyodide runs the same scenes in a Web Worker, and a WebAssembly build of the
core draws them with WebGPU.
diff --git a/justfile b/justfile
index 94c8e80f..0dec792a 100644
--- a/justfile
+++ b/justfile
@@ -54,6 +54,12 @@ check:
check-typescript:
cd browser && bun install --frozen-lockfile && bun run check
+# Check the browser engine without the native extension's features (target installed by CI)
+[group('development')]
+check-rust-web:
+ cargo check --locked --manifest-path rust/Cargo.toml -p manimgx-engine \
+ --target wasm32-unknown-unknown --no-default-features --features web
+
# Testing:
# Run the tests in parallel; arguments go to pytest (`just test tests/docs -x`)
@@ -61,22 +67,38 @@ check-typescript:
test *args:
uv run --frozen pytest -n auto {{ args }}
-# Test the browser package, its compiled worker, and its public declarations
+# Test the Rust core and native libraries; the installed-wheel suite tests Python's bindings
+[group('testing')]
+test-rust:
+ cargo test --locked --release --manifest-path rust/Cargo.toml --workspace \
+ --no-default-features \
+ --features manimgx-engine/render,manimgx-engine/export,manimgx-engine/typeset,manimgx-engine/player
+
+# Exercise native browser ownership with real Web Audio (wasm-bindgen-test-runner and a browser driver).
+[group('testing')]
+test-rust-web:
+ CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER=wasm-bindgen-test-runner \
+ cargo test --locked --manifest-path rust/Cargo.toml -p manimgx-engine \
+ --target wasm32-unknown-unknown --no-default-features --features web --lib
+
+# Test the browser package, its worker and declarations, and the corpus review panel
[group('testing')]
test-typescript:
cd browser && bun install --frozen-lockfile && bun run test
+ cd tests/integration/review/web && bun install --frozen-lockfile && bun run test
# Run the tests and measure their coverage: a summary here, every line in htmlcov/
[group('testing')]
test-coverage *args:
- uv run --frozen pytest -n auto --cov --cov-report=term --cov-report=html {{ args }}
+ MANIMGX_COVERAGE_SOURCE="$(uv run --frozen python -c 'import manimgx; print(manimgx.__path__[0])')" \
+ uv run --frozen pytest -n auto --cov --cov-report=term --cov-report=html {{ args }}
# Combine the coverage of several test runs (their .coverage.* files) into htmlcov/ and a table
[group('testing')]
combine-coverage directory:
- uvx coverage combine --quiet {{ directory }}
- uvx coverage html --quiet
- uvx coverage report --format=markdown
+ uv run --frozen coverage combine --quiet {{ directory }}
+ uv run --frozen coverage html --quiet
+ uv run --frozen coverage report --format=markdown
# Run the unit tests' properties on 2,000 examples each (the `thorough` Hypothesis profile)
[group('testing')]
@@ -112,9 +134,17 @@ review:
# Build the docs site into docs/site/: render its examples, write its reference, build its pages
[group('docs')]
-build-docs:
+build-docs: render-docs build-docs-pages
+
+# Render missing or changed examples; optional source paths or --jobs limit the work
+[group('docs')]
+render-docs *args:
+ uv run --frozen --no-default-groups --group docs python -m docs.examples {{ args }}
+
+# Build the pages from completed films (CI saves the films before this stage)
+[group('docs')]
+build-docs-pages:
uv run --frozen --no-default-groups --group docs python -m scripts.docs.gallery
- uv run --frozen --no-default-groups --group docs python -m docs.examples
uv run --frozen --no-default-groups --group docs python -m scripts.docs.reference
uv run --frozen --no-default-groups --group docs python -m zensical build --strict \
--config-file docs/zensical.toml
@@ -123,8 +153,8 @@ build-docs:
# Serve the docs site at http://localhost:8000, rebuilt as its pages change
[group('docs')]
serve-docs:
- uv run --frozen --no-default-groups --group docs python -m scripts.docs.gallery
-uv run --frozen --no-default-groups --group docs python -m docs.examples
+ uv run --frozen --no-default-groups --group docs python -m scripts.docs.gallery
uv run --frozen --no-default-groups --group docs python -m scripts.docs.reference
uv run --frozen --no-default-groups --group docs python -m zensical serve \
--config-file docs/zensical.toml
@@ -152,28 +182,42 @@ build-npm:
build-sdist:
uv build --sdist --out-dir dist
-# (the source distribution with every crate rust/Cargo.lock names and each archive the engine's
-# build fetches, and the cargo configuration that reads them: the source of all the wheels hold,
-# which builds them offline. A wheel is built from it, which reads the crates from it alone and
-# downloads the archives into it)
-# Build the wheels' complete source into dist/, from the source distribution
+# (the platform builds' source artifacts merged into release-sources/, with the repository,
+# every crate and each checked archive the engine uses. System build tools are prerequisites;
+# distribution source RPMs describe the exact libraries bundled by the Linux builds)
+# Build the wheels' and launchers' complete source into dist/, from the committed repository
[group('release')]
-build-source: build-sdist
+build-source sources="release-sources": build-sdist
#!/usr/bin/env bash
set -euo pipefail
version="$(uv version --short)"
+ sources="$(realpath "{{ sources }}")"
+ uv run --no-project scripts/release/linux_sources.py --verify "${sources}"
+ uv run --no-project scripts/release/create_executable.py --verify-sources "${sources}"
work="$(mktemp -d)"
trap 'rm -rf "${work}"' EXIT
- tar -xzf "dist/manimgx-${version}.tar.gz" -C "${work}"
+ just _source-tree "${work}/manimgx-${version}"
cd "${work}/manimgx-${version}"
+ cp -R "${sources}" sources
mkdir .cargo
cargo vendor --locked --manifest-path rust/Cargo.toml vendor > .cargo/config.toml
printf '\n[net]\noffline = true\n\n[env]\nMANIMGX_SOURCES = { value = "sources", relative = true }\n' \
>> .cargo/config.toml
+ CARGO_TARGET_DIR="${work}/target" MANIMGX_SOURCES="$PWD/sources" \
+ sh scripts/release/build_lavapipe.sh "${work}/lavapipe" --sources-only
CARGO_TARGET_DIR="${work}/target" uv build --wheel --out-dir "${work}/wheel" .
tar -cf - -C "${work}" "manimgx-${version}" | xz -T0 -9 \
> "{{ justfile_directory() }}/dist/manimgx-${version}-source.tar.xz"
+# A release's complete project source, including build recipes the pip sdist does not need.
+_source-tree directory:
+ #!/usr/bin/env bash
+ set -euo pipefail
+ git diff --quiet HEAD -- || { echo "Commit tracked changes before exporting release source." >&2; exit 1; }
+ mkdir -p "{{ directory }}"
+ git archive HEAD | tar -xf - -C "{{ directory }}"
+ git rev-parse HEAD > "{{ directory }}/SOURCE_COMMIT"
+
# Build the font packages, their wheels and source distributions, into dist/
[group('release')]
build-fonts:
diff --git a/pyproject.toml b/pyproject.toml
index c06da981..e9596bf2 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -13,9 +13,10 @@ requires-python = ">=3.13"
# (OFL-1.1, LPPL-1.3c as the GUST Font License, GPL-3.0-or-later with its font exception,
# DejaVu's Bitstream Vera and Arev terms), HTML data (W3C) and citation styles (CC-BY-SA-3.0);
# and in the Linux wheels, Mesa's lavapipe with LLVM (Apache-2.0 WITH LLVM-exception;
-# LICENSE-LAVAPIPE). The Noto fonts are manimgx-fonts'.
-license = "MIT AND GPL-2.0-or-later AND LGPL-2.1-or-later AND Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND BSL-1.0 AND ISC AND MPL-2.0 AND Unicode-3.0 AND Zlib AND 0BSD AND OFL-1.1 AND LPPL-1.3c AND GPL-3.0-or-later WITH Font-exception-2.0 AND Bitstream-Vera AND LicenseRef-Arev-Fonts AND W3C-20150513 AND CC-BY-SA-3.0 AND Apache-2.0 WITH LLVM-exception"
-license-files = ["LICENSE", "LICENSE-THIRD-PARTY", "LICENSE-LAVAPIPE"]
+# LICENSE-LAVAPIPE); and Windows wheels' DXC (NCSA, LICENSE-DXC). The Noto fonts are
+# manimgx-fonts'.
+license = "MIT AND GPL-2.0-or-later AND LGPL-2.1-or-later AND Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND BSL-1.0 AND ISC AND MPL-2.0 AND Unicode-3.0 AND Zlib AND 0BSD AND OFL-1.1 AND LPPL-1.3c AND GPL-3.0-or-later WITH Font-exception-2.0 AND Bitstream-Vera AND LicenseRef-Arev-Fonts AND W3C-20150513 AND CC-BY-SA-3.0 AND Apache-2.0 WITH LLVM-exception AND NCSA AND MIT-Khronos-old"
+license-files = ["LICENSE", "LICENSE-THIRD-PARTY", "LICENSE-LAVAPIPE", "LICENSE-DXC"]
authors = [
{ name = "Sina Atalay", email = "[email protected]" },
{ name = "Abdullah Geduk", email = "[email protected]" },
@@ -45,6 +46,8 @@ dependencies = [
"skia-pathops>=0.8; sys_platform != 'emscripten'",
"svgelements>=1.9.6",
"typer>=0.27.2; sys_platform != 'emscripten'",
+ # closed TypedDicts (PEP 728) for the keyword arguments, which typing has from 3.15
+ "typing-extensions>=4.13",
]
[project.scripts]
@@ -61,9 +64,13 @@ build-backend = "maturin"
[tool.maturin]
module-name = "manimgx._engine"
manifest-path = "rust/engine/Cargo.toml"
+locked = true
# what a wheel takes besides the package's sources: the lavapipe a Linux wheel bundles, built
# before it (scripts/release/build_lavapipe.sh) and ignored by git
-include = [{ path = "manimgx/lavapipe/libvulkan_lvp.so", format = "wheel" }]
+include = [
+ { path = "manimgx/lavapipe/libvulkan_lvp.so", format = "wheel" },
+ { path = "dxcompiler.dll", from = "out-dir", to = "manimgx/" },
+]
# the font packages, as they are here: manimgx requires them at exact versions, and in the
# workspace those are fonts/'s, installed editable, like manimgx, whose engine uv builds
@@ -137,6 +144,8 @@ before-all = [
"sh scripts/release/build_lavapipe.sh {package}/src/manimgx/lavapipe",
]
environment = { PATH = "$HOME/.cargo/bin:$PATH" }
+environment-pass = ["MANIMGX_SOURCES"]
+repair-wheel-command = "auditwheel repair -w {dest_dir} {wheel} && python {project}/scripts/release/linux_sources.py {dest_dir}"
[tool.cibuildwheel.pyodide]
# the browser's wheel (`just build-wheel pyodide`): the engine without the GPU (typesetting,
@@ -188,13 +197,17 @@ also_copy = ["src/manimgx/"]
pytest_add_cli_args = ["-p", "no:randomly", "--hypothesis-profile=mutation"]
[tool.coverage.run]
-# the package, measured in the tests' processes and in the ones they start (the corpus renders
-# each case in its own)
-source_pkgs = ["manimgx"]
+# Bind coverage to the installed product's directory, including its subprocesses.
+# A frozen reference has the same import name but is not the code under test.
+# Reporting defaults to the checkout after the platform paths have been combined.
+source = ["${MANIMGX_COVERAGE_SOURCE-src/manimgx}"]
patch = ["subprocess"]
# paths relative to the repository, so each OS's runs combine into one report
relative_files = true
+[tool.coverage.paths]
+source = ["src/manimgx", "*/site-packages/manimgx"]
+
[tool.ruff]
# first-party: the package (the tests import it as a third party would)
src = ["src"]
diff --git a/tests/strategies.py b/tests/strategies.py
index 0b0bca2e..00bd4f5e 100644
--- a/tests/strategies.py
+++ b/tests/strategies.py
@@ -300,9 +300,7 @@ MOBJECTS: dict[str, Callable[[], m.Mobject]] = {
"ValueTracker": lambda: m.ValueTracker(2.5),
"Variable": lambda: m.Variable(1.5, "x"),
"Vector": lambda: m.Vector(m.UP),
- "VectorField": lambda: m.VectorField(
- lambda p: p, x_range=[-1, 1, 1], y_range=[-1, 1, 1]
- ),
+ "VectorField": lambda: m.VectorField(lambda p: p),
"VectorizedPoint": lambda: m.VectorizedPoint(m.UR),
}
mobjects = st.sampled_from(sorted(MOBJECTS)).map(lambda name: MOBJECTS[name]())
diff --git a/tests/test_coverage.py b/tests/test_coverage.py
new file mode 100644
index 00000000..cfc7d395
--- /dev/null
+++ b/tests/test_coverage.py
@@ -0,0 +1,69 @@
+"""Coverage belongs to the product under test, not another package with the same name."""
+
+import os
+import subprocess
+import sys
+from pathlib import Path
+
+from coverage import CoverageData
+
+ROOT = Path(__file__).resolve().parents[1]
+
+
+def test_coverage_includes_current_children_and_excludes_reference_packages(
+ tmp_path: Path,
+) -> None:
+ current = tmp_path / "current" / "manimgx"
+ reference = tmp_path / "reference" / "manimgx"
+ current.mkdir(parents=True)
+ reference.mkdir(parents=True)
+ (current / "__init__.py").write_text(
+ "def parent():\n return 'parent'\n"
+ "def child():\n return 'child'\n"
+ "def unused():\n return 'unused'\n",
+ encoding="utf-8",
+ )
+ (reference / "__init__.py").write_text(
+ "def reference():\n return 'reference'\n", encoding="utf-8"
+ )
+ script = tmp_path / "run.py"
+ script.write_text(
+ "import os, subprocess, sys\n"
+ "import manimgx\n"
+ "assert manimgx.parent() == 'parent'\n"
+ "for package, call in zip(sys.argv[1:], ['child', 'reference']):\n"
+ " subprocess.run([sys.executable, '-c', "
+ "f\"import manimgx; assert manimgx.{call}() == '{call}'\"], "
+ "env=os.environ | {'PYTHONPATH': package}, check=True)\n",
+ encoding="utf-8",
+ )
+ data_file = tmp_path / ".coverage"
+ env = {
+ key: value
+ for key, value in os.environ.items()
+ if not key.startswith("COVERAGE_")
+ }
+ env |= {
+ "COVERAGE_FILE": str(data_file),
+ "COVERAGE_RCFILE": str(ROOT / "pyproject.toml"),
+ "MANIMGX_COVERAGE_SOURCE": str(current),
+ "PYTHONPATH": str(current.parent),
+ }
+ for args in (
+ ["run", str(script), str(current.parent), str(reference.parent)],
+ ["combine", str(tmp_path)],
+ ):
+ done = subprocess.run(
+ [sys.executable, "-m", "coverage", *args],
+ cwd=tmp_path,
+ env=env,
+ capture_output=True,
+ text=True,
+ check=False,
+ )
+ assert done.returncode == 0, done.stdout + done.stderr
+ data = CoverageData(basename=str(data_file))
+ data.read()
+ measured = str((current / "__init__.py").relative_to(tmp_path))
+ assert data.measured_files() == {measured}
+ assert set(data.lines(measured) or []) == {1, 2, 3, 4, 5}
diff --git a/uv.lock b/uv.lock
index e6b57717..4fb92874 100644
--- a/uv.lock
+++ b/uv.lock
@@ -915,6 +915,7 @@ dependencies = [
{ name = "skia-pathops", marker = "sys_platform != 'emscripten'" },
{ name = "svgelements" },
{ name = "typer", marker = "sys_platform != 'emscripten'" },
+ { name = "typing-extensions" },
]
[package.dev-dependencies]
@@ -951,6 +952,7 @@ requires-dist = [
{ name = "skia-pathops", marker = "sys_platform != 'emscripten'", specifier = ">=0.8" },
{ name = "svgelements", specifier = ">=1.9.6" },
{ name = "typer", marker = "sys_platform != 'emscripten'", specifier = ">=0.27.2" },
+ { name = "typing-extensions", specifier = ">=4.13" },
]
[package.metadata.requires-dev]