A community-maintained Python framework for creating mathematical animations.
Enhancement (of new feature): JupyterLab docker image and documentation for manim and IPython (#977)
Benjamin Hackl60c225a191de
diff --git a/README.md b/README.mdindex 3e6ad96e8..b98179475 100644--- a/README.md+++ b/README.md@@ -3,13 +3,14 @@<br /><br /><a href="https://pypi.org/project/manim/"><img src="https://img.shields.io/pypi/v/manim.svg?style=flat&logo=pypi" alt="PyPI Latest Release"></a>+ <a href="https://hub.docker.com/r/manimcommunity/manim"><img src="https://img.shields.io/docker/v/manimcommunity/manim?color=%23099cec&label=docker%20image&logo=docker" alt="Docker image"> </a>+ <a href="https://mybinder.org/v2/gist/behackl/725d956ec80969226b7bf9b4aef40b78/HEAD?filepath=basic%20example%20scenes.ipynb"><img src="https://mybinder.org/badge_logo.svg"></a><a href="http://choosealicense.com/licenses/mit/"><img src="https://img.shields.io/badge/license-MIT-red.svg?style=flat" alt="MIT License"></a><a href="https://www.reddit.com/r/manim/"><img src="https://img.shields.io/reddit/subreddit-subscribers/manim.svg?color=orange&label=reddit&logo=reddit" alt="Reddit" href=></a><a href="https://twitter.com/manim_community/"><img src="https://img.shields.io/twitter/url/https/twitter.com/cloudposse.svg?style=social&label=Follow%20%40manim_community" alt="Twitter"><a href="https://discord.gg/mMRrZQW"><img src="https://img.shields.io/discord/581738731934056449.svg?label=discord&color=yellow&logo=discord" alt="Discord"></a><a href="https://github.com/psf/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Code style: black"><a href="https://docs.manim.community/"><img src="https://readthedocs.org/projects/manimce/badge/?version=latest" alt="Documentation Status"></a>- <a href="https://hub.docker.com/r/manimcommunity/manim"><img src="https://img.shields.io/docker/v/manimcommunity/manim?color=%23099cec&label=docker%20image&logo=docker" alt="Docker image"> </a><a href="https://pepy.tech/project/manim"><img src="https://pepy.tech/badge/manim/month?" alt="Downloads"> </a><img src="https://github.com/ManimCommunity/manim/workflows/CI/badge.svg" alt="CI"><br />@@ -34,7 +35,12 @@ Manim is an animation engine for explanatory math videos. It's used to create pr## Installation-Manim requires a few dependencies that must be installed prior to using it. Please visit the [Documentation](https://docs.manim.community/en/latest/installation.html) and follow the appropriate instructions for your operating system.+Manim requires a few dependencies that must be installed prior to using it. If you+want to try it out first before installing it locally, you can do so+[in our online Jupyter environment](https://mybinder.org/v2/gist/behackl/725d956ec80969226b7bf9b4aef40b78/HEAD?filepath=basic%20example%20scenes.ipynb).++For the local installation, please visit the [Documentation](https://docs.manim.community/en/latest/installation.html)+and follow the appropriate instructions for your operating system.Once the dependencies have been installed, run the following in a terminal window:@@ -73,7 +79,8 @@ You should see your native video player program pop up and play a simple scene i[GitHub repository](master/example_scenes). You can also visit the [official gallery](https://docs.manim.community/en/latest/examples.html) for more advanced examples.Manim also ships with a `%%manim` IPython magic which allows to use it conveniently in JupyterLab (as well as classic Jupyter) notebooks. See the-[corresponding documentation](https://docs.manim.community/en/latest/reference/manim.utils.ipython_magic.ManimMagic.html) for some guidance.+[corresponding documentation](https://docs.manim.community/en/latest/reference/manim.utils.ipython_magic.ManimMagic.html) for some guidance and+[try it out online](https://mybinder.org/v2/gist/behackl/725d956ec80969226b7bf9b4aef40b78/HEAD?filepath=basic%20example%20scenes.ipynb).## Command line argumentsdiff --git a/docker/Dockerfile b/docker/Dockerfileindex 0d9d81c1f..2c38a5417 100644--- a/docker/Dockerfile+++ b/docker/Dockerfile@@ -1,4 +1,4 @@-FROM python:3.7-slim+FROM python:3.8-slimRUN apt-get update -qq \&& apt-get install --no-install-recommends -y \@@ -17,17 +17,33 @@ RUN wget -O /tmp/install-tl-unx.tar.gz http://mirror.ctan.org/systems/texlive/tltar -xzf /tmp/install-tl-unx.tar.gz -C /tmp/install-tl --strip-components=1 && \/tmp/install-tl/install-tl --profile=/tmp/texlive-profile.txt \&& tlmgr install \- amsmath babel-english cm-super doublestroke dvisvgm fundus-calligra \+ amsmath babel-english cm-super doublestroke dvisvgm everysel fundus-calligra \jknapltx latex-bin microtype ms physics preview ragged2e relsize rsfs \setspace standalone tipa wasy wasysym xcolor xkeyval# clone and build manimCOPY . /opt/manimWORKDIR /opt/manim-RUN pip install --no-cache .+RUN pip install --no-cache .[jupyterlab,webgl_renderer]+# required due to current incompatibility from latest jedi version+RUN pip install jedi==0.17.2++ARG NB_USER=manimuser+ARG NB_UID=1000+ENV USER ${NB_USER}+ENV NB_UID ${NB_UID}+ENV HOME /manim++RUN adduser --disabled-password \+ --gecos "Default user" \+ --uid ${NB_UID} \+ ${NB_USER}# create working directory for user to mount local directory into-WORKDIR /manim-RUN chmod 666 /manim+WORKDIR ${HOME}+USER root+RUN chown -R ${NB_USER}:${NB_USER} ${HOME}+RUN chmod 777 ${HOME}+USER ${NB_USER}CMD [ "/bin/bash" ]diff --git a/docker/readme.md b/docker/readme.mdindex 68f8d182f..4931a630b 100644--- a/docker/readme.md+++ b/docker/readme.md@@ -35,6 +35,15 @@ Then, to render a scene `CircleToSquare` in a file `test_scenes.py`, call$ docker exec -it --user="$(id -u):$(id -g)" my-manim-container manim test.py CircleToSquare -qm```+## Jupyterlab+Another alternative is to use the docker image to spin up a local webserver running+JupyterLab in whose Python kernel manim is installed and can be accessed via the `%%manim` cell magic.+To use JupyterLab, run+```+$ docker run -it -p 8888:8888 manimcommunity/manim jupyter lab --ip=0.0.0.0+```+and then follow the instructions in the terminal.+# Important notesWhen executing `manim` within a Docker container, several command line flags (in particular `-p` (preview file) and `-f` (show output file in the file browser)) are not supported.diff --git a/docs/source/examples.rst b/docs/source/examples.rstindex aa43200bb..762d67062 100644--- a/docs/source/examples.rst+++ b/docs/source/examples.rst@@ -16,6 +16,10 @@ Enjoy this taste of Manim!the modules :mod:`~.tex_mobject`, :mod:`~.geometry`, :mod:`~.moving_camera_scene`,and many more.+ Check out our `interactive Jupyter environment <https://mybinder.org/v2/gist/behackl/725d956ec80969226b7bf9b4aef40b78/HEAD?filepath=basic%20example%20scenes.ipynb>`_+ which allows running the examples online, without requiring a local+ installation.+Also, visit our `Twitter <https://twitter.com/manim_community/>`_ for more*manimations*!diff --git a/manim/__init__.py b/manim/__init__.pyindex 33e71e04d..51c093415 100644--- a/manim/__init__.py+++ b/manim/__init__.py@@ -1,5 +1,13 @@#!/usr/bin/env python+try:+ import importlib.metadata as importlib_metadata+except ModuleNotFoundError:+ import importlib_metadata++__version__ = importlib_metadata.version(__name__)++# Importing the config module should be the first thing we do, since other# modules depend on the global config dict for initialization.from ._config import *@@ -96,10 +104,3 @@ else:ipy.register_magics(ManimMagic)from .plugins import *--try:- import importlib.metadata as importlib_metadata-except ModuleNotFoundError:- import importlib_metadata--__version__ = importlib_metadata.version(__name__)