Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yamashita Yuu
committed
Sep 19, 2012
0 parents
commit 308f28e
Showing
9 changed files
with
240 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
*.gem | ||
*.rbc | ||
.bundle | ||
.config | ||
.yardoc | ||
Gemfile.lock | ||
InstalledFiles | ||
_yardoc | ||
coverage | ||
doc/ | ||
lib/bundler/man | ||
pkg | ||
rdoc | ||
spec/reports | ||
test/tmp | ||
test/version_tmp | ||
tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source 'https://rubygems.org' | ||
|
||
# Specify your gem's dependencies in capistrano-pyenv.gemspec | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright (c) 2012 Yamashita Yuu | ||
|
||
MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# capistrano-pyenv | ||
|
||
a capistrano recipe to manage pythons with [pyenv](https://github.com/yyuu/pyenv). | ||
|
||
## Installation | ||
|
||
Add this line to your application's Gemfile: | ||
|
||
gem 'capistrano-pyenv' | ||
|
||
And then execute: | ||
|
||
$ bundle | ||
|
||
Or install it yourself as: | ||
|
||
$ gem install capistrano-pyenv | ||
|
||
## Usage | ||
|
||
This recipe will install [pyenv](https://github.com/yyuu/pyenv) during `deploy:setup` task. | ||
|
||
To setup pyenv for your application, add following in you `config/deploy.rb`. | ||
|
||
# in "config/deploy.rb" | ||
require 'capistrano-pyenv' | ||
|
||
Following options are available to manage your pyenv. | ||
|
||
* `:pyenv_branch` - the git branch to install `pyenv` from. use `master` by default. | ||
* `:pyenv_cmd` - the `pyenv` command. | ||
* `:pyenv_path` - the path where `pyenv` will be installed. use `$HOME/.pyenv` by default. | ||
* `:pyenv_plugins_options` - install options for pyenv plugins. | ||
* `:pyenv_plugins` - pyenv plugins to install. do nothing by default. | ||
* `:pyenv_repository` - repository URL of pyenv. | ||
* `:pyenv_python_dependencies` - depedency packages. | ||
* `:pyenv_python_version` - the python version to install. install `2.7.3` by default. | ||
|
||
## Contributing | ||
|
||
1. Fork it | ||
2. Create your feature branch (`git checkout -b my-new-feature`) | ||
3. Commit your changes (`git commit -am 'Added some feature'`) | ||
4. Push to the branch (`git push origin my-new-feature`) | ||
5. Create new Pull Request | ||
|
||
## Author | ||
|
||
- YAMASHITA Yuu (https://github.com/yyuu) | ||
- Geisha Tokyo Entertainment Inc. (http://www.geishatokyo.com/) | ||
|
||
## License | ||
|
||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require "bundler/gem_tasks" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- encoding: utf-8 -*- | ||
require File.expand_path('../lib/capistrano-pyenv/version', __FILE__) | ||
|
||
Gem::Specification.new do |gem| | ||
gem.authors = ["Yamashita Yuu"] | ||
gem.email = ["yamashita@geishatokyo.com"] | ||
gem.description = %q{a capistrano recipe to manage pythons with pyenv.} | ||
gem.summary = %q{a capistrano recipe to manage pythons with pyenv.} | ||
gem.homepage = "https://github.com/yyuu/capistrano-pyenv" | ||
|
||
gem.files = `git ls-files`.split($\) | ||
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } | ||
gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) | ||
gem.name = "capistrano-pyenv" | ||
gem.require_paths = ["lib"] | ||
gem.version = Capistrano::PyEnv::VERSION | ||
|
||
gem.add_dependency("capistrano") | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require "capistrano-pyenv/deploy" | ||
require "capistrano-pyenv/version" | ||
|
||
module Capistrano | ||
module Pyenv | ||
# Your code goes here... | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
module Capistrano | ||
module PyEnv | ||
def self.extended(configuration) | ||
configuration.load { | ||
namespace(:pyenv) { | ||
_cset(:pyenv_path) { | ||
capture("echo $HOME/.pyenv").chomp() | ||
} | ||
_cset(:pyenv_bin) { | ||
File.join(pyenv_path, 'bin', 'pyenv') | ||
} | ||
_cset(:pyenv_cmd) { # to use custom pyenv_path, we use `env` instead of cap's default_environment. | ||
path = "#{pyenv_path}/bin:#{pyenv_path}/shims:$PATH" | ||
"env PATH=#{path.dump()} #{pyenv_bin}" | ||
} | ||
_cset(:pyenv_repository, 'git://github.com/yyuu/pyenv.git') | ||
_cset(:pyenv_branch, 'master') | ||
|
||
_cset(:pyenv_plugins, {}) | ||
_cset(:pyenv_plugins_options, {}) | ||
_cset(:pyenv_plugins_path) { | ||
File.join(pyenv_path, 'plugins') | ||
} | ||
|
||
_cset(:pyenv_git) { | ||
if scm == :git | ||
if fetch(:scm_command, :default) == :default | ||
fetch(:git, 'git') | ||
else | ||
scm_command | ||
end | ||
else | ||
fetch(:git, 'git') | ||
end | ||
} | ||
|
||
_cset(:pyenv_python_version, '2.7.3') | ||
_cset(:pyenv_python_dependencies, %w(build-essential libreadline6-dev zlib1g-dev libssl-dev)) | ||
|
||
desc("Setup pyenv.") | ||
task(:setup, :except => { :no_release => true }) { | ||
dependencies | ||
update | ||
configure | ||
build | ||
} | ||
after 'deploy:setup', 'pyenv:setup' | ||
|
||
def _pyenv_sync(repository, destination, revision) | ||
git = pyenv_git | ||
remote = 'origin' | ||
verbose = "-q" | ||
run((<<-E).gsub(/\s+/, ' ')) | ||
if test -d #{destination}; then | ||
cd #{destination} && #{git} fetch #{verbose} #{remote} && #{git} fetch --tags #{verbose} #{remote} && #{git} merge #{verbose} #{remote}/#{revision}; | ||
else | ||
#{git} clone #{verbose} #{repository} #{destination} && cd #{destination} && #{git} checkout #{verbose} #{revision}; | ||
fi; | ||
E | ||
end | ||
|
||
desc("Update pyenv installation.") | ||
task(:update, :except => { :no_release => true }) { | ||
_pyenv_sync(pyenv_repository, pyenv_path, pyenv_branch) | ||
plugins.update | ||
} | ||
|
||
desc("Purge pyenv.") | ||
task(:purge, :except => { :no_release => true }) { | ||
run("rm -rf #{pyenv_path}") | ||
} | ||
|
||
namespace(:plugins) { | ||
desc("Update pyenv plugins.") | ||
task(:update, :except => { :no_release => true }) { | ||
pyenv_plugins.each { |name, repository| | ||
options = ( pyenv_plugins_options[name] || {}) | ||
branch = ( options[:branch] || 'master' ) | ||
_pyenv_sync(repository, File.join(pyenv_plugins_path, name), branch) | ||
} | ||
} | ||
} | ||
|
||
task(:configure, :except => { :no_release => true }) { | ||
# nop | ||
} | ||
|
||
task(:dependencies, :except => { :no_release => true }) { | ||
unless pyenv_python_dependencies.empty? # dpkg-query is faster than apt-get on querying if packages are installed | ||
run("dpkg-query --show #{pyenv_python_dependencies.join(' ')} 2>/dev/null || #{sudo} apt-get -y install #{pyenv_python_dependencies.join(' ')}") | ||
end | ||
} | ||
|
||
desc("Build python within pyenv.") | ||
task(:build, :except => { :no_release => true }) { | ||
python = fetch(:pyenv_python_cmd, 'python') | ||
run("#{pyenv_cmd} whence #{python} | grep -q #{pyenv_python_version} || #{pyenv_cmd} install #{pyenv_python_version}") | ||
run("#{pyenv_cmd} global #{pyenv_python_version} && #{pyenv_cmd} exec #{python} --version") | ||
} | ||
} | ||
} | ||
end | ||
end | ||
end | ||
|
||
if Capistrano::Configuration.instance | ||
Capistrano::Configuration.instance.extend(Capistrano::PyEnv) | ||
end | ||
|
||
# vim:set ft=ruby ts=2 sw=2 : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Capistrano | ||
module PyEnv | ||
VERSION = "0.0.1git" | ||
end | ||
end |