X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/06b8c2609dac3b834dcf33af1f394354771a3fa5..b0d9abfbd0d3b78db57f09a8976b10a446542a99:/cookbooks/python/resources/package.rb diff --git a/cookbooks/python/resources/package.rb b/cookbooks/python/resources/package.rb index 76a6af7ec..d6431c87d 100644 --- a/cookbooks/python/resources/package.rb +++ b/cookbooks/python/resources/package.rb @@ -21,24 +21,29 @@ default_action :install property :package_name, :kind_of => String, :name_property => true property :version, :kind_of => String +property :python_version, :kind_of => String action :install do if version.nil? execute "pip-install-#{name}" do - command "pip install #{new_resource.package_name}" - not_if "pip show #{new_resource.package_name}" + command "#{pip_command} install #{new_resource.package_name}" + not_if "#{pip_command} show #{new_resource.package_name}" end else execute "pip-install-#{name}" do - command "pip install #{new_resource.package_name}==#{new_resource.version}" - not_if "pip show #{new_resource.package_name} | fgrep -q #{new_resource.version}" + command "#{pip_command} install #{new_resource.package_name}==#{new_resource.version}" + not_if "#{pip_command} show #{new_resource.package_name} | fgrep -q #{new_resource.version}" end end end action :remove do execute "pip-uninstall-#{name}" do - command "pip uninstall #{new_resource.package_name}" - only_if "pip show #{new_resource.package_name}" + command "#{pip_command} uninstall #{new_resource.package_name}" + only_if "#{pip_command} show #{new_resource.package_name}" end end + +def pip_command + "pip#{python_version}" +end