Ask coding questions

← Back to all posts
How to correctly setup Kivy in a Repl.it
Saibot84 (3)

I was testing things out ... and I've found that under certain conditions ... Kivy works in a Pygame repl. https://repl.it/@Saibot84/Kivy-code-snippets

Step 1: Run the following python code
import Cython
import Cython.Distutils

(In that repl, this code is saved as setup.txt We can copy it from there to main.py to run it)

Step 2:
Run the kivy code (but wait for kivy's wheels to be built, which take a while)

My question is ... how can we make sure that Cython and Cython.Distutils are built first ... before kivy gets built?

  • I tried using requirements.txt to require Cython and kivy ... kivy's build was throwing an error that it couldn't find Cython.Distutils

  • I tried creating a polygott repl ... and in run, having it pip install cython, then pip install kivy ... but pip was downloading the packages from the internet ... and the downloads were freezing/crashing what I assume to be the virtual polygott computer.

  • In the python code, I tried importing subprocess and using subprocess.call to "pip install cython" ... but this was also downloading from the internet and crashing the virtual polygott computer.

  • If the python code includes the line "import kivy" ... Repl is auto-installing the package ... even if I try calling subprocess to pip install cython /before/ the import kivy line of code is ever reached.

I know the Pygame and the polygott repls aren't "meant" for kivy ... but kivy is able to run.

Does anyone know how to control that cython and cython.distutils be built before kivy is built?

-Michael

Commentshotnewtop
Saibot84 (3)

I've recently come back to this ... and after some experimentation ...

https://repl.it/@Saibot84/Polygott-Kivy-Installer-Runner
Here's a polygott repl that installs kivy from a local wheelhouse, then runs the x11 vnc server and then the python code.
It will seem to hang while installing Kivy ... but you can check the nohup.out file to see the installation progress until the server and code are started. (By the way, it seems that sending output to nohup prevents the repl from crashing.)

https://repl.it/@Saibot84/Python3-Pygame-Kivy
Here's a Python3 with Pygame repl ... that uses a requirements.txt file to install kivy. Running it looks like it hangs while building Kivy, but just wait for it to finish.

https://repl.it/@Saibot84/Polygott-Kivy-PreInstalled
Here's a polygott repl that has kivy preinstalled ... so the build runs much faster. It, too, then runs the x11 vnc server and then the python code.