capistrano-virtualenv 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -0
- data/lib/capistrano-virtualenv/deploy.rb +55 -6
- data/lib/capistrano-virtualenv/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -40,6 +40,7 @@ Following options are available to manage your virtualenv.
|
|
40
40
|
* `:virtualenv_easy_install_options` - options for `easy_install`. by defaul "--quiet".
|
41
41
|
* `:virtualenv_install_packages` - apt packages dependencies for python.
|
42
42
|
* `:virtualenv_pip_options` - options for `pip`. by default "--quiet".
|
43
|
+
* `:virtualenv_pip_install_options` - options for `pip install`.
|
43
44
|
* `:virtualenv_release_path` - virtualenv path under `:release_path`.
|
44
45
|
* `:virtualenv_release_python` - python path under `:virtualenv_release_path`.
|
45
46
|
* `:virtualenv_requirements` - the list of `pip` packages should be installed to `virtualenv`.
|
@@ -28,6 +28,7 @@ module Capistrano
|
|
28
28
|
}
|
29
29
|
_cset(:virtualenv_easy_install_options, %w(--quiet))
|
30
30
|
_cset(:virtualenv_pip_options, %w(--quiet))
|
31
|
+
_cset(:virtualenv_pip_install_options, [])
|
31
32
|
_cset(:virtualenv_pip_package, 'pip')
|
32
33
|
_cset(:virtualenv_requirements, []) # primary package list
|
33
34
|
_cset(:virtualenv_requirements_file) { # secondary package list
|
@@ -47,9 +48,25 @@ module Capistrano
|
|
47
48
|
_cset(:virtualenv_shared_easy_install) {
|
48
49
|
File.join(virtualenv_shared_path, 'bin', 'easy_install')
|
49
50
|
}
|
51
|
+
_cset(:virtualenv_shared_easy_install_cmd) {
|
52
|
+
# execute from :virtualenv_shared_python
|
53
|
+
# since `virtualenv --relocatable` will not set shebang line with absolute path.
|
54
|
+
[
|
55
|
+
virtualenv_shared_python,
|
56
|
+
virtualenv_shared_easy_install,
|
57
|
+
virtualenv_easy_install_options,
|
58
|
+
].flatten.join(' ')
|
59
|
+
}
|
50
60
|
_cset(:virtualenv_shared_pip) {
|
51
61
|
File.join(virtualenv_shared_path, 'bin', 'pip')
|
52
62
|
}
|
63
|
+
_cset(:virtualenv_shared_pip_cmd) {
|
64
|
+
[
|
65
|
+
virtualenv_shared_python,
|
66
|
+
virtualenv_shared_pip,
|
67
|
+
virtualenv_pip_options,
|
68
|
+
].flatten.join(' ')
|
69
|
+
}
|
53
70
|
|
54
71
|
## release virtualenv
|
55
72
|
## - created in release_path
|
@@ -64,9 +81,23 @@ module Capistrano
|
|
64
81
|
_cset(:virtualenv_release_easy_install) {
|
65
82
|
File.join(virtualenv_release_path, 'bin', 'easy_install')
|
66
83
|
}
|
84
|
+
_cset(:virtualenv_release_easy_install_cmd) {
|
85
|
+
[
|
86
|
+
virtualenv_release_python,
|
87
|
+
virtualenv_release_easy_install,
|
88
|
+
virtualenv_easy_install_options,
|
89
|
+
].flatten.join(' ')
|
90
|
+
}
|
67
91
|
_cset(:virtualenv_release_pip) {
|
68
92
|
File.join(virtualenv_release_path, 'bin', 'pip')
|
69
93
|
}
|
94
|
+
_cset(:virtualenv_release_pip_cmd) {
|
95
|
+
[
|
96
|
+
virtualenv_release_python,
|
97
|
+
virtualenv_release_pip,
|
98
|
+
virtualenv_pip_options,
|
99
|
+
].flatten.join(' ')
|
100
|
+
}
|
70
101
|
|
71
102
|
## current virtualenv
|
72
103
|
## - placed in current_path
|
@@ -80,9 +111,23 @@ module Capistrano
|
|
80
111
|
_cset(:virtualenv_current_easy_install) {
|
81
112
|
File.join(virtualenv_current_path, 'bin', 'easy_install')
|
82
113
|
}
|
114
|
+
_cset(:virtualenv_current_easy_install_cmd) {
|
115
|
+
[
|
116
|
+
virtualenv_current_python,
|
117
|
+
virtualenv_current_easy_install,
|
118
|
+
virtualenv_easy_install_options,
|
119
|
+
].flatten.join(' ')
|
120
|
+
}
|
83
121
|
_cset(:virtualenv_current_pip) {
|
84
122
|
File.join(virtualenv_current_path, 'bin', 'pip')
|
85
123
|
}
|
124
|
+
_cset(:virtualenv_current_pip_cmd) {
|
125
|
+
[
|
126
|
+
virtualenv_current_python,
|
127
|
+
virtualenv_current_pip,
|
128
|
+
virtualenv_pip_options,
|
129
|
+
].flatten.join(' ')
|
130
|
+
}
|
86
131
|
|
87
132
|
desc("Setup virtualenv.")
|
88
133
|
task(:setup, :except => { :no_release => true }) {
|
@@ -110,8 +155,8 @@ module Capistrano
|
|
110
155
|
cmds = [ ]
|
111
156
|
cmds << "mkdir -p #{dirs.join(' ')}"
|
112
157
|
cmds << "( test -d #{virtualenv_shared_path} || #{virtualenv_cmd} #{virtualenv_shared_path} )"
|
113
|
-
cmds << "( test -x #{virtualenv_shared_pip} || #{
|
114
|
-
cmds << "#{virtualenv_shared_python} --version && #{
|
158
|
+
cmds << "( test -x #{virtualenv_shared_pip} || #{virtualenv_shared_easy_install_cmd} #{virtualenv_pip_package} )"
|
159
|
+
cmds << "#{virtualenv_shared_python} --version && #{virtualenv_shared_pip_cmd} --version"
|
115
160
|
run(cmds.join(' && '))
|
116
161
|
}
|
117
162
|
|
@@ -134,20 +179,24 @@ module Capistrano
|
|
134
179
|
top.put(virtualenv_requirements.join("\n"), tempfile.path)
|
135
180
|
run("diff -u #{virtualenv_requirements_file} #{tempfile.path} || mv -f #{tempfile.path} #{virtualenv_requirements_file}; rm -f #{tempfile.path}")
|
136
181
|
end
|
137
|
-
run("touch #{virtualenv_requirements_file} && #{
|
182
|
+
run("touch #{virtualenv_requirements_file} && #{virtualenv_shared_pip_cmd} install #{virtualenv_pip_install_options.join(' ')} -r #{virtualenv_requirements_file}")
|
138
183
|
}
|
139
184
|
|
140
185
|
task(:create_release, :except => { :no_release => true }) {
|
141
186
|
dirs = [ File.dirname(virtualenv_release_path) ].uniq()
|
142
187
|
cmds = [ ]
|
143
188
|
cmds << "mkdir -p #{dirs.join(' ')}"
|
144
|
-
|
189
|
+
# TODO: turn :virtualenv_use_relocatable true if it will be an official features.
|
190
|
+
# `virtualenv --relocatable` does not work expectedly as of virtualenv 1.7.2.
|
191
|
+
if fetch(:virtualenv_use_relocatable, false)
|
145
192
|
cmds << "#{virtualenv_cmd} --relocatable #{virtualenv_shared_path}"
|
146
193
|
cmds << "cp -RPp #{virtualenv_shared_path} #{virtualenv_release_path}"
|
147
194
|
else
|
148
195
|
cmds << "( test -d #{virtualenv_release_path} || #{virtualenv_cmd} #{virtualenv_release_path} )"
|
149
|
-
cmds << "( test -x #{virtualenv_release_pip} || #{
|
150
|
-
cmds << "#{virtualenv_release_python} --version && #{
|
196
|
+
cmds << "( test -x #{virtualenv_release_pip} || #{virtualenv_release_easy_install_cmd} #{virtualenv_pip_package} )"
|
197
|
+
cmds << "#{virtualenv_release_python} --version && #{virtualenv_release_pip_cmd} --version"
|
198
|
+
cmds << "rsync -lrpt -u #{virtualenv_shared_path}/bin/ #{virtualenv_release_path}/bin/" # copy binaries and scripts from shared virtualenv
|
199
|
+
cmds << "sed -i -e 's|^#!#{virtualenv_shared_path}/bin/python.*$|#!#{virtualenv_release_path}/bin/python|' #{virtualenv_release_path}/bin/*"
|
151
200
|
cmds << "rsync -lrpt #{virtualenv_shared_path}/lib/ #{virtualenv_release_path}/lib/" # copy libraries from shared virtualenv
|
152
201
|
end
|
153
202
|
run(cmds.join(' && '))
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-virtualenv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|