Raspbian Pixel Desktop

Goodbye Ubuntu, Hello Debian

I’ve been using Ubuntu as the go to operating system in my IT lab since it first came out in 2004. It has served me well over these last 15 years, but with its increasing commercialization and focus on cloud computing, snap packages, etc, the time as come for a switch to Debian for use in my classroom.

This switch has been both and encouraged and facilitated by two things:

  1. Unofficial non-free images including firmware packages I am a deeply committed free software activist, but I’m also enough of a pragmatist to use the freest thing that works, even if it does require a few comprises with the proprietary software devil. In years past whenever I tried switching to Debian, I ended up with classroom hardware that I couldn’t make work. This CD install image has worked great, allowing me to install Debian without much fuss on the wild hodgepodge of hardware we have in our lab.
  2. PIXEL for PC and Mac. The thought of using the same desktop environment in my classroom that students will see on a Raspberry Pi is extremely appealing on so many levels. Suffice it to say for now that the Raspberry Pi project has done amazing things for computer science education, so connecting my educational program as close as possible to it is a no-brainer.

The rest of this post describes the configuration process I use for my lab machines.

Setting Up the PIXEL Desktop on PC Hardware

I setup PIXEL PCs using the following process:

  1. Install Debian without a GUI using the architecture appropriate net install image (either amd64 or i386, and yes, I still have a few of those). I selected only SSH server and standard system utilities from the Software selection dialog, deselecting Debian desktop environment and print server, which were selected by default.

  2. Download each of the following three files into the same directory:

  3. Run the commands inside the directory where the downloaded files are located:

    $ chomod +x install_sh
    $ sudo -i
    

    Then remain in the root shell and change back to the directory containing the downloaded files and run:

    # ./install_sh

    Keep watch on this the process so that you can confirm the installation of the Flash plugin when the dialog pops up. When it finishes, reboot and login to the PIXEL desktop.

Installing Python 3.7 in User Directories from Source

I will be using Test-Driven Development with Python as the one of the text books for my Spring 2019 computer science classes. The book requires Python 3.6 or greater, but Debian stretch comes with Python 3.5. The solution I’ve chosen for this problem is to have students compile Python 3.7 from source and install it in their home directories.

To make sure all resources needed to build Python from source are installed on the system ask the system administrator to run:

$ sudo apt install build-essential checkinstall texinfo libffi-dev
$ sudo apt install zlib1g-dev tk-dev libreadline-gplv2-dev
$ sudo apt install libncursesw5-dev libssl-dev libsqlite3-dev
$ sudo apt install libc6-dev libbz2-dev libghc-gtk3-dev

(2019-02-13 Note: Added libghc-gtk3-dev to the install list in the hopes that gasp can be made to run in this local python.)

Follow the following process to install Python 3.7 in your home directory:

  1. Download the latest Python 3.7 source (3.7.2 at time of this writing) from https://www.python.org and extract it with:

    $ tar -xvf Python-3.7.2.tar.xz
    
  2. From inside the Python-3.7.2 directory, run the following to configure, build, and install python 3.7 into the user’s .local subdirectory:

    $ ./configure --enable-optimizations --prefix=$HOME/.local
    $ make
    $ make install
    

    (2019-02-01 Note: The --with-universal-archs=intel-64 configuration can be omitted, and will need to be on architectures other than 64 bit Intel, but it will cause a long series of tests to be run that make the process take a long time.)

  3. Python 3.7 is now installed in the .local/bin subdirectory of the user’s home directory. The .local subdirectory can be used as the root of a user space copy of the Linux Filesystem Hierarchy Standard, permitting the installation of software without administration privileges. This is what we have just done in installing Python 3.7

Configuring Environment for Python Development

A few more tweaks to the local environment will set us up for Python development.

  1. To be able to run python3.7 from the shell, set vim as the default editor for the shell, and swap the Esc and Caps Lock keys to make using vim easier, add the following to the end of the .bashrc file:

    # Swap Esc and Caps Lock Keys
    setxkbmap -option "caps:swapescape"
    
    EDITOR=vim
    PATH=$HOME/.local/bin:$PATH
    PYTHONPATH=$HOME/.local/bin/python
    
    export EDITOR PATH PYTHONPATH
    

    A sym link has automatically been created from python3 to python3.7, so running:

    $ python3
    

    at the bash prompt (after logging out and logging back in) will start Python 3.7.

  2. Adding the following to a .vimrc file in the user’s home directory will turn vim into a nice, light-weight Python IDE:

    syntax enable
    filetype indent on
    " Get around the cntr-c cntr-v not working in vim on Debian stretch
    set mouse=r
    " Expand tabs to spaces
    set et
    " Shiftwidth (for Python indentation) set to 4
    set sw=4
    " Use shiftwidth at start of lines
    set smarttab
    " Map keys to python3, doctest, doctest verbose, and style checking
    map <f3> :w\|!python3 % <cr>
    map <f4> :w\|!python3 -m doctest % <cr>
    map <f5> :w\|!python3 -m doctest -v % <cr>
    map <f8> :w\|!pep8 % -v <cr>
    

In future posts I’ll explore using this system with the Test-Driven Development with Python text.

(2019-01-14 Note: I have now had the chance to try this Python 3.7 “recipe” on both 64 and 32 bit x86 machines as well as a Raspberry Pi 3, and it appears to work on all of them.)