© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2021
M. Cywiak, D. CywiakMulti-Platform Graphics Programming with Kivyhttps://doi.org/10.1007/978-1-4842-7113-1_1

1. Getting Started: Software installation

Moisés Cywiak1   and David Cywiak2
(1)
Leon, Guanajuato, Mexico
(2)
Queretaro, Mexico
 

The code presented in this book can be executed on any platform running Python. However, to translate the programs into applications that can be installed and executed on Android, the developing operating system must be Ubuntu. We briefly describe the preliminary steps to run Python along with the required applications in Ubuntu. In this case, we are using Ubuntu 20.04.1 LTS.

Although Python3 is already installed in Ubuntu, we need to install pip3 and IDLE. We cover how to use pip3 later, which is necessary to install the additional packages and libraries that the programs will require. IDLE is the shell that allows you to write and execute the code.

1.1 Installing pip3 and IDLE

To install pip3, open a Terminal window by using Ctrl+Alt+T. It will be convenient to add the Terminal to the favorites bar. From this point on, your computer will require Internet access.

To install pip3 and IDLE, you have to type the following three commands, in the order indicated.
  1. 1.

    sudo apt update. At this step, you need an administrator password.

     
  2. 2.

    sudo apt install python3-pip. This command installs pip3.

     
  3. 3.

    sudo apt install idle3. This command installs Python-Shell.

     

pip3 and IDLE 3 should now be installed on your computer. To verify that IDLE 3 has been installed properly, click Ubuntu’s Show Applications icon and look for the IDLE icon. Now is also a good time to right-click the icon and select the Add to Favorites option.

To check for the pip3 installation, you can type pip3 list in the Terminal window. In response, you will obtain a list of packages installed for the Python3 environment.

For the programs in this book, you need mathematical and graphical capabilities. For this, we will use two powerful Python libraries: NumPy and Kivy.

To install NumPy, type pip3 install numpy in the Terminal window. After the installation completes, you can verify that NumPy has been added to the installed packages by typing pip3 list.

The installation of Kivy is described in the following subsection.

1.2 Installing Kivy

In our experience, it is advisable to install Kivy by carefully executing the step-by-step commands listed in Listing 1-1.
1.   sudo apt update
2.   sudo apt install libsdl2-dev
3.   sudo apt install libsdl2-ttf-dev
4.   sudo apt install libsdl2-image-dev
5.   sudo apt install libsdl2-mixer-dev
6.   sudo apt install python3-kivy
Listing 1-1

Step-by-Step Commands for Installing Kivy

You can verify that Kivy has been installed by typing pip3 list. In our case, we obtained Kivy version 1.10.1. As you will see, it is important to make a note of the version number.

1.3 Installing Buildozer

At this point, we have the entire engine is ready to carry out programming in Ubuntu. However, since you are interested in translating the programs into Android APKs, you need an additional tool, called Buildozer.

We suggest following the installation according to the step-by-step commands presented in Listing 1-2. By following this recipe, you can successfully install Buildozer.
 1.   sudo apt update
 2.   sudo apt install lld
 3.   sudo apt install libtool
 4.   sudo apt install pkg-config
 5.   sudo apt install zlib1g-dev
 6.   sudo apt install libncurses5-dev
 7.   sudo apt install libncursesw5-dev
 8.   sudo apt install libtinfo5
 9.   sudo apt install cmake
10.   sudo apt install libffi-dev
11.   sudo apt install git
12.   sudo apt install libssl-dev
13.   pip3 install autoconfig
14.   pip3 install cython==0.28.2 (see table 1-1)
15.   sudo pip3 install buildozer
Listing 1-2

Commands for Installing Buildozer

You’ll notice in Step 14 that we installed a specific version of Cython. The version number of Cython depends on the version number of Kivy installed on your computer. Required versions are listed in Table 1-1. This table is available at https://kivy.org/doc/stable-1.10.1/installation/deps-cython.html.
Table 1-1

Required Cython Version for Installed Kivy Version

Installed Kivy Version

Required Cython Version

1.9.0

0.21.2

1.9.1

0.23.1

1.10.0

0.25.2

1.10.1

0.28.2

1.11.0

0.29.9

1.11.1

0.29.9

2.0.0

0.29.10

Finally, Buildozer requires Java to be installed on your computer. To install a compatible Java version, the following command is required:
sudo apt install openjdk-8-jdk

Once it’s installed, you can verify the installed version of Java by typing javac -version. In this case, we obtained Javac 1.8.0_265. This is the required version for Buildozer 1.2.0. To obtain the installed Buildozer version, type pip3 list.

Now that you have installed all the requirements needed for developing the programs, you are ready to start programming. In the following chapter, you begin with analytical equations for rotating two-dimensional polygons.

1.4 Summary

In this chapter, we covered the installation of the software requirements to start programming. We provided step-by-step listings to install pip3, IDLE, Kivy, and Buildozer, as well as the corresponding Java and Cython versions.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset