Skip to content
Myr

use pip instead of setup.py in fabric command

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parent 14a5a9e · Browse files · 1 file+13 added−24 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+13 added−24 removed

  • other:+13 added−24 removed

1 file+13 added−24 removed

modified:docs/patterns/fabric.rst+13 added-24 removed
41 unmodified lines
42 # the servers where the commands are executed43 env.hosts = ['server1.example.com', 'server2.example.com']4445 def pack():46 # create a new source distribution as tarball46 # build the package47 local('python setup.py sdist --formats=gztar', capture=False)4849 def deploy():50 # figure out the release name and version50 # figure out the package name and version51 dist = local('python setup.py --fullname', capture=True).strip()52 # upload the source tarball to the temporary folder on the server53 put('dist/%s.tar.gz' % dist, '/tmp/yourapplication.tar.gz')54 # create a place where we can unzip the tarball, then enter55 # that directory and unzip it56 run('mkdir /tmp/yourapplication')57 with cd('/tmp/yourapplication'):58 run('tar xzf /tmp/yourapplication.tar.gz')59 # now setup the package with our virtual environment's60 # python interpreter61 run('/var/www/yourapplication/env/bin/python setup.py install')62 # now that all is set up, delete the folder again63 run('rm -rf /tmp/yourapplication /tmp/yourapplication.tar.gz')64 # and finally touch the .wsgi file so that mod_wsgi triggers65 # a reload of the application66 run('touch /var/www/yourapplication.wsgi')52 filename = '%s.tar.gz' % dist5368The example above is well documented and should be straightforward. Here69a recap of the most common commands fabric provides:54 # upload the package to the temporary folder on the server55 put('dist/%s' % filename, '/tmp/%s' % filename)5671- `run` - executes a command on a remote server72- `local` - executes a command on the local machine73- `put` - uploads a file to the remote server74- `cd` - changes the directory on the serverside. This has to be used75 in combination with the ``with`` statement.57 # install the package in the application's virtualenv with pip58 run('/var/www/yourapplication/env/bin/pip install /tmp/%s' % filename)5960 # remove the uploaded package61 run('rm -r /tmp/%s' % filename)6263 # touch the .wsgi file to trigger a reload in mod_wsgi64 run('touch /var/www/yourapplication.wsgi')6566Running Fabfiles67----------------6869Now how do you execute that fabfile? You use the `fab` command. To
117 unmodified lines