One-day workshop on automating tasks using Make

Nov 9th, 2016

9:00 am - 2:00 pm

Instructors: Lex Nederbragt

Helpers: Anne Fouilloux, Roza Berhanu Lemma, Michael Heeremans, William Brynildsen Reinar, Annicka Rockenberger, Halfdan Rydbeck

General Information

Software Carpentry's mission is to help scientists and engineers get more research done in less time and with less pain by teaching them basic lab skills for scientific computing.

For more information on what we teach and why, please see our paper "Best Practices for Scientific Computing".

This one-day Carpentry@UiO hands-on workshop will cover the Software Carpentry lesson on automating tasks on the Unix shell using Make. Make is a tool which can run commands to read files, process these files in some way, and write out the processed files. For example, in software development, Make is used to compile source code into executable programs or libraries. But, Make can also be used to:

Make is called a build tool - it builds data files, plots, papers, programs or libraries. It can also update existing files if desired. Make tracks the dependencies between the files it creates and the files used to create these. If one of the original files (e.g. a data file) is changed, then Make knows to recreate, or update, the files that depend upon this file (e.g. a plot).

Who: The course is aimed at graduate students and other researchers. You don't need to have any previous knowledge of the tools that will be presented at the workshop. However, some previous experience with using the shell to list directories, create, copy, remove and list files and directories, and run simple scripts is necessary.

Where: Room 1259 (Abels utsikt), Niels Henrik Abels hus, Moltke Moes vei 35, 0851 Oslo.. Get directions with OpenStreetMap or Google Maps.

Requirements: Participants must bring a laptop with a Mac, Linux, or Windows operating sytem (not a tablet, Chromebook, etc.) that they have administrative privileges on. They should have a few specific software packages installed (listed below). They are also required to abide by Software Carpentry's Code of Conduct.

Accessibility: We are committed to making this workshop accessible to everybody. The workshop organisers have checked that:

Materials will be provided in advance of the workshop and large-print handouts are available if needed by notifying the organizers in advance. If we can help making learning easier for you (e.g. sign-language interpreters, lactation facilities) please get in touch and we will attempt to provide them.

Registration: Please register using this form.

Contact: Please mail contact-us@swcarpentry.uio.no for more information.


Schedule

09:00 Automation and Make part I
10:30 Coffee/tea break
10:45 Automation and Make part II
12:00 Lunch break
13:00 Conclusion and practicing with Make
14:00 Wrap-up

Etherpad: http://pad.software-carpentry.org/2016-11-09-make.
We will use this Etherpad for chatting, taking notes, and sharing URLs and bits of code.


Syllabus

Automation and Make

  • Makefiles
  • Automatic Variables
  • Dependencies on Data and Code
  • Pattern Rules
  • Variables and functions
  • Self-Documenting Makefiles
  • Reference...

Setup

To participate in this workshop, you will need access to the software described below. In addition, you will need an up-to-date web browser.

We maintain a list of common issues that occur during installation as a reference for instructors that may be useful on the Configuration Problems and Solutions wiki page.

Overview

Editor

Make sure you install, or have available, a text editor that you are comfortable with using. When you're writing code, it's nice to have a text editor that is optimized for writing code, with features like automatic color-coding of key words.

The Bash Shell

Bash is a commonly-used shell. Using a shell gives you more power to do more tasks more quickly with your computer.

Git

Git is a state-of-the-art version control system. It lets you track who made changes to what when and has options for easily updating a shared or public version of your code on github.com.

Python

Python is becoming very popular in scientific computing, and it's a great language for teaching general programming concepts due to its easy-to-read syntax. We teach with Python version 2.7, since it is still the most widely used. Installing all the scientific packages for Python individually can be a bit difficult, so we recommend an all-in-one installer.

Make

Originally invented to manage compilation of programs written in languages like C, Make can be used to automatically update any set of files that depend on another set of files. This makes it a good solution for many data analysis and data management problems. While there are many build tools now in existence (e.g. ANT and CMake) they share the same fundamental concepts as Make.

Windows

Editor

nano is the editor installed by the Software Carpentry Installer, it is a basic editor integrated into the lesson material.

Notepad++ is a popular free code editor for Windows. Be aware that you must add its installation directory to your system path in order to launch it from the command line (or have other tools like Git launch it for you). Please ask your instructor to help you do this.

Git Bash

Install Git for Windows by download and running the installer. This will provide you with both Git and Bash in the Git Bash program.

Software Carpentry Installer

This installer requires an active internet connection

After installing Python and Git Bash:

  • Download the installer.
  • If the file opens directly in the browser select File→Save Page As to download it to your computer.
  • Double click on the file to run it.

Python

  • Download and install Anaconda.
  • Use all of the defaults for installation except make sure to check Make Anaconda the default Python.

Make

NOTE: The Software Carpentry Windows installer installs Make. When using the installer, start at the 'To test:' part below.

Once you have installed Git Bash you can install Make by:

  • Download make.exe from here
  • Place it in the bin directory where you installed Git Bash e.g. C:\Program Files (x86)\Git\bin.
  • To test: open a Git Bash window, type make, and press Enter.
  • You should see the following message
    make: *** No targets specified and no makefile found. Stop.
    This means that Make was successfully installed. Otherwise, you'll see this error message:
    bash: make: command not found

Mac OS X

Editor

We recommend Text Wrangler or Sublime Text. In a pinch, you can use nano, which should be pre-installed.

Bash

The default shell in all versions of Mac OS X is bash, so no need to install anything. You access bash from the Terminal (found in /Applications/Utilities). You may want to keep Terminal in your dock for this workshop.

Git

Install Git for Mac by downloading and running the installer. For older versions of OS X (10.5-10.7) use the most recent available installer available here. Use the Leopard installer for 10.5 and the Snow Leopard installer for 10.6-10.7.

Python

  • Download and install Anaconda.
  • Use all of the defaults for installation except make sure to check Make Anaconda the default Python.

Make

For OS X, version 10.9 (Mavericks) or above, download the Command Line Tools by doing:

xcode-select  --install

For more information, see the OSX Daily blog.

If you have an older OS X version and you do not already have access to make from within your shell, you will need to install XCode (which is free, but over a gigabyte to download).

  • Go to the Apple app store
  • Search for XCode
  • Click Free
  • Click Install App

Once XCode has installed:

  • Click Applications
  • Click XCode
  • Select XCode→Preferences...
  • Click Downloads
  • Select Command Line Tools
  • Click Install

You will now be able to run make within your shell.

Linux

Editor

Kate is one option for Linux users. In a pinch, you can use nano, which should be pre-installed.

Bash

The default shell is usually bash, but if your machine is set up differently you can run it by opening a terminal and typing bash. There is no need to install anything.

Git

If Git is not already available on your machine you can try to install it via your distro's package manager (e.g. apt-get or yum).

Python

We recommend the all-in-one scientific Python installer Anaconda. (Installation requires using the shell and if you aren't comfortable doing the installation yourself just download the installer and we'll help you at the workshop.)

  1. Download the installer that matches your operating system and save it in your home folder.
  2. Open a terminal window.
  3. Type
    bash Anaconda-
    and then press tab. The name of the file you just downloaded should appear.
  4. Press enter. You will follow the text-only prompts. When there is a colon at the bottom of the screen press the down arrow to move down through the text. Type yes and press enter to approve the license. Press enter to approve the default location for the files. Type yes and press enter to prepend Anaconda to your PATH (this makes the Anaconda distribution the default Python).

Make

Make is a standard tool on Linux systems and should already be available.