Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

132 lines (109 sloc) 4.408 kb
Fabric's own fabfile.
from fabric.api import *
from fabric.contrib import rsync_project
# New or updated tasks which are known to work
def test():
Run all unit tests
# Need show_stderr=True because the interesting output of nosetests is
# actually sent to stderr, not stdout.
print(local('nosetests -sv', show_stderr=True))
def build_docs():
Generate the Sphinx documentation
print(local('cd docs && make clean html', show_stderr=True))
def push_docs():
rsync_project('/var/www/fabfile/', 'docs/_build/html/', delete=True)
# Older stuff that needs to be updated or removed
def clean(**kwargs):
"Recurse the directory tree and remove all files matched by .gitignore."
# passing -delete to find doesn't work for directories, hence xargs rm -r
local('cat .gitignore | xargs -I PATTERN '
+ 'find . -name PATTERN -not -path "./.git/*" | (xargs rm -r || true)')
if not "nogc" in kwargs:
local('git gc --prune')
def ready_files():
local('mkdir release', fail = 'warn')
# This next part needs explaining...
# 1. use Git to pack HEAD in TAR format to stdout, so we don't distribute
# files with local changes. Plus, make sure that Git only packs those
# files that are named in MANIFEST, so that we make sure that the
# packages in the CheeseShop (PyPi) and on are similar.
# 2. Then we pipe the TAR data through gzip so we get it in tar.gz format.
# 3. Then, in the dist directory, we BOTH write data to a tar.gz file, AND
# unpack it. This will create a clean-room file-set that we can use for
# running distutils. This way, we also make sure that we don't get
# uncommittet changes in our distutils package.
# Pretty clever, eh? Unix CLI-fu!
local('git archive --format=tar --prefix=%(prefix)s/ HEAD '
+ '$(cat MANIFEST | perl -p -e "s/\\n/ /") | gzip | '
+ '(cd release && tee %(prefix)s.tar.gz | tar xzf -)')
local('gpg -b --use-agent %(filename)s')
def release(**kwargs):
"Create a new release of Fabric, and upload it to our various services."
prompt("confirmed", "Release Fabric v. %(fab_version)s? [y/n]")
if config.confirmed != "y":
dry = 'dry' in kwargs
if not dry:
local('git tag -s -m "Fabric v. %(fab_version)s" %(fab_version)s HEAD')
scp_cmd = 'scp $(filename) $(nongnu_user)'
if not dry:
distutil_cmd = ('cd release/%(prefix)s/ && '
+ 'python sdist upload --sign')
if dry:
distutil_cmd += ' --dry-run'
local('rm -fr release')
def install(**kwargs):
"Install Fabric locally."
if 'notest' not in kwargs:
local('python build')
local('sudo python install')
def layout(**kwargs):
Print a layout-overview of to the console.
Optionally append an argument to the underlying grep call.
fab layout
fab layout:-n
fab layout:-n,--color=always
options = ' '.join(['='.join(filter(None,i)) for i in kwargs.items()])
local(r'grep %s \\\(^#\ .*:$\\\)\\\|.*def\ .*|' % options
+ 'perl -p -e "s/def / def /"')
def website():
"Generates the Fabric website."
# assuming we have imagemagick installed:
#local("convert doc/site/fabric-logo.svg doc/site/fabric-logo.png",
# fail="warn")
# previous part commented out because the generated logo did not have
# the required transparent background.
local("cd doc/site && ./bin/")
def upload_website():
"Generates and uploads the Fabric website to"
local("cd doc/site && export CVS_RSH=ssh && "
+ "cvs -z3 -d:ext:$(nongnu_user) co fab")
prompt('website_commit_msg', 'Website commit message',
default = 'Website for version $(fab_version)')
local("cd doc/site/fab && export CVS_RSH=ssh && "
+ "cvs commit -m '$(website_commit_msg)'")
Jump to Line
Something went wrong with that request. Please try again.