Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 62437f8

Browse files
author
jtimberman
committed
Merge branch 'COOK-1046'
2 parents 2518c2e + 6ff2ba3 commit 62437f8

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

providers/pip.rb

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def current_installed_version
118118
@current_installed_version ||= begin
119119
delimeter = /==/
120120

121-
version_check_cmd = "pip freeze#{expand_virtualenv(can_haz_virtualenv(@new_resource))} | grep -i '^#{@new_resource.package_name}=='"
121+
version_check_cmd = "#{pip_cmd(@new_resource)} freeze | grep -i #{@new_resource.package_name}=="
122122
# incase you upgrade pip with pip!
123123
if @new_resource.package_name.eql?('pip')
124124
delimeter = /\s/
@@ -141,24 +141,20 @@ def candidate_version
141141

142142
def install_package(name, version, timeout)
143143
v = "==#{version}" unless version.eql?('latest')
144-
shell_out!("pip install#{expand_options(@new_resource.options)}#{expand_virtualenv(can_haz_virtualenv(@new_resource))} #{name}#{v}", :timeout => timeout)
144+
shell_out!("#{pip_cmd(@new_resource)} install#{expand_options(@new_resource.options)} #{name}#{v}", :timeout => timeout)
145145
end
146146

147147
def upgrade_package(name, version, timeout)
148148
v = "==#{version}" unless version.eql?('latest')
149-
shell_out!("pip install --upgrade#{expand_options(@new_resource.options)}#{expand_virtualenv(can_haz_virtualenv(@new_resource))} #{@new_resource.name}#{v}", :timeout => timeout)
149+
shell_out!("#{pip_cmd(@new_resource)} install --upgrade#{expand_options(@new_resource.options)} #{@new_resource.name}#{v}", :timeout => timeout)
150150
end
151151

152152
def remove_package(name, version, timeout)
153-
shell_out!("pip uninstall -y#{expand_options(@new_resource.options)}#{expand_virtualenv(can_haz_virtualenv(@new_resource))} #{@new_resource.name}", :timeout => timeout)
154-
end
155-
156-
def expand_virtualenv(virtualenv)
157-
virtualenv && " --environment=#{virtualenv}"
153+
shell_out!("#{pip_cmd(@new_resource)} uninstall -y#{expand_options(@new_resource.options)} #{@new_resource.name}", :timeout => timeout)
158154
end
159155

160156
# TODO remove when provider is moved into Chef core
161157
# this allows PythonPip to work with Chef::Resource::Package
162-
def can_haz_virtualenv(nr)
163-
nr.respond_to?("virtualenv") ? nr.virtualenv : nil
158+
def pip_cmd(nr)
159+
(nr.respond_to?("virtualenv") && nr.virtualenv) ? ::File.join(nr.virtualenv,'/bin/pip') : 'pip'
164160
end

0 commit comments

Comments
 (0)