Repository: ManimCommunity/manim

Issue:
Fix the installation of or completely replace cairo
As many, or rather probably most of us know personally, and have seen on the Discord channel too, the installation of cairo regularly causes problems (at least on windows.)

As of now the documentation refers to installing dependencies via the requirements.txt in the Directly section:
```
# Install python requirements
python3 -m pip install -r requirements.txt
```
Although there is a Directly(Windows) section, if the original Directly doesn't work on windows, then we'd want to write that properly as in Directly(Mac, Linux) or whatever, if we already can't streamline the process across platforms.

While this requirements.txt is in principle a great and convenient idea, pycairo (and to a lesser degree opencv-python) were often a source of issues. Recently the version numbers have been removed from the requirements.txt, which helps, but pycairo is still a unique case, as just trying to install it like this will always fail, and if that isn't bad enough, will actually ask for a Microsoft Visual C++ installation.
If you haven't tried it yet, that's a huge amount of overhead **and** also doesn't really make the pip pycairo install work reliably either. Highly frustrating to users.

The documentation goes on to mention downloading pycairo files (https://www.lfd.uci.edu/~gohlke/pythonlibs/#pycairo), but `For most users, pycairo‑1.18.0‑cp37‑cp37m‑win32.whl will do fine.` and `Make sure that pycairo==1.17.1 is changed to pycairo==1.18.0 in requirements.txt.` are also deprecated comments. The manual file installs are tied to the python version, so someone with 3.8 will not be able to install pycairo cp37 if I remember correctly. All in all this installation is just unreasonably stacked with pitfalls and will throw off most casual users with ease. Talking of python 3.8, manim can be installed on it and we probably should roll on with that too.

So what we should do is, at least dramatically clean-up the documentation, or at best find a way to either streamline the windows pycairo installation or replace it altogether.
Though I'm raising the issue I don't have any great idea for how to implement one of the better solutions.


Discussion:
I'm running manim on Python 3.8.2 and it works fine.
Maybe we can create an install script that pulls the cairo package?
> I'm running manim on Python 3.8.2 and it works fine.

It works if you install it manually... atm pip won't handle it entirely
We... should be able to, yeah. Question is if we want to commit to that option as it would mean stuff like checking the python and sys version, then grabbing the according file.
I thought we had already decided that the rendering engine would be kept modular, and that manim would only ship with OpenGL rendering?
Hi, replacing cairo is probably not a good idea, because `Text` rely on it to generate svg.

Maybe we should try to switch into cairocffi? But it's installation is also annoying in Windows, but at least it doesn't require Microsoft Visual C++ installation
I have make a PR to cairocffi already to let it support some cairo behavior so that manim can switch pycairo simply by ```import cairocffi as cairo```. Although my PR to cairocffi has been merged, they doesn't update their release so far, so we probably need to wait for sometime...
> Hi, replacing cairo is probably not a good idea, because `Text` rely on it to generate svg.

Note that it's _replacing_, not _removing_, so we'll simply have a different renderer do all the `Text` work and more.

> Maybe we should try to switch into cairocffi? But it's installation is also annoying in Windows, but at least it doesn't require Microsoft Visual C++ installation

The intention is to avoid those installation issues, but `cairo` should remain an option with our proposed addon API
Also, using cairocffi has a another advantage which pycairo can't offer. Using cairocffi can let Windows user to use pango/pangocairo easily. As we all know, the built-in text layout engine in cairo(both cairocffi and cairo) are not well support some languages like Bengali. Currently I'm trying to let `Text` to use pango/pangocairo to let it have a better utf-8 support, and this need us to switch pycairo into cairocffi
This should be resolved with future rendering options, such as JS
> This should be resolved with future rendering options, such as JS

You mean the electron app that EulerTour is working on?

yes
But it can't convert text into svg paths and lost many animating abilities...
it's not done yet
I agree with you that the drawing frames function should let other package to do rather than cairo.

Resolving patch:
diff --git a/Scripts/pycairoInstall.py b/Scripts/pycairoInstall.py
new file mode 100644
--- /dev/null
+++ b/Scripts/pycairoInstall.py
@@ -0,0 +1,51 @@
+import platform
+import os
+import sys
+import urllib.request
+
+if 'Windows' in platform.system():
+    #In case the python version is 3.6 and the system is 32-bit, try pycairo‑1.19.1‑cp37‑cp37m‑win32.whl version of cairo
+    if sys.version[:3]=='3.6' and platform.machine()=='x86':
+        urllib.request.urlretrieve("https://download.lfd.uci.edu/pythonlibs/s2jqpv5t/pycairo-1.19.1-cp36-cp36m-win32.whl", "pycairo-1.19.1-cp36-cp36m-win32.whl")
+        os.system("pip install pycairo-1.19.1-cp36-cp36m-win32.whl")
+        os.remove("pycairo-1.19.1-cp37-cp37m-win32.whl")
+
+    #In case the python version is 3.6 and the system is 64-bit, try pycairo‑1.19.1‑cp37‑cp37m‑win32.whl version of cairo
+    elif sys.version[:3]=='3.6' and platform.machine()=='AMD64':
+        urllib.request.urlretrieve("https://download.lfd.uci.edu/pythonlibs/s2jqpv5t/pycairo-1.19.1-cp36-cp36m-win_amd64.whl", "pycairo-1.19.1-cp36-cp36m-win_amd64.whl")
+        print("Sucessfully downloaded Cairo for your system")
+        print("Installing Cairo")
+        os.system("pip install pycairo-1.19.1-cp36-cp36m-win_amd64.whl")
+        os.remove("pycairo-1.19.1-cp36-cp36m-win_amd64.whl")
+    
+    #In case the python version is 3.7 and the system is 32-bit, try pycairo‑1.19.1‑cp37‑cp37m‑win32.whl version of cairo
+    elif sys.version[:3]=='3.7' and platform.machine()=='x86':
+        urllib.request.urlretrieve("https://download.lfd.uci.edu/pythonlibs/s2jqpv5t/pycairo-1.19.1-cp37-cp37m-win32.whl", "pycairo-1.19.1-cp37-cp37m-win32.whl")
+        print("Sucessfully downloaded Cairo for your system")
+        print("Installing Cairo")
+        os.system("pip install pycairo-1.19.1-cp37-cp37m-win32.whl")
+        os.remove("pycairo-1.19.1-cp37-cp37m-win32.whl")
+
+    #In case the python version is 3.7 and the system is AMD64, try pycairo-1.19.1-cp37-cp37m-win_amd64.whl version of cairo
+    elif sys.version[:3]=='3.7' and platform.machine()=='AMD64':
+        urllib.request.urlretrieve("https://download.lfd.uci.edu/pythonlibs/s2jqpv5t/pycairo-1.19.1-cp37-cp37m-win_amd64.whl", "pycairo-1.19.1-cp37-cp37m-win_amd64.whl")
+        print("Sucessfully downloaded Cairo for your system")
+        print("Installing Cairo")
+        os.system("pip install pycairo-1.19.1-cp37-cp37m-win_amd64.whl")
+        os.remove("pycairo-1.19.1-cp37-cp37m-win_amd64.whl")
+        
+    #In case the python version is 3.8 and the system is 32-bit, try pycairo-1.19.1-cp38-cp38-win32.whl version of cairo
+    elif sys.version[:3]=='3.8' and platform.machine()=='x86':
+        urllib.request.urlretrieve("https://download.lfd.uci.edu/pythonlibs/s2jqpv5t/pycairo-1.19.1-cp38-cp38-win32.whl", "pycairo-1.19.1-cp38-cp38-win32.whl")
+        print("Sucessfully downloaded Cairo for your system")
+        print("Installing Cairo")
+        os.system("pip install pycairo-1.19.1-cp38-cp38-win32.whl")
+        os.remove("pycairo-1.19.1-cp38-cp38-win32.whl")
+        
+    #In case the python version is 3.8 and the system is AMD64, try pycairo-1.19.1-cp38-cp38-win_amd64.whl version of cairo
+    elif sys.version[:3]=='3.8' and platform.machine()=='AMD64':
+        urllib.request.urlretrieve("https://download.lfd.uci.edu/pythonlibs/s2jqpv5t/pycairo-1.19.1-cp38-cp38-win_amd64.whl", "pycairo-1.19.1-cp38-cp38-win_amd64.whl")
+        print("Sucessfully downloaded Cairo for your system")
+        print("Installing Cairo")
+        os.system("pip install pycairo-1.19.1-cp38-cp38-win_amd64.whl")
+        os.remove("pycairo-1.19.1-cp38-cp38-win_amd64.whl")   
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -13,7 +13,6 @@
         ]
     },
     install_requires=[
-        "colour",
         "argparse",
         "colour",
         "numpy",


Test patch: