puppet-pip 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/puppet/provider/package/pip.rb +70 -0
- metadata +80 -0
@@ -0,0 +1,70 @@
|
|
1
|
+
# Puppet package provider for Python's `pip` package management
|
2
|
+
# frontend.
|
3
|
+
# <http://pip.openplans.org/>
|
4
|
+
|
5
|
+
require 'puppet/provider/package'
|
6
|
+
|
7
|
+
Puppet::Type.type(:package).provide :pip,
|
8
|
+
:parent => ::Puppet::Provider::Package do
|
9
|
+
|
10
|
+
desc "Python packages via `pip`."
|
11
|
+
|
12
|
+
has_feature :installable, :uninstallable, :versionable
|
13
|
+
|
14
|
+
# Enabling :upgradable and thus the ability to `ensure => latest`
|
15
|
+
# will require talking to the PyPI XMLRPC interface because the
|
16
|
+
# only way to figure out what the latest version number is from
|
17
|
+
# the CLI is to download and unpack it.
|
18
|
+
# <http://wiki.python.org/moin/PyPiXmlRpc>
|
19
|
+
#has_feature :upgradeable
|
20
|
+
|
21
|
+
if pathname = `which pip`.chomp
|
22
|
+
commands :pip => pathname
|
23
|
+
else
|
24
|
+
raise NotImplementedError
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.parse(line)
|
28
|
+
if line.chomp =~ /^([^=]+)==([^=]+)$/
|
29
|
+
{:ensure => $2, :name => $1, :provider => name}
|
30
|
+
else
|
31
|
+
nil
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.instances
|
36
|
+
packages = []
|
37
|
+
execpipe "#{command :pip} freeze" do |process|
|
38
|
+
process.collect do |line|
|
39
|
+
next unless options = parse(line)
|
40
|
+
packages << new(options)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
packages
|
44
|
+
end
|
45
|
+
|
46
|
+
def query
|
47
|
+
execpipe "#{command :pip} freeze" do |process|
|
48
|
+
process.each do |line|
|
49
|
+
options = self.class.parse(line)
|
50
|
+
return options if options[:name] == @resource[:name]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
nil
|
54
|
+
end
|
55
|
+
|
56
|
+
def install
|
57
|
+
arg = @resource[:name]
|
58
|
+
if String === @resource[:ensure]
|
59
|
+
arg = "#{arg}==#{@resource[:ensure]}"
|
60
|
+
end
|
61
|
+
pip "install", "-q", arg
|
62
|
+
end
|
63
|
+
|
64
|
+
# Uninstall won't work unless this issue gets fixed.
|
65
|
+
# <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=562544>
|
66
|
+
def uninstall
|
67
|
+
pip "uninstall", "-y", "-q", @resource[:name]
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: puppet-pip
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Richard Crowley
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-11-08 00:00:00 +00:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: puppet
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description: Puppet provider of Python packages via pip.
|
36
|
+
email: richard@devstructure.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files: []
|
42
|
+
|
43
|
+
files:
|
44
|
+
- lib/puppet/provider/package/pip.rb
|
45
|
+
has_rdoc: true
|
46
|
+
homepage: http://github.com/rcrowley/python-pip
|
47
|
+
licenses: []
|
48
|
+
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
version: "0"
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
hash: 3
|
69
|
+
segments:
|
70
|
+
- 0
|
71
|
+
version: "0"
|
72
|
+
requirements: []
|
73
|
+
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 1.3.7
|
76
|
+
signing_key:
|
77
|
+
specification_version: 3
|
78
|
+
summary: Puppet provider of Python packages via pip.
|
79
|
+
test_files: []
|
80
|
+
|