Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pip installer. #206

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions lib/sprinkle/installers/pip.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
module Sprinkle
module Installers
# The pip package installer installs Python packages.
#
#
# == Example Usage
#
# A simple installation:
#
# package :magic_beans do
# description "Beans beans they're good for your heart..."
# pip 'magic_beans'
# end
#
# You may also specify multiple packages as an array:
#
# package :magic_beans do
# pip %w(magic_beans magic_sauce)
# end
#
class Pip < Installer

##
# installs the pip packages passed
# :method: pip
# :call-seq: pip(*packages)
auto_api

verify_api do
def has_pip(package)
@commands << "pip show #{package} | fgrep Name"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer grep -F and lets match 'Name:' with the colon to be clearer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New commits pushed uses grep -F instead of fgrep,
with comments on matching pattern.

end
end

protected

def install_commands #:nodoc:
cmd = "#{sudo_cmd}pip install #{@packages.join(' ')}"
end

end
end
end