Browse Source

use pip instead of setup.py in fabric command

pull/1850/merge
David Lord 9 years ago
parent
commit
aa9a994946
  1. 37
      docs/patterns/fabric.rst

37
docs/patterns/fabric.rst

@ -43,36 +43,25 @@ virtual environment::
env.hosts = ['server1.example.com', 'server2.example.com'] env.hosts = ['server1.example.com', 'server2.example.com']
def pack(): def pack():
# create a new source distribution as tarball # build the package
local('python setup.py sdist --formats=gztar', capture=False) local('python setup.py sdist --formats=gztar', capture=False)
def deploy(): def deploy():
# figure out the release name and version # figure out the package name and version
dist = local('python setup.py --fullname', capture=True).strip() dist = local('python setup.py --fullname', capture=True).strip()
# upload the source tarball to the temporary folder on the server filename = '%s.tar.gz' % dist
put('dist/%s.tar.gz' % dist, '/tmp/yourapplication.tar.gz')
# create a place where we can unzip the tarball, then enter # upload the package to the temporary folder on the server
# that directory and unzip it put('dist/%s' % filename, '/tmp/%s' % filename)
run('mkdir /tmp/yourapplication')
with cd('/tmp/yourapplication'):
run('tar xzf /tmp/yourapplication.tar.gz')
# now setup the package with our virtual environment's
# python interpreter
run('/var/www/yourapplication/env/bin/python setup.py install')
# now that all is set up, delete the folder again
run('rm -rf /tmp/yourapplication /tmp/yourapplication.tar.gz')
# and finally touch the .wsgi file so that mod_wsgi triggers
# a reload of the application
run('touch /var/www/yourapplication.wsgi')
The example above is well documented and should be straightforward. Here # install the package in the application's virtualenv with pip
a recap of the most common commands fabric provides: run('/var/www/yourapplication/env/bin/pip install /tmp/%s' % filename)
- `run` - executes a command on a remote server # remove the uploaded package
- `local` - executes a command on the local machine run('rm -r /tmp/%s' % filename)
- `put` - uploads a file to the remote server
- `cd` - changes the directory on the serverside. This has to be used # touch the .wsgi file to trigger a reload in mod_wsgi
in combination with the ``with`` statement. run('touch /var/www/yourapplication.wsgi')
Running Fabfiles Running Fabfiles
---------------- ----------------

Loading…
Cancel
Save