PSLab device is made useful with applications running on two platforms. One is Android and the other one is a desktop application developed using Python frameworks. Desktop application uses half a dozen of dependent libraries and they are required to be installed prior to installing the application itself.
For someone with zero or less knowledge on how to install packages in a Linux environment, this task will be quite difficult. To ease up the process of installing the desktop application in a computer, we can use a script to run specific commands which will install the dependencies and the application.
Dependencies required by PSLab Desktop app
- PyQt 4.7
- Python 2.6, 2.7 or 3.x
- NumPy, Scipy
- pyopengl and qt-opengl
These dependencies can be made installed using a bash script running with root permission. A bash script will have the file extension “.sh” and a header line;
A bash script needs to be made executable by the user himself. To do this, user needs to type a one line command in the terminal as follows and enter his password;
The keyword “sudo” interprets as “Super User DO” and the line follows will be executed with root permission. In other words with administrative privileges to modify system settings such as copying content to system folders.
The keyword “chmod” stands for “Change Mode” which will alter the mode of a file. In current context, the file is made executable by adding the executable property to the bash script using “+x” syntax.
Once the script is made executable, it can be executed using;
An installer can be made attractive by using different colors rather than the plain old text outputs. For this purpose we can use color syntax in bash script. They are represented using ANSI escape codes and following is a list of commonly used colors;
As in any programming language, rather than using the same line in many places, we can define variables in a bash script. The syntax will be the variable name followed by an equal sign with the value. There cannot be spaces around the equal sign or it will generate an error.
These variables can be accessed using a special syntax as follows;
Finally we can output a message to the console using the “echo” command
Note that the keyword “-e” is used to enable interpretation of the following backslash escapes.
In order to install the packages and libraries, we use two package management tools. One is “apt” which stands for “Advanced Packaging Tool” and the second is “pip” which is used to download python related packages from “Python Package Index”. The following two lines illustrates how the two commands can be accessed.
The keyword “-y” avoids the confirmation prompt in console to allow installation by pressing “Y” key every time it installs a package from “apt”.
- Creating Bash Scripts: https://bash.cyberciti.biz/guide/Hello,_World!_Tutorial
- CHMOD: https://en.wikipedia.org/wiki/Chmod
- Colors in echo output: https://en.wikipedia.org/wiki/ANSI_escape_code
- apt vs pip: askubuntu.com/questions/431780/apt-get-install-vs-pip-install