-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new resource: 'conda_package', with tests
- Loading branch information
Showing
13 changed files
with
205 additions
and
6 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 |
---|---|---|
@@ -1,5 +1,11 @@ | ||
# CHANGELOG | ||
|
||
## 0.3.0 | ||
|
||
## 0.2.1 | ||
|
||
Fix incorrect checksums for Anaconda 2.0.1 | ||
|
||
## 0.2.0 | ||
|
||
Feature improvments: | ||
|
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
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
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
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 |
---|---|---|
@@ -1,5 +1,15 @@ | ||
if defined?(ChefSpec) | ||
|
||
def run_bash(resource_name) | ||
ChefSpec::Matchers::ResourceMatcher.new('bash', :run, resource_name) | ||
end | ||
|
||
def install_conda_package(resource_name) | ||
ChefSpec::Matchers::ResourceMatcher.new('anaconda_package', :install, resource_name) | ||
end | ||
|
||
def remove_conda_package(resource_name) | ||
ChefSpec::Matchers::ResourceMatcher.new('anaconda_package', :remove, resource_name) | ||
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,84 @@ | ||
def whyrun_supported? | ||
true | ||
end | ||
|
||
def cmd_conda | ||
"#{node.anaconda.install_root}/#{node.anaconda.version}/bin/conda" | ||
end | ||
|
||
def is_installed?(package_name) | ||
`"#{cmd_conda}" list`.include?(package_name) | ||
end | ||
|
||
def log_opts(node) | ||
if node.anaconda.install_log | ||
"2>&1 >#{node.anaconda.install_log}" | ||
else | ||
'' | ||
end | ||
end | ||
|
||
action :install do | ||
r = new_resource | ||
name = r.name | ||
package_name = r.package_name || name | ||
|
||
Chef::Log.info "installing conda package: #{package_name}" | ||
|
||
cmd_opts = [ | ||
# --yes: automated install (don't ask) | ||
"--yes", | ||
|
||
r.env_name ? "--name #{r.env_name}" : '', | ||
r.env_path_prefix ? "--name #{r.env_path_prefix}" : '', | ||
|
||
r.channel ? "--channel #{r.channel}" : '', | ||
r.override_channels ? '--override-channels' : '', | ||
|
||
r.no_pin ? '--no-pin' : '', | ||
|
||
r.force_install ? '--force' : '', | ||
|
||
r.revision ? "--revision #{r.revision}" : '', | ||
r.file ? "--file #{r.file}" : '', | ||
r.unknown ? '--unknown' : '', | ||
r.no_deps ? '--no_deps' : '', | ||
r.mkdir ? '--mkdir' : '', | ||
r.use_index_cache ? '--use-index-cache' : '', | ||
r.use_local ? '--use-local' : '', | ||
r.alt_hint ? '--alt-hint' : '', | ||
].join(" ") | ||
|
||
execute "conda_package_install_#{package_name}" do | ||
command "#{cmd_conda} install #{package_name} #{cmd_opts} #{log_opts(node)}" | ||
only_if { !is_installed?(package_name) || r.force_install } | ||
end | ||
end | ||
|
||
action :remove do | ||
r = new_resource | ||
name = r.name | ||
package_name = r.package_name || name | ||
|
||
Chef::Log.info "removing conda package: #{package_name}" | ||
|
||
cmd_opts = [ | ||
# --yes: automated install (don't ask) | ||
"--yes", | ||
|
||
r.env_name ? "--name #{r.env_name}" : '', | ||
r.env_path_prefix ? "--name #{r.env_path_prefix}" : '', | ||
|
||
r.channel ? "--channel #{r.channel}" : '', | ||
r.override_channels ? '--override-channels' : '', | ||
|
||
r.no_pin ? '--no-pin' : '', | ||
|
||
r.all ? '--all' : '', | ||
r.features ? '--features' : '', | ||
].join(' ') | ||
|
||
execute "conda_package_remove_#{package_name}" do | ||
command "#{cmd_conda} remove #{package_name} #{cmd_opts} #{log_opts(node)}" | ||
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,20 @@ | ||
# | ||
# Cookbook Name:: anaconda | ||
# Recipe:: package_tests | ||
# | ||
# Copyright (C) 2014 Matt Chu | ||
# | ||
# All rights reserved - Do Not Redistribute | ||
# | ||
|
||
log 'do NOT include this in your runlist! for testing only.' do | ||
level :error | ||
end | ||
|
||
anaconda_package 'astroid' do | ||
action :install | ||
end | ||
|
||
anaconda_package 'astroid' do | ||
action :remove | ||
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,17 @@ | ||
# | ||
# Cookbook Name:: anaconda | ||
# Recipe:: shell-conveniences | ||
# | ||
# Copyright (C) 2014 Matt Chu | ||
# | ||
# All rights reserved - Do Not Redistribute | ||
# | ||
|
||
template "#{node.anaconda.home}/source-me.sh" do | ||
source 'source-me.sh.erb' | ||
variables({ | ||
:install_root => node.anaconda.install_root, | ||
:version => node.anaconda.version, | ||
}) | ||
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,34 @@ | ||
actions :install, :remove | ||
default_action :install | ||
|
||
attribute :name, :kind_of => String, :name_attribute => true | ||
|
||
# attributes for both install and remove | ||
|
||
attribute :package_name, :kind_of => String | ||
|
||
attribute :env_name, :kind_of => String | ||
attribute :env_path_prefix, :kind_of => String | ||
|
||
attribute :channel, :kind_of => String | ||
attribute :override_channels, :kind_of => [ TrueClass, FalseClass ] | ||
|
||
attribute :no_pin, :kind_of => [ TrueClass, FalseClass ] | ||
|
||
# attributes for install only | ||
|
||
attribute :force_install, :kind_of => [ TrueClass, FalseClass ] | ||
|
||
attribute :revision, :kind_of => String | ||
attribute :file, :kind_of => String | ||
attribute :unknown, :kind_of => [ TrueClass, FalseClass ] | ||
attribute :no_deps, :kind_of => [ TrueClass, FalseClass ] | ||
attribute :mkdir, :kind_of => [ TrueClass, FalseClass ] | ||
attribute :use_index_cache, :kind_of => [ TrueClass, FalseClass ] | ||
attribute :use_local, :kind_of => [ TrueClass, FalseClass ] | ||
attribute :alt_hint, :kind_of => [ TrueClass, FalseClass ] | ||
|
||
# attributes for remove only | ||
|
||
attribute :all, :kind_of => [ TrueClass, FalseClass ] | ||
attribute :features, :kind_of => [ TrueClass, FalseClass ] |
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
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
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,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
export PATH=<%= @install_root %>/<%= @version %>/bin:${PATH} |
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