Skip to content

Commit 60c225a

Browse files
behacklkolibril13
andauthored
Enhancement (of new feature): JupyterLab docker image and documentation for manim and IPython (#977)
* fix import: move setting __version__ to top of __init__ * add simple Dockerfile for a manim-jupyterlab container * add section on jupyterlab in docker/readme.md * improve Dockerfile: separate user, install manim with all extras, upgrade to python 3.8 * remove separate jupyterlab docker image, adapt readme * add missing latex package * include link to interactive worksheet in documentation * Update README.md Co-authored-by: kolibril13 <[email protected]>
1 parent 89e20d5 commit 60c225a

File tree

5 files changed

+52
-15
lines changed

5 files changed

+52
-15
lines changed

README.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
<br />
44
<br />
55
<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>
6+
<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>
7+
<a href="https://mybinder.org/v2/gist/behackl/725d956ec80969226b7bf9b4aef40b78/HEAD?filepath=basic%20example%20scenes.ipynb"><img src="https://mybinder.org/badge_logo.svg"></a>
68
<a href="http://choosealicense.com/licenses/mit/"><img src="https://img.shields.io/badge/license-MIT-red.svg?style=flat" alt="MIT License"></a>
79
<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>
810
<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">
911
<a href="https://discord.gg/mMRrZQW"><img src="https://img.shields.io/discord/581738731934056449.svg?label=discord&color=yellow&logo=discord" alt="Discord"></a>
1012
<a href="https://github.com/psf/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Code style: black">
1113
<a href="https://docs.manim.community/"><img src="https://readthedocs.org/projects/manimce/badge/?version=latest" alt="Documentation Status"></a>
12-
<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>
1314
<a href="https://pepy.tech/project/manim"><img src="https://pepy.tech/badge/manim/month?" alt="Downloads"> </a>
1415
<img src="https://github.com/ManimCommunity/manim/workflows/CI/badge.svg" alt="CI">
1516
<br />
@@ -34,7 +35,12 @@ Manim is an animation engine for explanatory math videos. It's used to create pr
3435

3536
## Installation
3637

37-
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.
38+
Manim requires a few dependencies that must be installed prior to using it. If you
39+
want to try it out first before installing it locally, you can do so
40+
[in our online Jupyter environment](https://mybinder.org/v2/gist/behackl/725d956ec80969226b7bf9b4aef40b78/HEAD?filepath=basic%20example%20scenes.ipynb).
41+
42+
For the local installation, please visit the [Documentation](https://docs.manim.community/en/latest/installation.html)
43+
and follow the appropriate instructions for your operating system.
3844

3945
Once the dependencies have been installed, run the following in a terminal window:
4046

@@ -73,7 +79,8 @@ You should see your native video player program pop up and play a simple scene i
7379
[GitHub repository](master/example_scenes). You can also visit the [official gallery](https://docs.manim.community/en/latest/examples.html) for more advanced examples.
7480

7581
Manim also ships with a `%%manim` IPython magic which allows to use it conveniently in JupyterLab (as well as classic Jupyter) notebooks. See the
76-
[corresponding documentation](https://docs.manim.community/en/latest/reference/manim.utils.ipython_magic.ManimMagic.html) for some guidance.
82+
[corresponding documentation](https://docs.manim.community/en/latest/reference/manim.utils.ipython_magic.ManimMagic.html) for some guidance and
83+
[try it out online](https://mybinder.org/v2/gist/behackl/725d956ec80969226b7bf9b4aef40b78/HEAD?filepath=basic%20example%20scenes.ipynb).
7784

7885
## Command line arguments
7986

docker/Dockerfile

+21-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.7-slim
1+
FROM python:3.8-slim
22

33
RUN apt-get update -qq \
44
&& 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/tl
1717
tar -xzf /tmp/install-tl-unx.tar.gz -C /tmp/install-tl --strip-components=1 && \
1818
/tmp/install-tl/install-tl --profile=/tmp/texlive-profile.txt \
1919
&& tlmgr install \
20-
amsmath babel-english cm-super doublestroke dvisvgm fundus-calligra \
20+
amsmath babel-english cm-super doublestroke dvisvgm everysel fundus-calligra \
2121
jknapltx latex-bin microtype ms physics preview ragged2e relsize rsfs \
2222
setspace standalone tipa wasy wasysym xcolor xkeyval
2323

2424
# clone and build manim
2525
COPY . /opt/manim
2626
WORKDIR /opt/manim
27-
RUN pip install --no-cache .
27+
RUN pip install --no-cache .[jupyterlab,webgl_renderer]
28+
# required due to current incompatibility from latest jedi version
29+
RUN pip install jedi==0.17.2
30+
31+
ARG NB_USER=manimuser
32+
ARG NB_UID=1000
33+
ENV USER ${NB_USER}
34+
ENV NB_UID ${NB_UID}
35+
ENV HOME /manim
36+
37+
RUN adduser --disabled-password \
38+
--gecos "Default user" \
39+
--uid ${NB_UID} \
40+
${NB_USER}
2841

2942
# create working directory for user to mount local directory into
30-
WORKDIR /manim
31-
RUN chmod 666 /manim
43+
WORKDIR ${HOME}
44+
USER root
45+
RUN chown -R ${NB_USER}:${NB_USER} ${HOME}
46+
RUN chmod 777 ${HOME}
47+
USER ${NB_USER}
3248

3349
CMD [ "/bin/bash" ]

docker/readme.md

+9
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ Then, to render a scene `CircleToSquare` in a file `test_scenes.py`, call
3535
$ docker exec -it --user="$(id -u):$(id -g)" my-manim-container manim test.py CircleToSquare -qm
3636
```
3737

38+
## Jupyterlab
39+
Another alternative is to use the docker image to spin up a local webserver running
40+
JupyterLab in whose Python kernel manim is installed and can be accessed via the `%%manim` cell magic.
41+
To use JupyterLab, run
42+
```
43+
$ docker run -it -p 8888:8888 manimcommunity/manim jupyter lab --ip=0.0.0.0
44+
```
45+
and then follow the instructions in the terminal.
46+
3847
# Important notes
3948
When 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.
4049

docs/source/examples.rst

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ Enjoy this taste of Manim!
1616
the modules :mod:`~.tex_mobject`, :mod:`~.geometry`, :mod:`~.moving_camera_scene`,
1717
and many more.
1818

19+
Check out our `interactive Jupyter environment <https://mybinder.org/v2/gist/behackl/725d956ec80969226b7bf9b4aef40b78/HEAD?filepath=basic%20example%20scenes.ipynb>`_
20+
which allows running the examples online, without requiring a local
21+
installation.
22+
1923
Also, visit our `Twitter <https://twitter.com/manim_community/>`_ for more
2024
*manimations*!
2125

manim/__init__.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
#!/usr/bin/env python
22

3+
try:
4+
import importlib.metadata as importlib_metadata
5+
except ModuleNotFoundError:
6+
import importlib_metadata
7+
8+
__version__ = importlib_metadata.version(__name__)
9+
10+
311
# Importing the config module should be the first thing we do, since other
412
# modules depend on the global config dict for initialization.
513
from ._config import *
@@ -96,10 +104,3 @@
96104
ipy.register_magics(ManimMagic)
97105

98106
from .plugins import *
99-
100-
try:
101-
import importlib.metadata as importlib_metadata
102-
except ModuleNotFoundError:
103-
import importlib_metadata
104-
105-
__version__ = importlib_metadata.version(__name__)

0 commit comments

Comments
 (0)