capistrano-pyenv 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/capistrano-pyenv.gemspec +1 -0
- data/lib/capistrano-pyenv/version.rb +1 -1
- data/lib/capistrano-pyenv.rb +53 -67
- data/test/centos6-64/run.sh +1 -1
- data/test/config/deploy.rb +4 -4
- data/test/precise64/run.sh +1 -1
- metadata +18 -2
data/capistrano-pyenv.gemspec
CHANGED
@@ -16,6 +16,7 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.version = Capistrano::PyEnv::VERSION
|
17
17
|
|
18
18
|
gem.add_dependency("capistrano")
|
19
|
+
gem.add_dependency("capistrano-platform-resources", ">= 0.1.0")
|
19
20
|
gem.add_development_dependency("net-scp", "~> 1.0.4")
|
20
21
|
gem.add_development_dependency("net-ssh", "~> 2.2.2")
|
21
22
|
gem.add_development_dependency("vagrant", "~> 1.0.6")
|
data/lib/capistrano-pyenv.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "capistrano-pyenv/version"
|
2
2
|
require "capistrano/configuration"
|
3
|
+
require "capistrano/configuration/resources/platform_resources"
|
3
4
|
require "capistrano/recipes/deploy/scm"
|
4
5
|
|
5
6
|
module Capistrano
|
@@ -18,7 +19,7 @@ module Capistrano
|
|
18
19
|
File.join(pyenv_bin_path, "pyenv")
|
19
20
|
}
|
20
21
|
def pyenv_command(options={})
|
21
|
-
environment = pyenv_environment
|
22
|
+
environment = _merge_environment(pyenv_environment, options.fetch(:env, {}))
|
22
23
|
environment["PYENV_VERSION"] = options[:version] if options.key?(:version)
|
23
24
|
if environment.empty?
|
24
25
|
pyenv_bin
|
@@ -28,12 +29,10 @@ module Capistrano
|
|
28
29
|
end
|
29
30
|
end
|
30
31
|
_cset(:pyenv_cmd) { pyenv_command(:version => pyenv_python_version) } # this declares PYENV_VERSION.
|
31
|
-
_cset(:pyenv_environment) {
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
}
|
36
|
-
}
|
32
|
+
_cset(:pyenv_environment) {{
|
33
|
+
"PYENV_ROOT" => pyenv_path,
|
34
|
+
"PATH" => [ pyenv_shims_path, pyenv_bin_path, "$PATH" ].join(":"),
|
35
|
+
}}
|
37
36
|
_cset(:pyenv_repository, 'git://github.com/yyuu/pyenv.git')
|
38
37
|
_cset(:pyenv_branch, 'master')
|
39
38
|
|
@@ -54,13 +53,7 @@ module Capistrano
|
|
54
53
|
if pyenv_python_dependencies.empty?
|
55
54
|
false
|
56
55
|
else
|
57
|
-
|
58
|
-
when /(debian|ubuntu)/i
|
59
|
-
capture("dpkg-query -s #{pyenv_python_dependencies.map { |x| x.dump }.join(" ")} 1>/dev/null 2>&1 || echo required")
|
60
|
-
when /redhat/i
|
61
|
-
capture("rpm -qi #{pyenv_python_dependencies.map { |x| x.dump }.join(" ")} 1>/dev/null 2>&1 || echo required")
|
62
|
-
end
|
63
|
-
true and (/required/i =~ status)
|
56
|
+
not(platform.packages.installed?(pyenv_python_dependencies))
|
64
57
|
end
|
65
58
|
}
|
66
59
|
|
@@ -69,6 +62,7 @@ module Capistrano
|
|
69
62
|
#
|
70
63
|
# skip installation if the requested version has been installed.
|
71
64
|
#
|
65
|
+
reset!(:pyenv_python_versions)
|
72
66
|
begin
|
73
67
|
installed = pyenv_python_versions.include?(pyenv_python_version)
|
74
68
|
rescue
|
@@ -123,10 +117,6 @@ module Capistrano
|
|
123
117
|
plugins.update
|
124
118
|
}
|
125
119
|
|
126
|
-
def _setup_default_environment
|
127
|
-
set(:default_environment, default_environment.merge(pyenv_environment))
|
128
|
-
end
|
129
|
-
|
130
120
|
_cset(:pyenv_setup_default_environment) {
|
131
121
|
if exists?(:pyenv_define_default_environment)
|
132
122
|
logger.info(":pyenv_define_default_environment has been deprecated. use :pyenv_setup_default_environment instead.")
|
@@ -138,23 +128,36 @@ module Capistrano
|
|
138
128
|
# workaround for loading `capistrano-rbenv` later than `capistrano/ext/multistage`.
|
139
129
|
# https://github.com/yyuu/capistrano-rbenv/pull/5
|
140
130
|
if top.namespaces.key?(:multistage)
|
141
|
-
after "multistage:ensure"
|
142
|
-
_setup_default_environment if pyenv_setup_default_environment
|
143
|
-
end
|
131
|
+
after "multistage:ensure", "pyenv:setup_default_environmnt"
|
144
132
|
else
|
145
133
|
on :start do
|
146
134
|
if top.namespaces.key?(:multistage)
|
147
135
|
# workaround for loading `capistrano-rbenv` earlier than `capistrano/ext/multistage`.
|
148
136
|
# https://github.com/yyuu/capistrano-rbenv/issues/7
|
149
|
-
after "multistage:ensure"
|
150
|
-
_setup_default_environment if pyenv_setup_default_environment
|
151
|
-
end
|
137
|
+
after "multistage:ensure", "pyenv:setup_default_environment"
|
152
138
|
else
|
153
|
-
|
139
|
+
setup_default_environment
|
154
140
|
end
|
155
141
|
end
|
156
142
|
end
|
157
143
|
|
144
|
+
_cset(:pyenv_environment_join_keys, %w(DYLD_LIBRARY_PATH LD_LIBRARY_PATH MANPATH PATH))
|
145
|
+
def _merge_environment(x, y)
|
146
|
+
x.merge(y) { |key, x_val, y_val|
|
147
|
+
if pyenv_environment_join_keys.key?(key)
|
148
|
+
( y_val.split(":") + x_val.split(":") ).join(":")
|
149
|
+
else
|
150
|
+
y_val
|
151
|
+
end
|
152
|
+
}
|
153
|
+
end
|
154
|
+
|
155
|
+
task(:setup_default_environment, :except => { :no_release => true }) {
|
156
|
+
if pyenv_setup_default_environment
|
157
|
+
set(:default_environment, _merge_environment(default_environment, pyenv_environment))
|
158
|
+
end
|
159
|
+
}
|
160
|
+
|
158
161
|
desc("Purge pyenv.")
|
159
162
|
task(:purge, :except => { :no_release => true }) {
|
160
163
|
run("rm -rf #{pyenv_path.dump}")
|
@@ -248,46 +251,25 @@ module Capistrano
|
|
248
251
|
end
|
249
252
|
}
|
250
253
|
|
251
|
-
_cset(:pyenv_platform) {
|
252
|
-
capture((<<-EOS).gsub(/\s+/, ' ')).strip
|
253
|
-
if test -f /etc/debian_version; then
|
254
|
-
if test -f /etc/lsb-release && grep -i -q DISTRIB_ID=Ubuntu /etc/lsb-release; then
|
255
|
-
echo ubuntu;
|
256
|
-
else
|
257
|
-
echo debian;
|
258
|
-
fi;
|
259
|
-
elif test -f /etc/redhat-release; then
|
260
|
-
echo redhat;
|
261
|
-
else
|
262
|
-
echo unknown;
|
263
|
-
fi;
|
264
|
-
EOS
|
265
|
-
}
|
254
|
+
_cset(:pyenv_platform) { fetch(:platform_identifier) }
|
266
255
|
_cset(:pyenv_python_dependencies) {
|
267
|
-
case pyenv_platform
|
268
|
-
when
|
256
|
+
case pyenv_platform.to_sym
|
257
|
+
when :debian, :ubuntu
|
269
258
|
%w(git-core build-essential libreadline6-dev zlib1g-dev libssl-dev)
|
270
|
-
when
|
259
|
+
when :redhat, :centos
|
271
260
|
%w(git-core autoconf glibc-devel patch readline readline-devel zlib zlib-devel openssl)
|
272
261
|
else
|
273
262
|
[]
|
274
263
|
end
|
275
264
|
}
|
276
265
|
task(:dependencies, :except => { :no_release => true }) {
|
277
|
-
|
278
|
-
case pyenv_platform
|
279
|
-
when /(debian|ubuntu)/i
|
280
|
-
run("#{sudo} apt-get install -q -y #{pyenv_python_dependencies.map { |x| x.dump }.join(" ")}")
|
281
|
-
when /redhat/i
|
282
|
-
run("#{sudo} yum install -q -y #{pyenv_python_dependencies.map { |x| x.dump }.join(" ")}")
|
283
|
-
end
|
284
|
-
end
|
266
|
+
platform.packages.install(pyenv_python_dependencies)
|
285
267
|
}
|
286
268
|
|
287
269
|
_cset(:pyenv_python_versions) { pyenv.versions }
|
288
270
|
desc("Build python within pyenv.")
|
289
271
|
task(:build, :except => { :no_release => true }) {
|
290
|
-
|
272
|
+
# reset!(:pyenv_python_versions)
|
291
273
|
python = fetch(:pyenv_python_cmd, "python")
|
292
274
|
if pyenv_use_virtualenv
|
293
275
|
if pyenv_virtualenv_python_version != "system" and not pyenv_python_versions.include?(pyenv_virtualenv_python_version)
|
@@ -313,31 +295,35 @@ module Capistrano
|
|
313
295
|
invoke_command("#{pyenv_command} global #{version.dump}", options)
|
314
296
|
end
|
315
297
|
|
316
|
-
def
|
298
|
+
def invoke_command_with_path(cmdline, options={})
|
317
299
|
path = options.delete(:path)
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
300
|
+
if path
|
301
|
+
chdir = "cd #{path.dump}"
|
302
|
+
via = options.delete(:via)
|
303
|
+
# as of Capistrano 2.14.2, `sudo()` cannot handle multiple command correctly.
|
304
|
+
if via == :sudo
|
305
|
+
invoke_command("#{chdir} && #{sudo} #{cmdline}", options)
|
306
|
+
else
|
307
|
+
invoke_command("#{chdir} && #{cmdline}", options.merge(:via => via))
|
308
|
+
end
|
309
|
+
else
|
310
|
+
invoke_command(cmdline, options)
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
def local(version, options={})
|
315
|
+
invoke_command_with_path("#{pyenv_command} local #{version.dump}", options)
|
322
316
|
end
|
323
317
|
|
324
318
|
def which(command, options={})
|
325
|
-
path = options.delete(:path)
|
326
319
|
version = ( options.delete(:version) || pyenv_python_version )
|
327
|
-
|
328
|
-
execute << "cd #{path.dump}" if path
|
329
|
-
execute << "#{pyenv_command(:version => version)} which #{command.dump}"
|
330
|
-
capture(execute.join(" && "), options).strip
|
320
|
+
invoke_command_with_path("#{pyenv_command(:version => version)} which #{command.dump}", options)
|
331
321
|
end
|
332
322
|
|
333
323
|
def exec(command, options={})
|
334
324
|
# users of pyenv.exec must sanitize their command line.
|
335
|
-
path = options.delete(:path)
|
336
325
|
version = ( options.delete(:version) || pyenv_python_version )
|
337
|
-
|
338
|
-
execute << "cd #{path.dump}" if path
|
339
|
-
execute << "#{pyenv_command(:version => version)} exec #{command}"
|
340
|
-
invoke_command(execute.join(" && "), options)
|
326
|
+
invoke_command_with_path("#{pyenv_command(:version => version)} exec #{command}", options)
|
341
327
|
end
|
342
328
|
|
343
329
|
def versions(options={})
|
data/test/centos6-64/run.sh
CHANGED
data/test/config/deploy.rb
CHANGED
@@ -57,10 +57,10 @@ namespace(:test_default) {
|
|
57
57
|
pyenv.exec("python -c 'import os;assert os.getcwd()==\"/\"'", :path => "/")
|
58
58
|
}
|
59
59
|
|
60
|
-
|
61
|
-
#
|
62
|
-
|
63
|
-
|
60
|
+
task(:test_pyenv_exec_python_via_sudo_with_path) {
|
61
|
+
# capistrano does not provide safer way to invoke multiple commands via sudo.
|
62
|
+
pyenv.exec("python -c 'import os;assert os.getcwd()==\"/\" and os.getuid()==0'", :path => "/", :via => :sudo )
|
63
|
+
}
|
64
64
|
|
65
65
|
## via sudo
|
66
66
|
task(:test_pyenv_exec_via_sudo) {
|
data/test/precise64/run.sh
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-pyenv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
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: 2013-03-
|
12
|
+
date: 2013-03-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: capistrano-platform-resources
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.1.0
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.1.0
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: net-scp
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|