5 # Copyright:: 2017, OpenStreetMap Foundation
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # https://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
22 default_action :install
24 property :package_name, :kind_of => String, :name_property => true
25 property :version, :kind_of => String
26 property :python_version, :kind_of => String
27 property :python_virtualenv, :kind_of => String
28 property :extra_index_url, :kind_of => String
31 if new_resource.version.nil?
32 execute "pip-install-#{new_resource.package_name}" do
33 command "#{pip_command} install #{pip_extra_index} #{new_resource.package_name}"
34 not_if "#{pip_command} show #{new_resource.package_name}"
37 execute "pip-install-#{new_resource.package_name}" do
38 command "#{pip_command} install #{pip_extra_index} #{new_resource.package_name}==#{new_resource.version}"
39 not_if "#{pip_command} show #{new_resource.package_name} | fgrep -q #{new_resource.version}"
45 if new_resource.version.nil?
46 execute "pip-upgrade-#{new_resource.package_name}" do
47 command "#{pip_command} install #{pip_extra_index} --upgrade #{new_resource.package_name}"
48 only_if "#{pip_command} list --outdated | fgrep -q #{new_resource.package_name}"
51 execute "pip-upgrade-#{new_resource.package_name}" do
52 command "#{pip_command} install #{pip_extra_index} --upgrade #{new_resource.package_name}==#{new_resource.version}"
53 not_if "#{pip_command} show #{new_resource.package_name} | fgrep -q #{new_resource.version}"
59 execute "pip-uninstall-#{new_resource.package_name}" do
60 command "#{pip_command} uninstall #{new_resource.package_name}"
61 only_if "#{pip_command} show #{new_resource.package_name}"
67 if new_resource.extra_index_url
68 "--extra-index-url '#{new_resource.extra_index_url}'"
73 if new_resource.python_virtualenv
74 "#{new_resource.python_virtualenv}/bin/pip"
76 "pip#{new_resource.python_version}"