Installing third-party software

If you’re thinking of using our libraries (or other third-party libraries) on your Raspberry Pi, you’ve probably seen references to git and GitHub. You may be a veteran git user, in which case you can skip this article, but if git or GitHub are unfamiliar to you, read on.

Let’s start by taking a step back. If you want to use someone elses’ software library, there are several different ways in which you might be able to install it.

  1. You might download an archive (typically a zip or tgz file). You’ll usually need to unpack the archive and run some kind of installation script. That’s one way you can install our gpio-admin and quick2wire-python-api libraries.
  2. If you’re lucky, the library might be packaged as a Debian package (let’s say it’s called glockenspiel) and stored in a repository. In that case, you’ll be able to install it by invoking
sudo apt-get install glockenspiel

and the package should then be available for use.

We’ll package each of our libraries like that eventually, but only when they are stable and complete. That may take a while.

The problem of fast-changing code

At present we’re changing and extending the quick2wire-python-api code quite frequently, and we’ll update the gpio-admin library whenever we fix a bug or add a feature. If you use either of the earlier methods to install software and that software is changing fast, it’s likely that your version will be out-of-date, and you may not even know it.

That’s where git comes in.

Git

Git is a free and open source distributed version control system. Let’s take that apart bit by bit.

Git is free and open source. You don’t need to pay to use it, and the source code is freely available. In practice that means that many pairs of eyes will be scanning the code and reading any bug reports, so defects in the code are likely to be found and fixed quickly.

But what does git do?

The fact that it’s a version control system means that it can help you keep track of files that are frequently changed. Most version control systems maintain a history of changes and make it easy for users to compare versions, to load previous versions, and to add new versions as appropriate. Most software developers use a version control system of some sort, and many use git.

Git has a range of features which make it attractive to developers, and one of those features is the fact that it supports distributed development. In other words, git is designed for use by teams in which the developers work in more than one location. Most of the developers at Quick2wire have day jobs and we work on our software from home, so a distributed version control system is really useful to us.

You don’t need to know about we how we use git in our development process. The thing that matters is that you can use git, simply and easily, to get the latest version of our software on your Raspberry Pi.

Git expects developers to keep all the files for a project or library together in something called a repository. That’s just a grand name for a collection of files that belong together. All of our libraries are stored in git repositories, and those repositories are stored on GitHub.

GitHub

Hopefully that’s given you a feel for git and why we use it, but what about GitHub?

GitHub is a web-based service for people who want to use git. It’s widely used by teams who want to make some or all of their work publicly available under an open source license. Since that’s what we do, we feel that GitHub is a natural choice for us to store our code.

If you want to keep up-to-date with the code we’ve published on GitHub, you will need to install and use git.

Installing Git on your Pi

To install git, just pen a terminal window by typing Ctrls-Alt-T and invoke

sudo apt-get install git-core

You’ll be asked for your password and so long as your Pi has access to the internet and the debian RasPi repository is on-line you’ll see some activity which will show what’s going on as git is installed.

Once that stops you’ll be ready to go.

Using git to download our code

When you first install a local copy of a repository using git, you do so by creating what’s called a clone of the repository.

If you take a look at the web-page for our quick2wire-python-api library, at the top of the web- page you’ll see a panel that looks like this:

Project URI panel on GitHub

Project URI panel on GitHub

In order to install a local copy of the repository, click on the button marked ‘Git Read-Only’ and copy the text of the URI on its right. In our case, that’s git://github.com/quick2wire/quick2wire-python-api.git

It’s probably best to keep all your GitHub-based repositores in one place, so you may want to create a directory called git within your home directory. (In a command window, type cd ~

and then type mkdir git)

When you have done so, open a command window if necessary, change to your git directory by typing cd ~/git and create a copy of the GitHub content by typing

git clone git://github.com/quick2wire/quick2wire-python-api.git

Git will tell you that it’s created an empty repository and will then pull down all the current files from the repository on GitHub.

The README file on Git should tell you what do do to install the software in the repository.  in our case the recommended approach is to add the location of your new cloned repository to your Python Path.

Now you can use the software.

But how do you keep it up to date?

Keeping current

If you take  look at the GitHub page for a repository you can see when the files were last changed. If you open an account at GitHub (which has a free account option) you can chose to watch one or more repositories, in which case you will get notified whenever the repsoitory changes.

If a repository you’ve cloned has changed since you last updated it, it’s really easy to get back up-to-date. In a command window, change to the directory in which you cloned the repository. In our case, you’d type cd ~/git/quick2wire-python-api in a command window. Now just type git pull and git will update your repository so that it’s an exact copy of the current version on GitHub.

Depending on the way type of software in the repository, you may or may not need to repeat the installation procedure. If you’ve updated out gpio-admin repository, you’ll need to run through the installation process again, as described in the README for that repository in GitHub. In the case of the quick2wire-python-api package, you’ve already placed the code on your PythonPath so you should be ready to use the updated library without doing anything else.

Summary

You can use most code on GitHub by downloading, unpacking and installing an archive containing the code.

If the code is changing fast, and you want to stay up-to-date you may prefer to install git, use the clone command to create a local copy of the repository, and use the git pull command to refresh your copy when the version on GitHub has changed.

