puppet-pip 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/puppet/provider/package/pip.rb +18 -2
- metadata +3 -3
@@ -11,6 +11,8 @@ Puppet::Type.type(:package).provide :pip,
|
|
11
11
|
|
12
12
|
has_feature :installable, :uninstallable, :upgradeable, :versionable
|
13
13
|
|
14
|
+
# Parse lines of output from `pip freeze`, which are structured as
|
15
|
+
# _package_==_version_.
|
14
16
|
def self.parse(line)
|
15
17
|
if line.chomp =~ /^([^=]+)==([^=]+)$/
|
16
18
|
{:ensure => $2, :name => $1, :provider => name}
|
@@ -19,6 +21,8 @@ Puppet::Type.type(:package).provide :pip,
|
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
24
|
+
# Return an array of structured information about every installed package
|
25
|
+
# that's managed by `pip` or an empty array if `pip` is not available.
|
22
26
|
def self.instances
|
23
27
|
packages = []
|
24
28
|
execpipe "#{command :pip} freeze" do |process|
|
@@ -32,6 +36,8 @@ Puppet::Type.type(:package).provide :pip,
|
|
32
36
|
[]
|
33
37
|
end
|
34
38
|
|
39
|
+
# Return structured information about a particular package or `nil` if
|
40
|
+
# it is not installed or `pip` itself is not available.
|
35
41
|
def query
|
36
42
|
execpipe "#{command :pip} freeze" do |process|
|
37
43
|
process.each do |line|
|
@@ -44,6 +50,9 @@ Puppet::Type.type(:package).provide :pip,
|
|
44
50
|
nil
|
45
51
|
end
|
46
52
|
|
53
|
+
# Ask the PyPI API for the latest version number. There is no local
|
54
|
+
# cache of PyPI's package list so this operation will always have to
|
55
|
+
# ask the web service.
|
47
56
|
def latest
|
48
57
|
client = XMLRPC::Client.new2("http://pypi.python.org/pypi")
|
49
58
|
client.http_header_extra = {"Content-Type" => "text/xml"}
|
@@ -51,6 +60,10 @@ Puppet::Type.type(:package).provide :pip,
|
|
51
60
|
result.first
|
52
61
|
end
|
53
62
|
|
63
|
+
# Install a package. The ensure parameter may specify installed,
|
64
|
+
# latest, a version number, or, in conjunction with the source
|
65
|
+
# parameter, an SCM revision. In that case, the source parameter
|
66
|
+
# gives the fully-qualified URL to the repository.
|
54
67
|
def install
|
55
68
|
args = %w{install -q}
|
56
69
|
if @resource[:source]
|
@@ -74,7 +87,8 @@ Puppet::Type.type(:package).provide :pip,
|
|
74
87
|
lazy_pip *args
|
75
88
|
end
|
76
89
|
|
77
|
-
# Uninstall won't work
|
90
|
+
# Uninstall a package. Uninstall won't work reliably on Debian/Ubuntu
|
91
|
+
# unless this issue gets fixed.
|
78
92
|
# <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=562544>
|
79
93
|
def uninstall
|
80
94
|
lazy_pip "uninstall", "-y", "-q", @resource[:name]
|
@@ -84,10 +98,12 @@ Puppet::Type.type(:package).provide :pip,
|
|
84
98
|
install
|
85
99
|
end
|
86
100
|
|
101
|
+
# Execute a `pip` command. If Puppet doesn't yet know how to do so,
|
102
|
+
# try to teach it and if even that fails, raise the error.
|
87
103
|
private
|
88
104
|
def lazy_pip(*args)
|
89
105
|
pip *args
|
90
|
-
rescue NoMethodError
|
106
|
+
rescue NoMethodError => e
|
91
107
|
if pathname = `which pip`.chomp
|
92
108
|
self.class.commands :pip => pathname
|
93
109
|
retry
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-pip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Richard Crowley
|