lib/capistrano-virtualenv/deploy.rb in capistrano-virtualenv-0.0.2 vs lib/capistrano-virtualenv/deploy.rb in capistrano-virtualenv-0.0.3
- old
+ new
@@ -1,7 +1,6 @@
-require 'tempfile'
require 'uri'
module Capistrano
module Virtualenv
def self.extended(configuration)
@@ -32,10 +31,11 @@
_cset(:virtualenv_pip_package, 'pip')
_cset(:virtualenv_requirements, []) # primary package list
_cset(:virtualenv_requirements_file) { # secondary package list
File.join(release_path, 'requirements.txt')
}
+ _cset(:virtualenv_build_requirements, {})
_cset(:virtualenv_install_packages, []) # apt packages
## shared virtualenv:
## - created in shared_path
## - to be used to share libs between releases
@@ -173,14 +173,24 @@
}
after 'deploy:finalize_update', 'virtualenv:update'
task(:update_shared, :except => { :no_release => true }) {
unless virtualenv_requirements.empty?
- tempfile = Tempfile.new(File.basename($0))
- top.put(virtualenv_requirements.join("\n"), tempfile.path)
- run("diff -u #{virtualenv_requirements_file} #{tempfile.path} || mv -f #{tempfile.path} #{virtualenv_requirements_file}; rm -f #{tempfile.path}")
+ tempfile = "/tmp/requirements.txt.#{$$}"
+ begin
+ top.put(virtualenv_requirements.join("\n"), tempfile)
+ run("diff -u #{virtualenv_requirements_file} #{tempfile} || mv -f #{tempfile} #{virtualenv_requirements_file}")
+ ensure
+ run("rm -f #{tempfile}")
+ end
end
run("touch #{virtualenv_requirements_file} && #{virtualenv_shared_pip_cmd} install #{virtualenv_pip_install_options.join(' ')} -r #{virtualenv_requirements_file}")
+
+ execute = virtualenv_build_requirements.map { |package, options|
+ build_options = ( options || [] )
+ "#{virtualenv_shared_pip_cmd} install #{virtualenv_pip_install_options.join(' ')} #{build_options.join(' ')} #{package.dump}"
+ }
+ run(execute.join(' && ')) unless execute.empty?
}
task(:create_release, :except => { :no_release => true }) {
dirs = [ File.dirname(virtualenv_release_path) ].uniq()
cmds = [ ]