capistrano-pyenv 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-pyenv.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Yamashita Yuu
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # capistrano-pyenv
2
+
3
+ a capistrano recipe to manage pythons with [pyenv](https://github.com/yyuu/pyenv).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'capistrano-pyenv'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install capistrano-pyenv
18
+
19
+ ## Usage
20
+
21
+ This recipe will install [pyenv](https://github.com/yyuu/pyenv) during `deploy:setup` task.
22
+
23
+ To setup pyenv for your application, add following in you `config/deploy.rb`.
24
+
25
+ # in "config/deploy.rb"
26
+ require 'capistrano-pyenv'
27
+
28
+ Following options are available to manage your pyenv.
29
+
30
+ * `:pyenv_branch` - the git branch to install `pyenv` from. use `master` by default.
31
+ * `:pyenv_cmd` - the `pyenv` command.
32
+ * `:pyenv_path` - the path where `pyenv` will be installed. use `$HOME/.pyenv` by default.
33
+ * `:pyenv_plugins_options` - install options for pyenv plugins.
34
+ * `:pyenv_plugins` - pyenv plugins to install. do nothing by default.
35
+ * `:pyenv_repository` - repository URL of pyenv.
36
+ * `:pyenv_python_dependencies` - depedency packages.
37
+ * `:pyenv_python_version` - the python version to install. install `2.7.3` by default.
38
+
39
+ ## Contributing
40
+
41
+ 1. Fork it
42
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
43
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
44
+ 4. Push to the branch (`git push origin my-new-feature`)
45
+ 5. Create new Pull Request
46
+
47
+ ## Author
48
+
49
+ - YAMASHITA Yuu (https://github.com/yyuu)
50
+ - Geisha Tokyo Entertainment Inc. (http://www.geishatokyo.com/)
51
+
52
+ ## License
53
+
54
+ MIT
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/capistrano-pyenv/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Yamashita Yuu"]
6
+ gem.email = ["yamashita@geishatokyo.com"]
7
+ gem.description = %q{a capistrano recipe to manage pythons with pyenv.}
8
+ gem.summary = %q{a capistrano recipe to manage pythons with pyenv.}
9
+ gem.homepage = "https://github.com/yyuu/capistrano-pyenv"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "capistrano-pyenv"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Capistrano::PyEnv::VERSION
17
+
18
+ gem.add_dependency("capistrano")
19
+ end
@@ -0,0 +1,110 @@
1
+ module Capistrano
2
+ module PyEnv
3
+ def self.extended(configuration)
4
+ configuration.load {
5
+ namespace(:pyenv) {
6
+ _cset(:pyenv_path) {
7
+ capture("echo $HOME/.pyenv").chomp()
8
+ }
9
+ _cset(:pyenv_bin) {
10
+ File.join(pyenv_path, 'bin', 'pyenv')
11
+ }
12
+ _cset(:pyenv_cmd) { # to use custom pyenv_path, we use `env` instead of cap's default_environment.
13
+ path = "#{pyenv_path}/bin:#{pyenv_path}/shims:$PATH"
14
+ "env PATH=#{path.dump()} #{pyenv_bin}"
15
+ }
16
+ _cset(:pyenv_repository, 'git://github.com/yyuu/pyenv.git')
17
+ _cset(:pyenv_branch, 'master')
18
+
19
+ _cset(:pyenv_plugins, {})
20
+ _cset(:pyenv_plugins_options, {})
21
+ _cset(:pyenv_plugins_path) {
22
+ File.join(pyenv_path, 'plugins')
23
+ }
24
+
25
+ _cset(:pyenv_git) {
26
+ if scm == :git
27
+ if fetch(:scm_command, :default) == :default
28
+ fetch(:git, 'git')
29
+ else
30
+ scm_command
31
+ end
32
+ else
33
+ fetch(:git, 'git')
34
+ end
35
+ }
36
+
37
+ _cset(:pyenv_python_version, '2.7.3')
38
+ _cset(:pyenv_python_dependencies, %w(build-essential libreadline6-dev zlib1g-dev libssl-dev))
39
+
40
+ desc("Setup pyenv.")
41
+ task(:setup, :except => { :no_release => true }) {
42
+ dependencies
43
+ update
44
+ configure
45
+ build
46
+ }
47
+ after 'deploy:setup', 'pyenv:setup'
48
+
49
+ def _pyenv_sync(repository, destination, revision)
50
+ git = pyenv_git
51
+ remote = 'origin'
52
+ verbose = "-q"
53
+ run((<<-E).gsub(/\s+/, ' '))
54
+ if test -d #{destination}; then
55
+ cd #{destination} && #{git} fetch #{verbose} #{remote} && #{git} fetch --tags #{verbose} #{remote} && #{git} merge #{verbose} #{remote}/#{revision};
56
+ else
57
+ #{git} clone #{verbose} #{repository} #{destination} && cd #{destination} && #{git} checkout #{verbose} #{revision};
58
+ fi;
59
+ E
60
+ end
61
+
62
+ desc("Update pyenv installation.")
63
+ task(:update, :except => { :no_release => true }) {
64
+ _pyenv_sync(pyenv_repository, pyenv_path, pyenv_branch)
65
+ plugins.update
66
+ }
67
+
68
+ desc("Purge pyenv.")
69
+ task(:purge, :except => { :no_release => true }) {
70
+ run("rm -rf #{pyenv_path}")
71
+ }
72
+
73
+ namespace(:plugins) {
74
+ desc("Update pyenv plugins.")
75
+ task(:update, :except => { :no_release => true }) {
76
+ pyenv_plugins.each { |name, repository|
77
+ options = ( pyenv_plugins_options[name] || {})
78
+ branch = ( options[:branch] || 'master' )
79
+ _pyenv_sync(repository, File.join(pyenv_plugins_path, name), branch)
80
+ }
81
+ }
82
+ }
83
+
84
+ task(:configure, :except => { :no_release => true }) {
85
+ # nop
86
+ }
87
+
88
+ task(:dependencies, :except => { :no_release => true }) {
89
+ unless pyenv_python_dependencies.empty? # dpkg-query is faster than apt-get on querying if packages are installed
90
+ run("dpkg-query --show #{pyenv_python_dependencies.join(' ')} 2>/dev/null || #{sudo} apt-get -y install #{pyenv_python_dependencies.join(' ')}")
91
+ end
92
+ }
93
+
94
+ desc("Build python within pyenv.")
95
+ task(:build, :except => { :no_release => true }) {
96
+ python = fetch(:pyenv_python_cmd, 'python')
97
+ run("#{pyenv_cmd} whence #{python} | grep -q #{pyenv_python_version} || #{pyenv_cmd} install #{pyenv_python_version}")
98
+ run("#{pyenv_cmd} global #{pyenv_python_version} && #{pyenv_cmd} exec #{python} --version")
99
+ }
100
+ }
101
+ }
102
+ end
103
+ end
104
+ end
105
+
106
+ if Capistrano::Configuration.instance
107
+ Capistrano::Configuration.instance.extend(Capistrano::PyEnv)
108
+ end
109
+
110
+ # vim:set ft=ruby ts=2 sw=2 :
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module PyEnv
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ require "capistrano-pyenv/deploy"
2
+ require "capistrano-pyenv/version"
3
+
4
+ module Capistrano
5
+ module Pyenv
6
+ # Your code goes here...
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-pyenv
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Yamashita Yuu
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-19 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: capistrano
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: a capistrano recipe to manage pythons with pyenv.
31
+ email:
32
+ - yamashita@geishatokyo.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - Gemfile
39
+ - LICENSE.txt
40
+ - README.md
41
+ - Rakefile
42
+ - capistrano-pyenv.gemspec
43
+ - lib/capistrano-pyenv.rb
44
+ - lib/capistrano-pyenv/deploy.rb
45
+ - lib/capistrano-pyenv/version.rb
46
+ homepage: https://github.com/yyuu/capistrano-pyenv
47
+ licenses: []
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubyforge_project:
66
+ rubygems_version: 1.8.23
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: a capistrano recipe to manage pythons with pyenv.
70
+ test_files: []