Background Image
Table of Contents Table of Contents
Previous Page  185 / 478 Next Page
Information
Show Menu
Previous Page 185 / 478 Next Page
Page Background

1. Author of the Mock library and maintainer of

unittest

; if the Python testing world has a rock star, it is he.

CHAPTER 9

Automating Deployment with Fabric

Automate, automate, automate.

— Cay Horstman

Automating deployment is critical for our staging tests to mean anything. By making

sure the deployment procedure is repeatable, we give ourselves assurances that every‐

thing will go well when we deploy to production.

Fabric is a tool which lets you automate commands that you want to run on servers.

You can install fabric systemwide—it’s not part of the core functionality of our site, so

it doesn’t need to go into our virtualenv and

requirements.txt

. So, on your local PC:

$

pip2 install fabric

At the time of writing, Fabric had not been ported to Python 3, so we

have to use the Python 2 version. Thankfully, the Fabric code is to‐

tally separate from the rest of our codebase, so it’s not a problem.

Installing Fabric on Windows

Fabric depends on pycrypto, which is a package that needs compiling. Compiling on

Windows is a rather fraught process; it’s often quicker to try and get hold of precompiled

binaries put out there by some kindly soul. In this case the excellent Michael Foord

1

has

provided some

Windows binaries

. (Don’t forget to giggle at the mention of absurd US

munitions export controls.)

So the instructions, for Windows, are:

157