danielfm / django-flash

Django-Flash is a simple Django extension which provides support for Rails-like flash messages.

This URL has Read+Write access

django-flash / fabfile.py
19e91cd3 » danielfm 2009-06-26 Started the development of ... 1 # -*- coding: utf-8 -*-
2
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 3 """Build script used to test, build and deploy django-flash using several
28fb6278 » danielfm 2009-06-27 Done a few improvements in ... 4 Python versions.
5
d65c9809 » danielfm 2009-06-27 Some improvements. 6 In order to test and build django-flash in these different environments,
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 7 this script requires different virtualenvs, each one targeted to a specific
8 Python version:
28fb6278 » danielfm 2009-06-27 Done a few improvements in ... 9
10 * django-flash-py2.6 - for Python 2.6
11 * django-flash-py2.5 - for Python 2.5
12 * django-flash-py2.4 - for Python 2.4
13
d65c9809 » danielfm 2009-06-27 Some improvements. 14 Also, each one of these virtualenvs must have the following packages
28fb6278 » danielfm 2009-06-27 Done a few improvements in ... 15 installed:
16
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 17 * Django (version 1.0+)
28fb6278 » danielfm 2009-06-27 Done a few improvements in ... 18 * Pysqlite (version recommended by the current Django version)
19
20 Finally, to use this script, you must install the packages below to your
21 default Python installation:
22
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 23 * Fabric 0.9+
28fb6278 » danielfm 2009-06-27 Done a few improvements in ... 24
d65c9809 » danielfm 2009-06-27 Some improvements. 25 That's it. You can now see all available targets provided by this build
26 script by running the command line below:
28fb6278 » danielfm 2009-06-27 Done a few improvements in ... 27
28 $ cd /path/to/django-flash
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 29 $ fab -l
19e91cd3 » danielfm 2009-06-26 Started the development of ... 30 """
31
baf9f3a6 » danielfm 2009-09-18 Added to the fabfile a func... 32 import os
33 import re
34 import sys
35
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 36 from fabric.api import *
37
38
baf9f3a6 » danielfm 2009-09-18 Added to the fabfile a func... 39 # Adds the 'src' to the Python path
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 40 sys.path += ('src',)
baf9f3a6 » danielfm 2009-09-18 Added to the fabfile a func... 41
42 # Supported Python versions
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 43 env.versions = ('2.6', '2.5', '2.4')
44 env.default_version = env.versions[0]
baf9f3a6 » danielfm 2009-09-18 Added to the fabfile a func... 45
19e91cd3 » danielfm 2009-06-26 Started the development of ... 46 # Environment info
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 47 env.project = 'django-flash'
48 env.virtualenv_dir = os.environ['WORKON_HOME'] or '~/.virtualenvs'
49 env.default_editor = os.environ['EDITOR'] or 'vi'
baf9f3a6 » danielfm 2009-09-18 Added to the fabfile a func... 50
51 # Files that contain version information
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 52 env.new_version_files = (
baf9f3a6 » danielfm 2009-09-18 Added to the fabfile a func... 53 'setup.py',
54 'src/djangoflash/__init__.py',
55 'doc/source/conf.py',
66a221bf » danielfm 2009-09-18 Fabfile improvement. 56 'doc/source/changelog.rst',
baf9f3a6 » danielfm 2009-09-18 Added to the fabfile a func... 57 )
19e91cd3 » danielfm 2009-06-26 Started the development of ... 58
59 # Information needed to build the documentation
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 60 env.sphinx_output = 'build/sphinx'
61 env.sphinx_latex = '%s/latex' % env.sphinx_output
62 env.sphinx_html = '%s/html' % env.sphinx_output
63 env.doc_output = 'djangoflash'
19e91cd3 » danielfm 2009-06-26 Started the development of ... 64
65 # Host where the documentation website lives
13fb2bd5 » danielfm 2009-11-23 Fixed a problem with the 'h... 66 env.hosts = ['destaquenet.com']
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 67 env.doc_folder = '/home/destaquenet/public_html'
19e91cd3 » danielfm 2009-06-26 Started the development of ... 68
69
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 70 def setup(command, version=env.default_version):
deb84645 » danielfm 2009-06-26 Done small improvements on ... 71 """Executes the given setup command with a virtual Python installation.
19e91cd3 » danielfm 2009-06-26 Started the development of ... 72 """
8bd8995d » danielfm 2009-09-18 Breaking down long lines. 73 local('%s/%s-py%s/bin/python setup.py %s' %
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 74 (env.virtualenv_dir, env.project, version, command))
19e91cd3 » danielfm 2009-06-26 Started the development of ... 75
76 def test():
77 """Runs all tests in different Python versions.
78 """
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 79 for version in env.versions:
c933ccbc » danielfm 2009-06-26 Done small improvements on ... 80 setup('test', version)
19e91cd3 » danielfm 2009-06-26 Started the development of ... 81
c933ccbc » danielfm 2009-06-26 Done small improvements on ... 82 def clean():
deb84645 » danielfm 2009-06-26 Done small improvements on ... 83 """Removes the build directory.
19e91cd3 » danielfm 2009-06-26 Started the development of ... 84 """
c933ccbc » danielfm 2009-06-26 Done small improvements on ... 85 local('rm -fR build')
19e91cd3 » danielfm 2009-06-26 Started the development of ... 86
87 def build_docs():
deb84645 » danielfm 2009-06-26 Done small improvements on ... 88 """Builds the documentation in PDF and HTML.
19e91cd3 » danielfm 2009-06-26 Started the development of ... 89 """
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 90 clean()
19e91cd3 » danielfm 2009-06-26 Started the development of ... 91 setup('build_sphinx')
92 setup('build_sphinx -b latex')
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 93 local('make -C ' + env.sphinx_latex)
19e91cd3 » danielfm 2009-06-26 Started the development of ... 94
95 def zip_docs():
c933ccbc » danielfm 2009-06-26 Done small improvements on ... 96 """Creates a zip file with the complete documentation.
19e91cd3 » danielfm 2009-06-26 Started the development of ... 97 """
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 98 build_docs()
8bd8995d » danielfm 2009-09-18 Breaking down long lines. 99 local('cp %s/%s.pdf %s' %
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 100 (env.sphinx_latex, env.project, env.sphinx_html))
8bd8995d » danielfm 2009-09-18 Breaking down long lines. 101 local('cd %s; mv html %s; zip -r9 %s.zip %s' %
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 102 ((env.sphinx_output,) + (env.doc_output,)*3))
19e91cd3 » danielfm 2009-06-26 Started the development of ... 103
104 def register_pypi():
105 """Register the current version on PyPI.
106 """
107 setup('register')
108
109 def deploy_src():
110 """Deploy the source code to PyPI.
111 """
112 setup('sdist upload')
113
114 def deploy_eggs():
115 """Upload Python Eggs to PyPI.
116 """
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 117 for version in env.versions:
19e91cd3 » danielfm 2009-06-26 Started the development of ... 118 setup('bdist_egg upload', version)
119
120 def deploy_pypi():
c933ccbc » danielfm 2009-06-26 Done small improvements on ... 121 """Deploys all artifacts to PyPI.
19e91cd3 » danielfm 2009-06-26 Started the development of ... 122 """
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 123 test()
124 register_pypi()
125 deploy_src()
126 deploy_eggs()
19e91cd3 » danielfm 2009-06-26 Started the development of ... 127
128 def deploy_website():
c933ccbc » danielfm 2009-06-26 Done small improvements on ... 129 """Deploys the documentation website.
19e91cd3 » danielfm 2009-06-26 Started the development of ... 130 """
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 131 zip_docs()
8bd8995d » danielfm 2009-09-18 Breaking down long lines. 132 put('%s/%s.zip' %
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 133 (env.sphinx_output, env.doc_output), env.doc_folder)
8bd8995d » danielfm 2009-09-18 Breaking down long lines. 134 run('cd %s; rm -R %s; unzip %s.zip; rm %s.zip' %
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 135 ((env.doc_folder,) + (env.doc_output,)*3))
19e91cd3 » danielfm 2009-06-26 Started the development of ... 136
137 def deploy():
c933ccbc » danielfm 2009-06-26 Done small improvements on ... 138 """Deploys the application to PyPI and updates the documentation website.
19e91cd3 » danielfm 2009-06-26 Started the development of ... 139 """
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 140 deploy_pypi()
141 deploy_website()
baf9f3a6 » danielfm 2009-09-18 Added to the fabfile a func... 142
143 def tag_new_version():
8bd8995d » danielfm 2009-09-18 Breaking down long lines. 144 """Updates the version number, pushing the changes and tagging afterwards.
baf9f3a6 » danielfm 2009-09-18 Added to the fabfile a func... 145 """
146 # Checks if there are changed or untracked files
147 git_status_file = 'build/git_status'
148 local('git status > %s' % git_status_file, fail='ignore')
149 if re.search(r'(Changed|Untracked)', file(git_status_file, 'r').read()):
150 print 'There are changed or untracked files. Aborting...'
151 return
152
153 # Brings up the text editor with the files to be changed
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 154 for f in env.new_version_files:
155 local('%s %s' % (env.default_editor, f))
baf9f3a6 » danielfm 2009-09-18 Added to the fabfile a func... 156
157 # Asks for confirmation
158 prompt('tag_proceed', 'You are about to commit and push the version '
159 'changes. Continue?', default='y')
160
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 161 if env.tag_proceed.upper() != 'Y':
baf9f3a6 » danielfm 2009-09-18 Added to the fabfile a func... 162 print 'Aborting...'
163 return
164
2909567f » danielfm 2009-09-18 Fabfile improvement. 165 # Commits and tags the new release
baf9f3a6 » danielfm 2009-09-18 Added to the fabfile a func... 166 from djangoflash import __version__
dfde88d7 » danielfm 2009-09-18 Fabfile fix. 167 local('git commit -am "Updated version number."; git push', fail='ignore')
8bd8995d » danielfm 2009-09-18 Breaking down long lines. 168 local('git tag -am "Tagged version %s." %s; git push --tags' %
169 ((__version__,)*2), fail='ignore')
baf9f3a6 » danielfm 2009-09-18 Added to the fabfile a func... 170 local('git push --tags')
ae7a2547 » danielfm 2009-11-01 Upgrading to Fabric 0.9rc1. 171