mirror of
https://github.com/ManimCommunity/manim.git
synced 2026-06-22 10:01:47 +00:00
Merge branch 'main' of https://github.com/JasonGrace2282/manim into experimental
This commit is contained in:
commit
620766e6dd
24 changed files with 2296 additions and 2107 deletions
14
.github/workflows/ci.yml
vendored
14
.github/workflows/ci.yml
vendored
|
|
@ -23,7 +23,7 @@ jobs:
|
|||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-22.04, macos-13, windows-latest]
|
||||
python: ["3.10", "3.11", "3.12"]
|
||||
python: ["3.10", "3.11", "3.12", "3.13"]
|
||||
|
||||
steps:
|
||||
- name: Checkout the repository
|
||||
|
|
@ -31,7 +31,7 @@ jobs:
|
|||
|
||||
- name: Install Poetry
|
||||
run: |
|
||||
pipx install "poetry==1.7.*"
|
||||
pipx install "poetry==1.8.*"
|
||||
poetry config virtualenvs.prefer-active-python true
|
||||
|
||||
- name: Setup Python ${{ matrix.python }}
|
||||
|
|
@ -142,10 +142,7 @@ jobs:
|
|||
Expand-Archive -LiteralPath "$($env:TMP)\TinyTex.zip" -DestinationPath "$($PWD)\ManimCache\LatexWindows"
|
||||
$env:Path = "$($PWD)\ManimCache\LatexWindows\TinyTeX\bin\windows;$($env:PATH)"
|
||||
tlmgr update --self
|
||||
foreach ($c in $tinyTexPackages){
|
||||
$c=$c.Trim()
|
||||
tlmgr install $c
|
||||
}
|
||||
tlmgr install $tinyTexPackages
|
||||
$env:PATH=$OriPath
|
||||
echo "Completed Latex"
|
||||
|
||||
|
|
@ -156,10 +153,9 @@ jobs:
|
|||
$env:Path = "$env:USERPROFILE\.poetry\bin;$($env:PATH)"
|
||||
echo "$env:Path" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||
|
||||
- name: Install manim
|
||||
- name: Install dependencies and manim
|
||||
run: |
|
||||
poetry config installer.modern-installation false
|
||||
poetry install
|
||||
poetry install --all-extras
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
|
|
|
|||
41
conftest.py
41
conftest.py
|
|
@ -1,41 +0,0 @@
|
|||
# This file is automatically picked by pytest
|
||||
# while running tests. So, that each test is
|
||||
# run on difference temporary directories and avoiding
|
||||
# errors.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import moderngl
|
||||
|
||||
# If it is running Doctest the current directory
|
||||
# is changed because it also tests the config module
|
||||
# itself. If it's a normal test then it uses the
|
||||
# tempconfig to change directories.
|
||||
import pytest
|
||||
from _pytest.doctest import DoctestItem
|
||||
|
||||
from manim import config, tempconfig
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def temp_media_dir(tmpdir, monkeypatch, request):
|
||||
if isinstance(request.node, DoctestItem):
|
||||
monkeypatch.chdir(tmpdir)
|
||||
yield tmpdir
|
||||
else:
|
||||
with tempconfig({"media_dir": str(tmpdir)}):
|
||||
assert config.media_dir == str(tmpdir)
|
||||
yield tmpdir
|
||||
|
||||
|
||||
def pytest_report_header(config):
|
||||
ctx = moderngl.create_standalone_context()
|
||||
info = ctx.info
|
||||
ctx.release()
|
||||
return (
|
||||
"\nOpenGL information",
|
||||
"------------------",
|
||||
f"vendor: {info['GL_VENDOR'].strip()}",
|
||||
f"renderer: {info['GL_RENDERER'].strip()}",
|
||||
f"version: {info['GL_VERSION'].strip()}\n",
|
||||
)
|
||||
|
|
@ -3,3 +3,5 @@ myst-parser
|
|||
sphinx>=7.3
|
||||
sphinx-copybutton
|
||||
sphinxext-opengraph
|
||||
sphinx-design
|
||||
sphinx-reredirects
|
||||
|
|
|
|||
|
|
@ -51,11 +51,22 @@ extensions = [
|
|||
"sphinx.ext.inheritance_diagram",
|
||||
"sphinxcontrib.programoutput",
|
||||
"myst_parser",
|
||||
"sphinx_design",
|
||||
"sphinx_reredirects",
|
||||
]
|
||||
|
||||
# Automatically generate stub pages when using the .. autosummary directive
|
||||
autosummary_generate = True
|
||||
|
||||
myst_enable_extensions = ["colon_fence", "amsmath"]
|
||||
|
||||
# redirects (for moved / deleted pages)
|
||||
redirects = {
|
||||
"installation/linux": "uv.html",
|
||||
"installation/macos": "uv.html",
|
||||
"installation/windows": "uv.html",
|
||||
}
|
||||
|
||||
# generate documentation from type hints
|
||||
ALIAS_DOCS_DICT = parse_module_attributes()[0]
|
||||
autodoc_typehints = "description"
|
||||
|
|
|
|||
|
|
@ -120,19 +120,24 @@ of [ManimPango's README](https://github.com/ManimCommunity/ManimPango).
|
|||
|
||||
---
|
||||
|
||||
(not-on-path)=
|
||||
## I am using Windows and get the error `X is not recognized as an internal or external command, operable program or batch file`
|
||||
|
||||
Regardless of whether `X` says `python` or `manim`, this means that the executable you
|
||||
are trying to run is not located in one of the directories your system is looking
|
||||
for them (specified by the `PATH` variable). Take a look at the instructions
|
||||
{doc}`in the installation guide for Windows </installation/windows>`, or
|
||||
[this StackExchange answer](https://superuser.com/questions/143119/how-do-i-add-python-to-the-windows-path/143121#143121)
|
||||
to get help with editing the `PATH` variable manually.
|
||||
If you have followed {doc}`our local installation instructions </installation/uv>` and
|
||||
have not activated the corresponding virtual environment, make sure to use `uv run manim ...`
|
||||
instead of just `manim` (or activate the virtual environment by following the instructions
|
||||
printed when running `uv venv`).
|
||||
|
||||
If `python` is recognized but not `manim` or `pip`, you can try running
|
||||
Otherwise there is a problem with the directories where your system is looking for
|
||||
executables (the `PATH` variable).
|
||||
If `python` is recognized, you can try running
|
||||
commands by prepending `python -m`. That is, `manim` becomes `python -m manim`,
|
||||
and `pip` becomes `python -m pip`.
|
||||
|
||||
Otherwise see
|
||||
[this StackExchange answer](https://superuser.com/questions/143119/how-do-i-add-python-to-the-windows-path/143121#143121)
|
||||
to get help with editing the `PATH` variable manually.
|
||||
|
||||
---
|
||||
|
||||
## I have tried using Chocolatey (`choco install manimce`) to install Manim, but it failed!
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ require no local installation. Head over to
|
|||
https://try.manim.community to give our interactive tutorial a try.
|
||||
|
||||
Otherwise, if you intend to use Manim to work on an animation project,
|
||||
we recommend installing the library locally (either to a conda environment,
|
||||
your system's Python, or via Docker).
|
||||
we recommend installing the library locally (preferably to some isolated
|
||||
virtual Python environment, or a conda-like environment, or via Docker).
|
||||
|
||||
.. warning::
|
||||
|
||||
|
|
@ -19,13 +19,31 @@ your system's Python, or via Docker).
|
|||
versions <different-versions>` if you are unsure which
|
||||
version you should install.
|
||||
|
||||
#. :ref:`(Recommended) Installing Manim via Python's package manager pip
|
||||
<local-installation>`
|
||||
#. :ref:`Installing Manim to a conda environment <conda-installation>`
|
||||
#. :ref:`Installing Manim to your system's Python <local-installation>`
|
||||
#. :ref:`Using Manim via Docker <docker-installation>`
|
||||
#. :ref:`Interactive Jupyter notebooks via Binder / Google Colab
|
||||
<interactive-online>`
|
||||
|
||||
|
||||
.. _local-installation:
|
||||
|
||||
Installing Manim locally via pip
|
||||
********************************
|
||||
|
||||
The recommended way of installing Manim is by using Python's package manager
|
||||
pip. If you already have a Python environment set up, you can simply run
|
||||
``pip install manim`` to install the library.
|
||||
|
||||
Our :doc:`local installation guide <installation/uv>` provides more detailed
|
||||
instructions, including best practices for setting up a suitable local environment.
|
||||
|
||||
.. toctree::
|
||||
:hidden:
|
||||
|
||||
installation/uv
|
||||
|
||||
.. _conda-installation:
|
||||
|
||||
Installing Manim via Conda and related environment managers
|
||||
|
|
@ -55,48 +73,6 @@ The following pages show how to install Manim in a conda environment:
|
|||
installation/conda
|
||||
|
||||
|
||||
|
||||
.. _local-installation:
|
||||
|
||||
Installing Manim locally
|
||||
************************
|
||||
|
||||
Manim is a Python library, and it can be
|
||||
installed via `pip <https://pypi.org/project/manim/>`__
|
||||
or `conda <https://anaconda.org/conda-forge/manim/>`__. However,
|
||||
in order for Manim to work properly, some additional system
|
||||
dependencies need to be installed first. The following pages have
|
||||
operating system specific instructions for you to follow.
|
||||
|
||||
Manim requires Python version ``3.10`` or above to run.
|
||||
|
||||
.. hint::
|
||||
|
||||
Depending on your particular setup, the installation process
|
||||
might be slightly different. Make sure that you have tried to
|
||||
follow the steps on the following pages carefully, but in case
|
||||
you hit a wall we are happy to help: either `join our Discord
|
||||
<https://www.manim.community/discord/>`__, or start a new
|
||||
Discussion `directly on GitHub
|
||||
<https://github.com/ManimCommunity/manim/discussions>`__.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
installation/windows
|
||||
installation/macos
|
||||
installation/linux
|
||||
|
||||
Once Manim is installed locally, you can proceed to our
|
||||
:doc:`quickstart guide <tutorials/quickstart>` which walks you
|
||||
through rendering a first simple scene.
|
||||
|
||||
As mentioned above, do not worry if there are errors or other
|
||||
problems: consult our :doc:`FAQ section </faq/index>` for help
|
||||
(including instructions for how to ask Manim's community for help).
|
||||
|
||||
|
||||
|
||||
.. _docker-installation:
|
||||
|
||||
Using Manim via Docker
|
||||
|
|
@ -140,6 +116,11 @@ If you're using Visual Studio Code you can install an extension called
|
|||
of the animation inside the editor. The extension can be installed through the
|
||||
`marketplace of VS Code <https://marketplace.visualstudio.com/items?itemName=Rickaym.manim-sideview>`__.
|
||||
|
||||
.. caution::
|
||||
|
||||
This extension is not officially maintained by the Manim Community.
|
||||
If you run into issues, please report them to the extension's author.
|
||||
|
||||
|
||||
Installation for developers
|
||||
***************************
|
||||
|
|
|
|||
|
|
@ -10,15 +10,25 @@ namely `conda <https://docs.conda.io/projects/conda/en/latest/user-guide/install
|
|||
|
||||
After installing your package manager, you can create a new environment and install ``manim`` inside by running
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# using conda or mamba
|
||||
conda create -n my-manim-environment
|
||||
conda activate my-manim-environment
|
||||
conda install -c conda-forge manim
|
||||
# using pixi
|
||||
pixi init
|
||||
pixi add manim
|
||||
.. tab-set::
|
||||
|
||||
.. tab-item:: conda / mamba
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# if you want to use mamba, just replace conda below with mamba
|
||||
conda create -n my-manim-environment
|
||||
conda activate my-manim-environment
|
||||
conda install -c conda-forge manim
|
||||
|
||||
.. tab-item:: pixi
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pixi init
|
||||
pixi add manim
|
||||
|
||||
|
||||
Since all dependencies (except LaTeX) are handled by conda, you don't need to worry
|
||||
about needing to install additional dependencies.
|
||||
|
|
@ -32,11 +42,8 @@ In order to make use of Manim's interface to LaTeX to, for example, render
|
|||
equations, LaTeX has to be installed as well. Note that this is an optional
|
||||
dependency: if you don't intend to use LaTeX, you don't have to install it.
|
||||
|
||||
You can install LaTeX by following the optional dependencies steps
|
||||
for :ref:`Windows <win-optional-dependencies>`,
|
||||
:ref:`Linux <linux-optional-dependencies>` or
|
||||
:ref:`macOS <macos-optional-dependencies>`.
|
||||
|
||||
Recommendations on how to install LaTeX on different operating systems
|
||||
can be found :doc:`in our local installation guide </installation/uv>`.
|
||||
|
||||
|
||||
Working with Manim
|
||||
|
|
|
|||
|
|
@ -1,162 +0,0 @@
|
|||
Linux
|
||||
=====
|
||||
|
||||
The installation instructions depend on your particular operating
|
||||
system and package manager. If you happen to know exactly what you are doing,
|
||||
you can also simply ensure that your system has:
|
||||
|
||||
- a reasonably recent version of Python 3 (3.10 or above),
|
||||
- with working Cairo bindings in the form of
|
||||
`pycairo <https://cairographics.org/pycairo/>`__,
|
||||
- and `Pango <https://pango.gnome.org>`__ headers.
|
||||
|
||||
Then, installing Manim is just a matter of running:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pip3 install manim
|
||||
|
||||
.. note::
|
||||
|
||||
In light of the current efforts of migrating to rendering via OpenGL,
|
||||
this list might be incomplete. Please `let us know
|
||||
<https://github.com/ManimCommunity/manim/issues/new/choose>` if you
|
||||
ran into missing dependencies while installing.
|
||||
|
||||
In any case, we have also compiled instructions for several common
|
||||
combinations of operating systems and package managers below.
|
||||
|
||||
Required Dependencies
|
||||
---------------------
|
||||
|
||||
apt – Ubuntu / Mint / Debian
|
||||
****************************
|
||||
|
||||
To first update your sources, and then install Cairo and Pango
|
||||
simply run:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sudo apt update
|
||||
sudo apt install build-essential python3-dev libcairo2-dev libpango1.0-dev
|
||||
|
||||
If you don't have python3-pip installed, install it via:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sudo apt install python3-pip
|
||||
|
||||
Then, to install Manim, run:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pip3 install manim
|
||||
|
||||
Continue by reading the :ref:`optional dependencies <linux-optional-dependencies>`
|
||||
section.
|
||||
|
||||
dnf – Fedora / CentOS / RHEL
|
||||
****************************
|
||||
|
||||
To install Cairo and Pango:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sudo dnf install cairo-devel pango-devel
|
||||
|
||||
In order to successfully build the ``pycairo`` wheel, you will also
|
||||
need the Python development headers:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sudo dnf install python3-devel
|
||||
|
||||
At this point you have all required dependencies and can install
|
||||
Manim by running:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pip3 install manim
|
||||
|
||||
Continue by reading the :ref:`optional dependencies <linux-optional-dependencies>`
|
||||
section.
|
||||
|
||||
pacman – Arch / Manjaro
|
||||
***********************
|
||||
|
||||
.. tip::
|
||||
|
||||
Thanks to *groctel*, there is a `dedicated Manim package
|
||||
on the AUR! <https://aur.archlinux.org/packages/manim/>`
|
||||
|
||||
If you don't want to use the packaged version from AUR, here is what
|
||||
you need to do manually: Update your package sources, then install
|
||||
Cairo and Pango:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sudo pacman -Syu
|
||||
sudo pacman -S cairo pango
|
||||
|
||||
If you don't have ``python-pip`` installed, get it by running:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sudo pacman -S python-pip
|
||||
|
||||
then simply install Manim via:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pip3 install manim
|
||||
|
||||
|
||||
Continue by reading the :ref:`optional dependencies <linux-optional-dependencies>`
|
||||
section.
|
||||
|
||||
|
||||
.. _linux-optional-dependencies:
|
||||
|
||||
Optional Dependencies
|
||||
---------------------
|
||||
|
||||
In order to make use of Manim's interface to LaTeX for, e.g., rendering
|
||||
equations, LaTeX has to be installed as well. Note that this is an optional
|
||||
dependency: if you don't intend to use LaTeX, you don't have to install it.
|
||||
|
||||
You can use whichever LaTeX distribution you like or whichever is easiest
|
||||
to install with your package manager. Usually,
|
||||
`TeX Live <https://www.tug.org/texlive/>`__ is a good candidate if you don't
|
||||
care too much about disk space.
|
||||
|
||||
For Debian-based systems (like Ubuntu), sufficient LaTeX dependencies can be
|
||||
installed by running:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sudo apt install texlive texlive-latex-extra
|
||||
|
||||
For Fedora (see `docs <https://docs.fedoraproject.org/en-US/neurofedora/latex/>`__):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sudo dnf install texlive-scheme-full
|
||||
|
||||
Should you choose to work with some smaller TeX distribution like
|
||||
`TinyTeX <https://yihui.org/tinytex/>`__ , the full list
|
||||
of LaTeX packages which Manim interacts with in some way (a subset might
|
||||
be sufficient for your particular application) is::
|
||||
|
||||
collection-basic amsmath babel-english cbfonts-fd cm-super ctex doublestroke
|
||||
dvisvgm everysel fontspec frcursive fundus-calligra gnu-freefont jknapltx
|
||||
latex-bin mathastext microtype ms physics preview ragged2e relsize rsfs
|
||||
setspace standalone tipa wasy wasysym xcolor xetex xkeyval
|
||||
|
||||
|
||||
|
||||
Working with Manim
|
||||
------------------
|
||||
|
||||
At this point, you should have a working installation of Manim, head
|
||||
over to our :doc:`Quickstart Tutorial <../tutorials/quickstart>` to learn
|
||||
how to make your own *Manimations*!
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
macOS
|
||||
=====
|
||||
|
||||
For the sake of simplicity, the following instructions assume that you have
|
||||
the popular `package manager Homebrew <https://brew.sh>`__ installed. While
|
||||
you can certainly also install all dependencies without it, using Homebrew
|
||||
makes the process much easier.
|
||||
|
||||
If you want to use Homebrew but do not have it installed yet, please
|
||||
follow `Homebrew's installation instructions <https://docs.brew.sh/Installation>`__.
|
||||
|
||||
.. note::
|
||||
|
||||
For a while after Apple released its new ARM-based processors (the Apple Silicon chips like the *"M1 chip"*),
|
||||
the recommended way of installing Manim relied on *Rosetta*, Apple's compatibility
|
||||
layer between Intel and ARM architectures. This is no longer necessary, Manim can
|
||||
(and is recommended to) be installed natively.
|
||||
|
||||
|
||||
Installing Manim
|
||||
----------------
|
||||
|
||||
As of July/2024, brew can install Manim including all required dependencies.
|
||||
To install Manim:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
brew install manim
|
||||
|
||||
.. _macos-optional-dependencies:
|
||||
|
||||
Optional Dependencies
|
||||
---------------------
|
||||
|
||||
In order to make use of Manim's interface to LaTeX for, e.g., rendering
|
||||
equations, LaTeX has to be installed as well. Note that this is an optional
|
||||
dependency: if you don't intend to use LaTeX, you don't have to install it.
|
||||
|
||||
For macOS, the recommended LaTeX distribution is
|
||||
`MacTeX <http://www.tug.org/mactex/>`__. You can install it by following
|
||||
the instructions from the link, or alternatively also via Homebrew by
|
||||
running:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
brew install --cask mactex-no-gui
|
||||
|
||||
.. warning::
|
||||
|
||||
MacTeX is a *full* LaTeX distribution and will require more than 4GB of
|
||||
disk space. If this is an issue for you, consider installing a smaller
|
||||
distribution like
|
||||
`BasicTeX <http://www.tug.org/mactex/morepackages.html>`__.
|
||||
|
||||
Should you choose to work with some partial TeX distribution, the full list
|
||||
of LaTeX packages which Manim interacts with in some way (a subset might
|
||||
be sufficient for your particular application) is::
|
||||
|
||||
amsmath babel-english cbfonts-fd cm-super ctex doublestroke dvisvgm everysel
|
||||
fontspec frcursive fundus-calligra gnu-freefont jknapltx latex-bin
|
||||
mathastext microtype ms physics preview ragged2e relsize rsfs
|
||||
setspace standalone tipa wasy wasysym xcolor xetex xkeyval
|
||||
|
||||
|
||||
Working with Manim
|
||||
------------------
|
||||
|
||||
At this point, you should have a working installation of Manim. Head
|
||||
over to our :doc:`Quickstart Tutorial <../tutorials/quickstart>` to learn
|
||||
how to make your own *Manimations*!
|
||||
284
docs/source/installation/uv.md
Normal file
284
docs/source/installation/uv.md
Normal file
|
|
@ -0,0 +1,284 @@
|
|||
# Installing Manim locally
|
||||
|
||||
The standard way of installing Manim is by using
|
||||
Python's package manager `pip` to install the latest
|
||||
release from [PyPI](https://pypi.org/project/manim/).
|
||||
|
||||
To make it easier for you to follow best practices when it
|
||||
comes to setting up a Python project for your Manim animations,
|
||||
we strongly recommend using a tool for managing Python environments
|
||||
and dependencies. In particular,
|
||||
[we strongly recommend using `uv`](https://docs.astral.sh/uv/#getting-started).
|
||||
|
||||
For the two main ways of installing Manim described below, we assume
|
||||
that `uv` is available; we think it is particularly helpful if you are
|
||||
new to Python or programming in general. It is not a hard requirement
|
||||
whatsoever; if you know what you are doing you can just use `pip` to
|
||||
install Manim directly.
|
||||
|
||||
:::::{admonition} Installing the Python management tool `uv`
|
||||
:class: seealso
|
||||
|
||||
One way to install `uv` is via the dedicated console installer supporting
|
||||
all large operating systems. Simply paste the following snippet into
|
||||
your terminal / PowerShell -- or
|
||||
[consult `uv`'s documentation](https://docs.astral.sh/uv/#getting-started)
|
||||
for alternative ways to install the tool.
|
||||
|
||||
::::{tab-set}
|
||||
:::{tab-item} MacOS and Linux
|
||||
```bash
|
||||
curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||
```
|
||||
:::
|
||||
:::{tab-item} Windows
|
||||
```powershell
|
||||
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
|
||||
```
|
||||
:::
|
||||
::::
|
||||
|
||||
:::::
|
||||
|
||||
Of course, if you know what you are doing and prefer to setup a virtual
|
||||
environment yourself, feel free to do so!
|
||||
|
||||
:::{important}
|
||||
If you run into issues when following our instructions below, do
|
||||
not worry: check our [installation FAQs](<project:/faq/installation.md>) to
|
||||
see whether the problem is already addressed there -- and otherwise go and
|
||||
check [how to contact our community](<project:/faq/help.md>) to get help.
|
||||
:::
|
||||
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
### Step 1: Installing Python
|
||||
|
||||
We first need to check that an appropriate version of Python is available
|
||||
on your machine. Open a terminal to run
|
||||
```bash
|
||||
uv python install
|
||||
```
|
||||
to install the latest version of Python. If this is successful, continue
|
||||
to the next step.
|
||||
|
||||
(installation-optional-latex)=
|
||||
### Step 2 (optional): Installing LaTeX
|
||||
|
||||
[LaTeX](https://en.wikibooks.org/wiki/LaTeX/Mathematics) is a very well-known
|
||||
and widely used typesetting system allowing you to write formulas like
|
||||
|
||||
\begin{equation*}
|
||||
\frac{1}{2\pi i} \oint_{\gamma} \frac{f(z)}{(z - z_0)^{n+1}}~dz
|
||||
= \frac{f^{(n)}(z_0)}{n!}.
|
||||
\end{equation*}
|
||||
|
||||
If rendering plain text is sufficient for your needs and you don't want
|
||||
to render any typeset formulas, you can technically skip this step. Otherwise
|
||||
select your operating system from the tab list below and follow the instructions.
|
||||
|
||||
:::::{tab-set}
|
||||
|
||||
::::{tab-item} Windows
|
||||
For Windows we recommend installing LaTeX via the
|
||||
[MiKTeX distribution](https://miktex.org). Simply grab
|
||||
the Windows installer available from their download page,
|
||||
<https://miktex.org/download> and run it.
|
||||
::::
|
||||
|
||||
::::{tab-item} MacOS
|
||||
If you are running MacOS, we recommend installing the
|
||||
[MacTeX distribution](https://www.tug.org/mactex/). The latest
|
||||
available PKG file can be downloaded from
|
||||
<https://www.tug.org/mactex/mactex-download.html>.
|
||||
Get it and follow the standard installation procedure.
|
||||
::::
|
||||
|
||||
::::{tab-item} Linux
|
||||
Given the large number of Linux distributions with different ways
|
||||
of installing packages, we cannot give detailed instructions for
|
||||
all package managers.
|
||||
|
||||
In general we recommend to install a *TeX Live* distribution
|
||||
(<https://www.tug.org/texlive/>). For most Linux distributions,
|
||||
TeX Live has already been packaged such that it can be installed
|
||||
easily with your system package manager. Search the internet and
|
||||
your usual OS resources for detailed instructions.
|
||||
|
||||
For example, on Debian-based systems with the package manager `apt`,
|
||||
a full TeX Live distribution can be installed by running
|
||||
```bash
|
||||
sudo apt install texlive-full
|
||||
```
|
||||
For Fedora (managed via `dnf`), the corresponding command is
|
||||
```bash
|
||||
sudo dnf install texlive-scheme-full
|
||||
```
|
||||
As soon as LaTeX is installed, continue with actually installing Manim
|
||||
itself.
|
||||
|
||||
::::
|
||||
|
||||
:::::
|
||||
|
||||
:::{dropdown} I know what I am doing and I would like to setup a minimal LaTeX installation
|
||||
You are welcome to use a smaller, more customizable LaTeX distribution like
|
||||
[TinyTeX](https://yihui.org/tinytex/). Manim overall requires the following
|
||||
LaTeX packages to be installed in your distribution:
|
||||
```text
|
||||
amsmath babel-english cbfonts-fd cm-super count1to ctex doublestroke dvisvgm everysel
|
||||
fontspec frcursive fundus-calligra gnu-freefont jknapltx latex-bin
|
||||
mathastext microtype multitoc physics preview prelim2e ragged2e relsize rsfs
|
||||
setspace standalone tipa wasy wasysym xcolor xetex xkeyval
|
||||
```
|
||||
:::
|
||||
|
||||
### Step 3: Installing Manim
|
||||
|
||||
These steps again differ slightly between different operating systems. Make
|
||||
sure you select the correct one from the tab list below, then follow
|
||||
the instructions below.
|
||||
|
||||
::::::{tab-set}
|
||||
|
||||
:::::{tab-item} MacOS & Windows
|
||||
The following commands will
|
||||
|
||||
- create a new directory for a Python project,
|
||||
- and add Manim as a dependency, which installs it into the corresponding
|
||||
local Python environment.
|
||||
|
||||
The name for the Python project is *manimations*, which you can change
|
||||
to anything you like.
|
||||
|
||||
```bash
|
||||
uv init manimations
|
||||
cd manimations
|
||||
uv add manim
|
||||
```
|
||||
|
||||
Manim is now installed in your local project environment!
|
||||
|
||||
:::::
|
||||
|
||||
:::::{tab-item} Linux
|
||||
Practically, the instructions given in the *MacOS & Windows* tab
|
||||
also apply for Linux -- however, some additional dependencies are
|
||||
required as Linux users need to build
|
||||
[ManimPango](https://github.com/ManimCommunity/ManimPango)
|
||||
(and potentially [pycairo](https://pycairo.readthedocs.io/en/latest/))
|
||||
from source. More specifically, this includes:
|
||||
|
||||
- A C compiler,
|
||||
- Python's development headers,
|
||||
- the `pkg-config` tool,
|
||||
- Pango and its development headers,
|
||||
- and Cairo and its development headers.
|
||||
|
||||
Instructions for popular systems / package managers are given below.
|
||||
|
||||
::::{tab-set}
|
||||
|
||||
:::{tab-item} Debian-based / apt
|
||||
```bash
|
||||
sudo apt update
|
||||
sudo apt install build-essential python3-dev libcairo2-dev libpango1.0-dev
|
||||
```
|
||||
:::
|
||||
|
||||
:::{tab-item} Fedora / dnf
|
||||
```bash
|
||||
sudo dnf install python3-devel pkg-config cairo-devel pango-devel
|
||||
```
|
||||
:::
|
||||
|
||||
:::{tab-item} Arch Linux / pacman
|
||||
```bash
|
||||
sudo pacman -Syu base-devel cairo pango
|
||||
```
|
||||
:::
|
||||
|
||||
::::
|
||||
|
||||
As soon as the required dependencies are installed, you can create
|
||||
a Python project (feel free to change the name *manimations* used below
|
||||
to some other name) with a local environment containing Manim by running
|
||||
```bash
|
||||
uv init manimations
|
||||
cd manimations
|
||||
uv add manim
|
||||
```
|
||||
|
||||
:::::
|
||||
|
||||
::::::
|
||||
|
||||
To verify that your local Python project is setup correctly
|
||||
and that Manim is available, simply run
|
||||
```bash
|
||||
uv run manim checkhealth
|
||||
```
|
||||
|
||||
At this point, you can also open your project folder with the
|
||||
IDE of your choice. All modern Python IDEs (for example VS Code
|
||||
with the Python extension, or PyCharm) should automatically detect
|
||||
the local environment created by `uv` such that if you put
|
||||
```py
|
||||
import manim
|
||||
```
|
||||
into a new file `my-first-animation.py`, the import is resolved
|
||||
correctly and autocompletion is available.
|
||||
|
||||
*Happy Manimating!*
|
||||
|
||||
|
||||
:::{dropdown} Alternative: Installing Manim as a global `uv`-managed tool
|
||||
If you have Manim projects in many different directories and you do not
|
||||
want to setup a local project environment for each of them, you could
|
||||
also install Manim as a `uv`-managed tool.
|
||||
|
||||
See [`uv`'s documentation for more information](https://docs.astral.sh/uv/concepts/tools/)
|
||||
on their tool mechanism.
|
||||
|
||||
To install Manim as a global `uv` tool, simply run
|
||||
```bash
|
||||
uv tool install manim
|
||||
```
|
||||
after which the `manim` executable will be available on your
|
||||
global system path, without the need to activate any virtual
|
||||
environment or prefixing your commands with `uv run`.
|
||||
|
||||
Note that when using this approach, setting up your code editor
|
||||
to properly resolve `import manim` requires additional work, as
|
||||
the global tool environment is not automatically detected: the
|
||||
base path of all tool environments can be determined by running
|
||||
```
|
||||
uv tool dir
|
||||
```
|
||||
which should now contain a directory `manim` in which the appropriate
|
||||
virtual environment is located. Set the Python interpreter of your IDE
|
||||
to this environment to make imports properly resolve themselves.
|
||||
:::
|
||||
|
||||
:::{dropdown} Installing Manim for a different version of Python
|
||||
In case you would like to use a different version of Python
|
||||
(for example, due to compatibility issues with other packages),
|
||||
then `uv` allows you to do so in a fairly straightforward way.
|
||||
|
||||
When initializing the local Python project, simply pass the Python
|
||||
version you want to use as an argument to the `init` command:
|
||||
```
|
||||
uv init --python 3.12 manimations
|
||||
cd manimations
|
||||
uv add manim
|
||||
```
|
||||
To change the version for an existing package, you will need to
|
||||
edit the `pyproject.toml` file. If you are downgrading the python version, the
|
||||
`requires-python` entry needs to be updated such that your chosen
|
||||
version satisfies the requirement. Change the line to, for example
|
||||
`requires-python = ">=3.12"`. After that, run `uv python pin 3.12`
|
||||
to pin the python version to `3.12`. Finally, run `uv sync`, and your
|
||||
environment is updated!
|
||||
:::
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
Windows
|
||||
=======
|
||||
|
||||
The easiest way of installing Manim and its dependencies is by using a
|
||||
package manager like `Chocolatey <https://chocolatey.org/>`__
|
||||
or `Scoop <https://scoop.sh>`__, especially if you need optional dependencies
|
||||
like LaTeX support.
|
||||
|
||||
If you choose to use one of the package managers, please follow
|
||||
their installation instructions
|
||||
(`for Chocolatey <https://chocolatey.org/install#install-step2>`__,
|
||||
`for Scoop <https://scoop-docs.now.sh/docs/getting-started/Quick-Start.html>`__)
|
||||
to make one of them available on your system.
|
||||
|
||||
|
||||
Required Dependencies
|
||||
---------------------
|
||||
|
||||
Manim requires a recent version of Python (3.10 or above)
|
||||
in order to work.
|
||||
|
||||
Chocolatey
|
||||
**********
|
||||
|
||||
Manim can be installed via Chocolatey simply by running:
|
||||
|
||||
.. code-block:: powershell
|
||||
|
||||
choco install manimce
|
||||
|
||||
That's it, no further steps required. You can continue with installing
|
||||
the :ref:`optional dependencies <win-optional-dependencies>` below.
|
||||
|
||||
Pip
|
||||
***
|
||||
|
||||
As mentioned above, Manim needs a reasonably recent version of
|
||||
Python 3 (3.10 or above).
|
||||
|
||||
**Python:** Head over to https://www.python.org, download an installer
|
||||
for a recent version of Python, and follow its instructions to get Python
|
||||
installed on your system.
|
||||
|
||||
.. note::
|
||||
|
||||
We have received reports of problems caused by using the version of
|
||||
Python that can be installed from the Windows Store. At this point,
|
||||
we recommend staying away from the Windows Store version. Instead,
|
||||
install Python directly from the
|
||||
`official website <https://www.python.org>`__.
|
||||
|
||||
Then, Manim can be installed via Pip simply by running:
|
||||
|
||||
.. code-block:: powershell
|
||||
|
||||
python -m pip install manim
|
||||
|
||||
Manim should now be installed on your system. Continue reading
|
||||
the :ref:`optional dependencies <win-optional-dependencies>` section
|
||||
below.
|
||||
|
||||
|
||||
.. _win-optional-dependencies:
|
||||
|
||||
Optional Dependencies
|
||||
---------------------
|
||||
|
||||
In order to make use of Manim's interface to LaTeX to, for example, render
|
||||
equations, LaTeX has to be installed as well. Note that this is an optional
|
||||
dependency: if you don't intend to use LaTeX, you don't have to install it.
|
||||
|
||||
For Windows, the recommended LaTeX distribution is
|
||||
`MiKTeX <https://miktex.org/download>`__. You can install it by using the
|
||||
installer from the linked MiKTeX site, or by using the package manager
|
||||
of your choice (Chocolatey: ``choco install miktex.install``,
|
||||
Scoop: ``scoop install latex``, Winget: ``winget install MiKTeX.MiKTeX``).
|
||||
|
||||
If you are concerned about disk space, there are some alternative,
|
||||
smaller distributions of LaTeX.
|
||||
|
||||
**Using Chocolatey:** If you used Chocolatey to install manim or are already
|
||||
a chocolatey user, then you can simply run ``choco install manim-latex``. It
|
||||
is a dedicated package for Manim based on TinyTeX which contains all the
|
||||
required packages that Manim interacts with.
|
||||
|
||||
**Manual Installation:**
|
||||
You can also use `TinyTeX <https://yihui.org/tinytex/>`__ (Chocolatey: ``choco install tinytex``,
|
||||
Scoop: first ``scoop bucket add r-bucket https://github.com/cderv/r-bucket.git``,
|
||||
then ``scoop install tinytex``) alternative installation instructions can be found at their website.
|
||||
Keep in mind that you will have to manage the LaTeX packages installed on your system yourself via ``tlmgr``.
|
||||
Therefore we only recommend this option if you know what you are doing.
|
||||
|
||||
The full list of LaTeX packages which Manim interacts with in some way
|
||||
(a subset might be sufficient for your particular application) are::
|
||||
|
||||
amsmath babel-english cbfonts-fd cm-super ctex doublestroke dvisvgm everysel
|
||||
fontspec frcursive fundus-calligra gnu-freefont jknapltx latex-bin
|
||||
mathastext microtype ms physics preview ragged2e relsize rsfs
|
||||
setspace standalone tipa wasy wasysym xcolor xetex xkeyval
|
||||
|
||||
|
||||
|
||||
Working with Manim
|
||||
------------------
|
||||
|
||||
At this point, you should have a working installation of Manim, head
|
||||
over to our :doc:`Quickstart Tutorial <../tutorials/quickstart>` to learn
|
||||
how to make your own *Manimations*!
|
||||
|
|
@ -3,12 +3,22 @@ Quickstart
|
|||
==========
|
||||
|
||||
.. note::
|
||||
Before proceeding, install Manim and make sure it's running properly by
|
||||
following the steps in :doc:`../installation`. For
|
||||
information on using Manim with Jupyterlab or Jupyter notebook, go to the
|
||||
documentation for the
|
||||
:meth:`IPython magic command <manim.utils.ipython_magic.ManimMagic.manim>`,
|
||||
``%%manim``.
|
||||
|
||||
Before proceeding, install Manim and make sure it is running properly by
|
||||
following the steps in :doc:`../installation`. For
|
||||
information on using Manim with Jupyterlab or Jupyter notebook, go to the
|
||||
documentation for the
|
||||
:meth:`IPython magic command <manim.utils.ipython_magic.ManimMagic.manim>`,
|
||||
``%%manim``.
|
||||
|
||||
|
||||
.. important::
|
||||
|
||||
If you installed Manim in the recommended way, using the
|
||||
Python management tool ``uv``, then you either need to make sure the corresponding
|
||||
virtual environment is activated (follow the instructions printed on running ``uv venv``),
|
||||
or you need to remember to prefix the ``manim`` command in the console with ``uv run``;
|
||||
that is, ``uv run manim ...``.
|
||||
|
||||
Overview
|
||||
********
|
||||
|
|
@ -28,45 +38,38 @@ use to modify ``Mobject``\s.
|
|||
Starting a new project
|
||||
**********************
|
||||
|
||||
Start by creating a new folder. For the purposes of this guide, name the folder ``project``:
|
||||
Start by creating a new folder::
|
||||
|
||||
.. code-block:: bash
|
||||
manim init project my-project --default
|
||||
|
||||
project/
|
||||
|
||||
This folder is the root folder for your project. It contains all the files that Manim needs to function,
|
||||
The ``my-project`` folder is the root folder for your project. It contains all the files that Manim needs to function,
|
||||
as well as any output that your project produces.
|
||||
|
||||
|
||||
Animating a circle
|
||||
******************
|
||||
|
||||
1. Open a text editor, such as Notepad. Copy the following code snippet into the window:
|
||||
1. Open a text editor, such as Notepad. Open the file ``main.py`` in the ``my-project`` folder.
|
||||
It should look something like this:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python
|
||||
|
||||
from manim import *
|
||||
from manim import *
|
||||
|
||||
|
||||
class CreateCircle(Scene):
|
||||
def construct(self):
|
||||
circle = Circle() # create a circle
|
||||
circle.set_fill(PINK, opacity=0.5) # set the color and transparency
|
||||
self.play(Create(circle)) # show the circle on screen
|
||||
class CreateCircle(Scene):
|
||||
def construct(self):
|
||||
circle = Circle() # create a circle
|
||||
circle.set_fill(PINK, opacity=0.5) # set the color and transparency
|
||||
self.play(Create(circle)) # show the circle on screen
|
||||
|
||||
2. Save the code snippet into your project folder with the name ``scene.py``.
|
||||
|
||||
.. code-block:: bash
|
||||
2. Open the command line, navigate to your project folder, and execute
|
||||
the following command:
|
||||
|
||||
project/
|
||||
└─scene.py
|
||||
.. code-block:: bash
|
||||
|
||||
3. Open the command line, navigate to your project folder, and execute
|
||||
the following command:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
manim -pql scene.py CreateCircle
|
||||
manim -pql main.py CreateCircle
|
||||
|
||||
Manim will output rendering information, then create an MP4 file.
|
||||
Your default movie player will play the MP4 file, displaying the following animation.
|
||||
|
|
|
|||
|
|
@ -116,7 +116,9 @@ def always_redraw(func: Callable[[], M]) -> M:
|
|||
|
||||
|
||||
def turn_animation_into_updater(
|
||||
animation: MobjectAnimation[M], cycle: bool = False
|
||||
animation: MobjectAnimation[M],
|
||||
cycle: bool = False,
|
||||
delay: float = 0,
|
||||
) -> M:
|
||||
"""
|
||||
Add an updater to the animation's mobject which applies
|
||||
|
|
@ -125,6 +127,8 @@ def turn_animation_into_updater(
|
|||
If cycle is True, this repeats over and over. Otherwise,
|
||||
the updater will be popped upon completion
|
||||
|
||||
The ``delay`` parameter is the delay (in seconds) before the animation starts..
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
|
|
@ -144,25 +148,27 @@ def turn_animation_into_updater(
|
|||
mobject = animation.mobject
|
||||
animation.suspend_mobject_updating = False
|
||||
animation.begin()
|
||||
total_time = 0
|
||||
|
||||
def update(m: OpenGLMobject, dt: float):
|
||||
total_time = -delay
|
||||
|
||||
def update(m: M, dt: float):
|
||||
nonlocal total_time
|
||||
run_time = animation.get_run_time()
|
||||
time_ratio = total_time / run_time
|
||||
if cycle:
|
||||
alpha = time_ratio % 1
|
||||
else:
|
||||
alpha = np.clip(time_ratio, 0, 1)
|
||||
if alpha >= 1:
|
||||
animation.finish()
|
||||
m.remove_updater(update)
|
||||
return
|
||||
animation.interpolate(alpha)
|
||||
animation.update_mobjects(dt)
|
||||
if total_time >= 0:
|
||||
run_time = animation.get_run_time()
|
||||
time_ratio = total_time / run_time
|
||||
if cycle:
|
||||
alpha = time_ratio % 1
|
||||
else:
|
||||
alpha = np.clip(time_ratio, 0, 1)
|
||||
if alpha >= 1:
|
||||
animation.finish()
|
||||
m.remove_updater(update) # type: ignore
|
||||
return
|
||||
animation.interpolate(alpha)
|
||||
animation.update_mobjects(dt)
|
||||
total_time += dt
|
||||
|
||||
mobject.add_updater(update)
|
||||
mobject.add_updater(update) # type: ignore
|
||||
return mobject
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ class ArrowTip(VMobject, metaclass=ConvertToOpenGL):
|
|||
|
||||
>>> from manim import Arrow
|
||||
>>> arrow = Arrow(np.array([0, 0, 0]), np.array([1, 1, 0]), buff=0)
|
||||
>>> round(arrow.tip.tip_angle, 5) == round(PI/4, 5)
|
||||
>>> bool(round(arrow.tip.tip_angle, 5) == round(PI/4, 5))
|
||||
True
|
||||
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -403,9 +403,9 @@ class NumberLine(Line):
|
|||
>>> from manim import NumberLine
|
||||
>>> number_line = NumberLine()
|
||||
>>> number_line.point_to_number((0, 0, 0))
|
||||
0.0
|
||||
np.float64(0.0)
|
||||
>>> number_line.point_to_number((1, 0, 0))
|
||||
1.0
|
||||
np.float64(1.0)
|
||||
>>> number_line.point_to_number([[0.5, 0, 0], [1, 0, 0], [1.5, 0, 0]])
|
||||
array([0.5, 1. , 1.5])
|
||||
|
||||
|
|
|
|||
|
|
@ -1604,13 +1604,13 @@ class Mobject:
|
|||
>>> from manim import *
|
||||
>>> sq = Square()
|
||||
>>> sq.height
|
||||
2.0
|
||||
np.float64(2.0)
|
||||
>>> sq.scale_to_fit_width(5)
|
||||
Square
|
||||
>>> sq.width
|
||||
5.0
|
||||
np.float64(5.0)
|
||||
>>> sq.height
|
||||
5.0
|
||||
np.float64(5.0)
|
||||
"""
|
||||
return self.rescale_to_fit(width, 0, stretch=False, **kwargs)
|
||||
|
||||
|
|
@ -1629,13 +1629,13 @@ class Mobject:
|
|||
>>> from manim import *
|
||||
>>> sq = Square()
|
||||
>>> sq.height
|
||||
2.0
|
||||
np.float64(2.0)
|
||||
>>> sq.stretch_to_fit_width(5)
|
||||
Square
|
||||
>>> sq.width
|
||||
5.0
|
||||
np.float64(5.0)
|
||||
>>> sq.height
|
||||
2.0
|
||||
np.float64(2.0)
|
||||
"""
|
||||
return self.rescale_to_fit(width, 0, stretch=True, **kwargs)
|
||||
|
||||
|
|
@ -1654,13 +1654,13 @@ class Mobject:
|
|||
>>> from manim import *
|
||||
>>> sq = Square()
|
||||
>>> sq.width
|
||||
2.0
|
||||
np.float64(2.0)
|
||||
>>> sq.scale_to_fit_height(5)
|
||||
Square
|
||||
>>> sq.height
|
||||
5.0
|
||||
np.float64(5.0)
|
||||
>>> sq.width
|
||||
5.0
|
||||
np.float64(5.0)
|
||||
"""
|
||||
return self.rescale_to_fit(height, 1, stretch=False, **kwargs)
|
||||
|
||||
|
|
@ -1679,13 +1679,13 @@ class Mobject:
|
|||
>>> from manim import *
|
||||
>>> sq = Square()
|
||||
>>> sq.width
|
||||
2.0
|
||||
np.float64(2.0)
|
||||
>>> sq.stretch_to_fit_height(5)
|
||||
Square
|
||||
>>> sq.height
|
||||
5.0
|
||||
np.float64(5.0)
|
||||
>>> sq.width
|
||||
2.0
|
||||
np.float64(2.0)
|
||||
"""
|
||||
return self.rescale_to_fit(height, 1, stretch=True, **kwargs)
|
||||
|
||||
|
|
@ -2868,7 +2868,7 @@ class Mobject:
|
|||
|
||||
>>> result = rect.copy().become(circ, stretch=True)
|
||||
>>> result.height, result.width
|
||||
(2.0, 4.0)
|
||||
(np.float64(2.0), np.float64(4.0))
|
||||
>>> ellipse_points = np.array(result.get_anchors())
|
||||
>>> ellipse_eq = np.sum(ellipse_points**2 * [1/4, 1, 0], axis=1)
|
||||
>>> np.allclose(ellipse_eq, 1)
|
||||
|
|
@ -2882,14 +2882,14 @@ class Mobject:
|
|||
|
||||
>>> result = rect.copy().become(circ, match_height=True)
|
||||
>>> result.height, result.width
|
||||
(2.0, 2.0)
|
||||
(np.float64(2.0), np.float64(2.0))
|
||||
>>> circle_points = np.array(result.get_anchors())
|
||||
>>> circle_eq = np.sum(circle_points**2, axis=1)
|
||||
>>> np.allclose(circle_eq, 1)
|
||||
True
|
||||
>>> result = rect.copy().become(circ, match_width=True)
|
||||
>>> result.height, result.width
|
||||
(4.0, 4.0)
|
||||
(np.float64(4.0), np.float64(4.0))
|
||||
>>> circle_points = np.array(result.get_anchors())
|
||||
>>> circle_eq = np.sum(circle_points**2, axis=1)
|
||||
>>> np.allclose(circle_eq, 2**2)
|
||||
|
|
|
|||
|
|
@ -1160,7 +1160,7 @@ def inverse_interpolate(
|
|||
.. code-block:: pycon
|
||||
|
||||
>>> inverse_interpolate(start=2, end=6, value=4)
|
||||
0.5
|
||||
np.float64(0.5)
|
||||
|
||||
>>> start = np.array([1, 2, 1])
|
||||
>>> end = np.array([7, 8, 11])
|
||||
|
|
@ -1222,7 +1222,7 @@ def match_interpolate(
|
|||
Examples
|
||||
--------
|
||||
>>> match_interpolate(0, 100, 10, 20, 15)
|
||||
50.0
|
||||
np.float64(50.0)
|
||||
"""
|
||||
old_alpha = inverse_interpolate(old_start, old_end, old_value)
|
||||
return interpolate(
|
||||
|
|
@ -1968,7 +1968,7 @@ def is_closed(points: Point3D_Array) -> bool:
|
|||
return False
|
||||
if abs(end[1] - start[1]) > tolerance[1]:
|
||||
return False
|
||||
return abs(end[2] - start[2]) <= tolerance[2]
|
||||
return bool(abs(end[2] - start[2]) <= tolerance[2])
|
||||
|
||||
|
||||
def proportions_along_bezier_curve_for_point(
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import ast
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from typing_extensions import TypeAlias
|
||||
|
|
@ -158,27 +159,35 @@ def parse_module_attributes() -> tuple[AliasDocsDict, DataDict, TypeVarDict]:
|
|||
inner_nodes = [node]
|
||||
|
||||
for node in inner_nodes:
|
||||
# If we encounter an assignment annotated as "TypeAlias":
|
||||
if (
|
||||
# Check if this node is a TypeAlias (type <name> = <value>)
|
||||
# or an AnnAssign annotated as TypeAlias (<target>: TypeAlias = <value>).
|
||||
is_type_alias = (
|
||||
sys.version_info >= (3, 12) and type(node) is ast.TypeAlias
|
||||
)
|
||||
is_annotated_assignment_with_value = (
|
||||
type(node) is ast.AnnAssign
|
||||
and type(node.annotation) is ast.Name
|
||||
and node.annotation.id == "TypeAlias"
|
||||
and type(node.target) is ast.Name
|
||||
and node.value is not None
|
||||
):
|
||||
alias_name = node.target.id
|
||||
def_node = node.value
|
||||
# If it's an Union, replace it with vertical bar notation
|
||||
)
|
||||
if is_type_alias or is_annotated_assignment_with_value:
|
||||
alias_name = node.name.id if is_type_alias else node.target.id
|
||||
definition_node = node.value
|
||||
|
||||
# If the definition is a Union, replace with vertical bar notation.
|
||||
# Instead of "Union[Type1, Type2]", we'll have "Type1 | Type2".
|
||||
if (
|
||||
type(def_node) is ast.Subscript
|
||||
and type(def_node.value) is ast.Name
|
||||
and def_node.value.id == "Union"
|
||||
type(definition_node) is ast.Subscript
|
||||
and type(definition_node.value) is ast.Name
|
||||
and definition_node.value.id == "Union"
|
||||
):
|
||||
union_elements = definition_node.slice.elts
|
||||
definition = " | ".join(
|
||||
ast.unparse(elem) for elem in def_node.slice.elts
|
||||
ast.unparse(elem) for elem in union_elements
|
||||
)
|
||||
else:
|
||||
definition = ast.unparse(def_node)
|
||||
definition = ast.unparse(definition_node)
|
||||
|
||||
definition = definition.replace("npt.", "")
|
||||
if category_dict is None:
|
||||
|
|
@ -188,7 +197,7 @@ def parse_module_attributes() -> tuple[AliasDocsDict, DataDict, TypeVarDict]:
|
|||
alias_info = category_dict[alias_name]
|
||||
continue
|
||||
|
||||
# Check if it is a typing.TypeVar
|
||||
# Check if it is a typing.TypeVar (<target> = TypeVar(...)).
|
||||
elif (
|
||||
type(node) is ast.Assign
|
||||
and type(node.targets[0]) is ast.Name
|
||||
|
|
|
|||
|
|
@ -40,10 +40,10 @@ def binary_search(
|
|||
::
|
||||
|
||||
>>> solution = binary_search(lambda x: x**2 + 3*x + 1, 11, 0, 5)
|
||||
>>> abs(solution - 2) < 1e-4
|
||||
>>> bool(abs(solution - 2) < 1e-4)
|
||||
True
|
||||
>>> solution = binary_search(lambda x: x**2 + 3*x + 1, 11, 0, 5, tolerance=0.01)
|
||||
>>> abs(solution - 2) < 0.01
|
||||
>>> bool(abs(solution - 2) < 0.01)
|
||||
True
|
||||
|
||||
Searching in the interval :math:`[0, 5]` for a target value of :math:`71`
|
||||
|
|
|
|||
|
|
@ -632,11 +632,11 @@ def get_winding_number(points: Sequence[np.ndarray]) -> float:
|
|||
>>> from manim import Square, get_winding_number
|
||||
>>> polygon = Square()
|
||||
>>> get_winding_number(polygon.get_vertices())
|
||||
1.0
|
||||
np.float64(1.0)
|
||||
>>> polygon.shift(2 * UP)
|
||||
Square
|
||||
>>> get_winding_number(polygon.get_vertices())
|
||||
0.0
|
||||
np.float64(0.0)
|
||||
"""
|
||||
total_angle = 0
|
||||
for p1, p2 in adjacent_pairs(points):
|
||||
|
|
@ -699,7 +699,7 @@ def cross2d(
|
|||
.. code-block:: pycon
|
||||
|
||||
>>> cross2d(np.array([1, 2]), np.array([3, 4]))
|
||||
-2
|
||||
np.int64(-2)
|
||||
>>> cross2d(
|
||||
... np.array([[1, 2, 0], [1, 0, 0]]),
|
||||
... np.array([[3, 4, 0], [0, 1, 0]]),
|
||||
|
|
|
|||
3331
poetry.lock
generated
3331
poetry.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -17,6 +17,7 @@ classifiers= [
|
|||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
"Programming Language :: Python :: 3.13",
|
||||
"Natural Language :: English",
|
||||
]
|
||||
exclude = ["scripts/","logo/","readme-assets/"]
|
||||
|
|
@ -25,8 +26,8 @@ packages = [
|
|||
]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.10,<3.13"
|
||||
av = ">=9.0.0"
|
||||
python = ">=3.10"
|
||||
av = ">=9.0.0,<14.0.0" # v14.0.0 contains breaking changes, remove after dropping python 3.9
|
||||
click = ">=8.0"
|
||||
cloup = ">=2.0.0"
|
||||
dearpygui = { version = ">=1.0.0", optional = true }
|
||||
|
|
@ -41,14 +42,26 @@ moderngl = ">=5.0.0,<6.0.0"
|
|||
moderngl-window = ">=2.0.0"
|
||||
networkx = ">=2.6"
|
||||
notebook = { version = ">=6.0.0", optional = true }
|
||||
numpy = ">=1.26"
|
||||
numpy = [
|
||||
# numpy 2.1 is the first version with prebuilt wheels for 3.13,
|
||||
# while numpy 2.0 is the last version supporting 3.9
|
||||
# TODO: remove when python 3.10 is the minimum supported version
|
||||
{version = ">=2.1", python = ">=3.10"},
|
||||
{version = ">=2.0", python = "<3.10"},
|
||||
]
|
||||
Pillow = ">=9.1"
|
||||
pyopengl = "^3.1.6"
|
||||
pydub = ">=0.20.0"
|
||||
audioop-lts = { version = ">=0.2.0", python = ">=3.13" } # for pydub
|
||||
Pygments = ">=2.0.0"
|
||||
rich = ">=12.0.0"
|
||||
screeninfo = "^0.8"
|
||||
scipy = ">=1.6.0"
|
||||
scipy = [
|
||||
# scipy 1.14.0 is the first version with prebuilt wheels for 3.13
|
||||
# TODO: remove when python 3.10 is the minimum supported version
|
||||
{version = ">=1.13.0", python = "<3.13"},
|
||||
{version = ">=1.14.0", python = ">=3.13"},
|
||||
]
|
||||
screeninfo = ">=0.7"
|
||||
skia-pathops = ">=0.7.0"
|
||||
srt = ">=3.0.0"
|
||||
svgelements = ">=1.8.0"
|
||||
|
|
@ -70,7 +83,7 @@ myst-parser = "^2.0.0"
|
|||
pre-commit = "^3.5.0"
|
||||
psutil = {version = "^5.8.0", python = "<3.10"}
|
||||
psutil-wheels = {version = "5.8.0", python = ">=3.10"}
|
||||
pytest = "^7.4.3"
|
||||
pytest = "^8.3"
|
||||
pygithub = "^2.1.1"
|
||||
pytest-cov = "^4.1.0"
|
||||
pytest-xdist = "^2.2" # Using latest gives flaky tests
|
||||
|
|
@ -82,6 +95,8 @@ sphinxext-opengraph = "^0.9.1"
|
|||
types-decorator = "^0.1.7"
|
||||
types-Pillow = "^10.1.0.2"
|
||||
types-Pygments = "^2.17.0.0"
|
||||
sphinx-design = "^0.6.1"
|
||||
sphinx-reredirects = "^0.1.5"
|
||||
|
||||
[tool.poetry.urls]
|
||||
"Bug Tracker" = "https://github.com/ManimCommunity/manim/issues"
|
||||
|
|
|
|||
|
|
@ -4,11 +4,31 @@ import logging
|
|||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import cairo
|
||||
import moderngl
|
||||
import pytest
|
||||
|
||||
import manim
|
||||
|
||||
|
||||
def pytest_report_header(config):
|
||||
try:
|
||||
ctx = moderngl.create_standalone_context()
|
||||
info = ctx.info
|
||||
ctx.release()
|
||||
except Exception as e:
|
||||
raise Exception("Error while creating moderngl context") from e
|
||||
|
||||
return (
|
||||
f"\nCairo Version: {cairo.cairo_version()}",
|
||||
"\nOpenGL information",
|
||||
"------------------",
|
||||
f"vendor: {info['GL_VENDOR'].strip()}",
|
||||
f"renderer: {info['GL_RENDERER'].strip()}",
|
||||
f"version: {info['GL_VERSION'].strip()}\n",
|
||||
)
|
||||
|
||||
|
||||
def pytest_addoption(parser):
|
||||
parser.addoption(
|
||||
"--skip_slow",
|
||||
|
|
@ -46,6 +66,17 @@ def pytest_collection_modifyitems(config, items):
|
|||
item.add_marker(slow_skip)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def temp_media_dir(tmpdir, monkeypatch, request):
|
||||
if isinstance(request.node, pytest.DoctestItem):
|
||||
monkeypatch.chdir(tmpdir)
|
||||
yield tmpdir
|
||||
else:
|
||||
with manim.tempconfig({"media_dir": str(tmpdir)}):
|
||||
assert manim.config.media_dir == str(tmpdir)
|
||||
yield tmpdir
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def manim_caplog(caplog):
|
||||
logger = logging.getLogger("manim")
|
||||
|
|
@ -58,6 +89,7 @@ def manim_caplog(caplog):
|
|||
@pytest.fixture
|
||||
def config():
|
||||
saved = manim.config.copy()
|
||||
manim.config.renderer = "cairo"
|
||||
# we need to return the actual config so that tests
|
||||
# using tempconfig pass
|
||||
yield manim.config
|
||||
|
|
|
|||
|
|
@ -89,7 +89,13 @@ def test_gif_writing(tmp_path, config, write_to_movie, transparent):
|
|||
],
|
||||
)
|
||||
def test_codecs(
|
||||
tmp_path, config, write_to_movie, format, transparent, codec, pixel_format
|
||||
tmp_path,
|
||||
config,
|
||||
write_to_movie,
|
||||
format,
|
||||
transparent,
|
||||
codec,
|
||||
pixel_format,
|
||||
):
|
||||
output_filename = f"codec_{format}_{'transparent' if transparent else 'opaque'}"
|
||||
config.media_dir = tmp_path
|
||||
|
|
@ -141,7 +147,7 @@ def test_codecs(
|
|||
np.testing.assert_allclose(first_frame[-1, -1], target_rgba_center, atol=5)
|
||||
|
||||
|
||||
def test_scene_with_non_raw_or_wav_audio(manim_caplog):
|
||||
def test_scene_with_non_raw_or_wav_audio(config, manim_caplog):
|
||||
class SceneWithMP3(Scene):
|
||||
def construct(self):
|
||||
file_path = Path(__file__).parent / "click.mp3"
|
||||
|
|
@ -153,7 +159,7 @@ def test_scene_with_non_raw_or_wav_audio(manim_caplog):
|
|||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_unicode_partial_movie(tmpdir, simple_scenes_path):
|
||||
def test_unicode_partial_movie(config, tmpdir, simple_scenes_path):
|
||||
# Characters that failed for a user on Windows
|
||||
# due to its weird default encoding.
|
||||
unicode_str = "三角函数"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue