-
Notifications
You must be signed in to change notification settings - Fork 7
/
Rakefile
136 lines (121 loc) · 3.3 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
$venv_dir = '.venv'
$mac_os = `uname -s`.strip == 'Darwin'
desc "Create a Python virtualenv"
task :create_venv do
raise unless system("virtualenv #{$venv_dir}")
end
task :require_venv_activated do
unless File.exists? "#{$venv_dir}/bin/activate"
puts
puts "Please create a virtual environment."
puts
puts "\t$ rake create_venv"
puts
raise
end
if ENV['VIRTUAL_ENV'] != File.join(Dir.pwd, $venv_dir)
puts
puts "Please activate virtualenv."
puts
puts "\t$ . #{$venv_dir}/bin/activate"
puts
raise
end
end
desc "Install dependencies for development"
task :install => :require_venv_activated do
raise unless system("pip install -r requirements_dev.txt")
end
desc "Install dependencies for integration testing"
task :install_integration => :install do
if $mac_os
# Homebrew deps for doc gen and integration tests
raise unless system("brew update")
raise unless system("brew install chromedriver")
end
# Deps for building Fine Uploader for integration tests
raise unless system("npm install -g grunt-cli")
if not $mac_os
puts
puts "Installation complete."
puts
puts "You must install:"
puts
puts " - chromedriver"
puts
raise
end
end
desc "Install dependencies for distribution"
task :install_dist => :install do
if $mac_os
raise unless system "brew update"
raise unless system "brew install pandoc"
else
puts
puts "You must install:"
puts
puts " - pandoc"
puts
raise
end
end
desc "Install a particular version of Fine Uploader for integration testing."
task :install_fine, [:version] do |t, args|
raise unless system("./fine-uploader-build.sh #{args.version}")
end
def command_is_in_path?(command)
system("which #{ command} > /dev/null 2>&1")
end
task :test => :require_venv_activated do
if command_is_in_path?('foreman')
maybe_foreman_run = 'foreman run'
else
maybe_foreman_run = ''
end
raise unless system("#{maybe_foreman_run} drf_to_s3/runtests/runtests.py")
end
task :integration => :require_venv_activated do
unless command_is_in_path?('foreman')
puts
puts "Please install `foreman`."
puts
puts "Via RubyGems:"
puts
puts "\tgem install foreman"
puts
puts "Or via Heroku Toolbelt:"
puts
puts "\thttps://toolbelt.heroku.com/"
puts
raise
end
raise unless system("foreman run drf_to_s3/runtests/runtests.py integration")
end
desc "Remove .pyc files"
task :clean do
system("find . -name '*.pyc' -delete")
end
desc "Remove venv, vendor files, and built distributions"
task :veryclean => :clean do
system("rm -rf ./#{$venv_dir} vendor/ dist/")
system("rm -rf drf_to_s3/integration/static/fine-uploader")
end
task :sdist do
unless command_is_in_path?('pandoc')
puts
puts "Please install pandoc."
puts
raise
end
raise unless system("python setup.py sdist")
end
task :upload do
unless command_is_in_path?('pandoc')
puts
puts "Please install pandoc."
puts
raise
end
raise unless system("python setup.py sdist upload")
end