Skip to content

Instantly share code, notes, and snippets.

@NamPNQ
Created March 28, 2016 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NamPNQ/f9c9ccbe35370f36e117 to your computer and use it in GitHub Desktop.
Save NamPNQ/f9c9ccbe35370f36e117 to your computer and use it in GitHub Desktop.
fabric with virtualenv
from fabric.api import lcd, local, path
project_dir = '/www/my_project/sms/'
env_bin_dir = project_dir + '../env/bin/'
def deploy():
with lcd(project_dir):
local('git pull origin')
local('git checkout -f')
with path(env_bin_dir, behavior='prepend'):
local('pip freeze')
local('pip install -r requirements/staging.txt')
local('./manage.py migrate') # Django related
# Note: previous line is the same as:
local('python manage.py migrate')
# Using next line, you can make sure that python
# from virtualenv directory is used:
local('which python')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment