forked from jsonpickle/jsonpickle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
74 lines (64 loc) · 1.58 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
VERSION_FILE = File.open('jsonpickle/version.py').gets.strip
eval VERSION_FILE
PYTHON_ENVS = [:env26, :env27, :env32, :env33, :env34]
PYTHON_EXECS = {:env26 => "python2.6",
:env27 => "python2.7",
:env32 => "python3.2",
:env33 => "python3.3",
:env34 => "python3.4"}
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 "rm -rf *.pyc *.pyo"
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", env)
}
end
task :default => [:tests]