-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
95 lines (81 loc) · 2.04 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
require 'uri'
VERSION = "0.0.2"
PYTHON_ENVS = [:env27, :env33]
PYTHON_EXECS = {:env27 => "python2.7", :env33 => "python3.3"}
def colorize(text, color)
color_codes = {
:black => 30,
:red => 31,
:green => 32,
:yellow => 33,
:blue => 34,
:magenta => 35,
:cyan => 36,
:white => 37
}
code = color_codes[color]
if code == nil
text
else
"\033[#{code}m#{text}\033[0m"
end
end
def virtual_env(command, env="env33")
sh "source #{env}/bin/activate && #{command}"
end
def create_virtual_env(dir, python)
sh "virtualenv #{dir} -p #{python}"
end
task :clean => [] do
sh "rm -rf ~*"
sh "find . -name '*.pyc' -delete"
sh "rm -rf data/"
sh "rm -rf *.egg-info"
sh "rm -rf dist/"
end
task :install => [] do
sh "python --version"
sh "ruby --version"
sh "easy_install pip"
end
task :dev_env => [] do
PYTHON_ENVS.each { |env|
puts colorize("Environment #{env}", :blue)
create_virtual_env(env, PYTHON_EXECS[env])
}
end
task :dependencies => [:dev_env] do
PYTHON_ENVS.each { |env|
puts colorize("Environment #{env}", :blue)
virtual_env("pip install -r requirements.txt", "#{env}")
virtual_env("pip install -r requirements-test.txt", "#{env}")
}
end
task :tests => [] do
PYTHON_ENVS.each { |env|
puts colorize("Environment #{env}", :blue)
virtual_env("nosetests --process-timeout=3 --verbosity=2", env)
}
end
task :tag => [:tests] do
sh "git tag #{VERSION}"
sh "git push origin #{VERSION}"
end
task :reset_tag => [] do
sh "git tag -d #{VERSION}"
sh "git push origin :refs/tags/#{VERSION}"
end
task :publish => [:tests, :tag] do
# http://guide.python-distribute.org/quickstart.html
# python setup.py sdist
# python setup.py register
# python setup.py sdist upload
# Manual upload to PypI
# http://pypi.python.org/pypi/THE-PROJECT
# Go to 'edit' link
# Update version and save
# Go to 'files' link and upload the file
virtual_env("python setup.py sdist upload")
end
task :all => [:dev_env, :dependencies, :tests]
task :default => [:tests]