22 Comments

  1. Thanks for the great simple guides.

    I am having a couple of problems though, and i was wondering if you could help me? My pi is connected to the internet with an ethernet cable connected to my mac. I think because of this I don’t get a ip address when I follow your SSH guide. This wouldn’t be a problem, except that when I try and install the GIT information my pi ‘cannot resolve ‘ftp.uk.debian.org”. I think the connection method is probably my problem, but can you see anything else I could be missing? (When I check with CyberDuck i can see the debian ftp on my mac)

    Thank-you so much,
    Emily

    Reply

  2. Hi Emily,

    You will need to enable Internet sharing on your Mac.

    Open up ‘System Preferences’ on your Mac, goto ‘Sharing’ (in ‘Internet and Wireless’ section), and enable ‘Internet Sharing’.

    I’m guessing that your Mac is using wifi to connect to the Internet, so next to ‘Share your connection from:’, choose ‘AirPort’. The next to ‘To computers using:’, choose ‘Ethernet’.

    Thanks
    -Joe

    Reply

  3. git clone git://github.com/quick2wire/quick2wire-python-api.git does not work today.
    Cloning into ‘quick2wire-gpio-admin’…
    fatal: unable to connect to github.com:
    github.com[0: 207.97.227.239]: errno=Connexion terminee par expiration du delai d’attente

    I am able to ping the site, to see it in the web browser but no to clone it?

    Reply

  4. 11 Feb 2013. Tried to install git core but all I got was a mass of failures, missing files and errors.
    I fear that I will not be able to get my newly ordered boards to work when they arrive unless a a different method of supplying the essential software is provided. This problem appears to have been going on for a long time. Any ideas about a simple download of the current library just to get us started?

    Reply

    • I’m guessing that you have not updated the libraries on your Pi distribution.

      in a terminal window, type
      sudo apt-get update
      and then
      sudo apt-get upgrade

      wait a while as the Pi brings itself up-to-date. This can take a few minutes if your internet or your SD card are slow.

      Then
      sudo apt-get install git-core
      should work and you’ll be ready to go.

      Reply

  5. Downloads and installs have all worked OK and I have all the necessary files in
    ~/git/quick2wire-python-api

    How do I add this location to my Python Path?

    Sorry to be so thick – I can do Arduino but Linux/python is still a steep learning curve – I still need explicit instructions.

    Reply

  6. QUick question if you have a lot of clone software you have downloaded and want to update them all the same time do you know where or how to create a script to update them?

    Let’s say the software are all located in the opt folder or /pentest folder in backtrack. How would you update all the software?

    Reply

  7. I’m sorry to be difficult but having set the PYTHONPATH I find the the rest of the instructions using python-pip and python-virtualenv totally incomprehendable.

    Your boards are a delight to solder up but many of your customers will find installing the libraries from these instructions impossible and frustrating. (I got as far setting PYTHONPATH from the note above totally failed to follow how to use python-pip or python-virtualenv.)

    I understand that the software is still underdevelopment, adding interrupt control and pwm etc, but a basic library to just set pin directions in/out, set output values and read input values, which is EASY to install is vital. I’m thinking of some command like:
    wget http://quick2wire.com/download/install.txt | bash

    An improved library with extra bells and whistles could be installed later.

    Sorry to appear so negative but I’ve spent 4 times as long on trying to install the sofware (unsuccessfully) as I spent building the boards.

    Reply

    • Hi Tony,

      We have a library version that should be as easy to install as you would like. At present the website doesn’t make it clear how to install it. I’ll fix this tomorrow and will post a link here.

      Romilly

      Reply

  8. Any chance of this simple to install basic (read/write registers) i2c library by the weekend?

    Regards

    Tony Goodhew

    Reply

    • Tony Goodhew

      Still still not managed to get a working version of the essential software for I2C and Python API. How about putting an SD card image of a properly running installation on your site with some example Python code in the user’s directory? This would be easy to download and very simple to install on a new card.

      Reply

      • That’s a great idea, and we may be able to do it tomorrow.

        Sorry you’ve been having such trouble. We’ve had technical hassles of our own (now resolved) which is why we have been slow to respond.

        Reply

        • Tony Goodhew

          Please include code examples for using the new analog board which is currently on order. ie read from an ATD port and write to the DTA port.

          Reply

          • Tony Goodhew

            Any news about this SD card image as I am still unable to get your api to install and am only able to use port extender in python 2 with smbus?

            I’ve just built your Analogue board. Is there any info on how to use it?

  9. Romilly Cocking

    Tony, I’m creating a fresh image with all our software; I will put it up on our website tomorrow.

    I hope we can post a basic guide to using the PCF8591 library with the analogue board tomorrow also.

    Reply

    • Is the card image available somewhere? I’ve not managed to find it and still cannot get past PythonPath bit. Using virtualenv without simpler/fuller instructions is still too big a step.

      I can only access the boards via smbus.

      Tony Goodhew

      Reply

      • We made a card image but did it on an 8 GB card, so the image is a huge download. We’re going to re-flash one on a 4Gb card, and may be able to put the image up tomorrow.

        I am sorry you’ve had such a wait but we have been dealing with an order for 5000 kits (not a typo!) so things have been really, really mad and lots of important things have slipped.

        Reply

        • Thanks for the reply. I’m really glad the business has been going so well. I love the boards and have learned a great deal working everything out from first principles and chip data sheets.

          Reply

          • It never seems to be as simple as I hope :)

            The image we built is 800Mb when zipped. We can’t upload that big a file on wordpress, and the services we use for our test servers would only allow a download or so a day. So I’ve posted you an SD card with raspbian and all our software on, installed and configured, in the hope that this will help you get going.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>