puppet-pip 0.0.1 → 0.0.2

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.
Files changed (2) hide show
  1. data/lib/puppet/provider/package/pip.rb +21 -14
  2. metadata +4 -4
@@ -1,22 +1,15 @@
1
- # Puppet package provider for Python's `pip` package management
2
- # frontend.
1
+ # Puppet package provider for Python's `pip` package management frontend.
3
2
  # <http://pip.openplans.org/>
4
3
 
5
4
  require 'puppet/provider/package'
5
+ require 'xmlrpc/client'
6
6
 
7
7
  Puppet::Type.type(:package).provide :pip,
8
8
  :parent => ::Puppet::Provider::Package do
9
9
 
10
10
  desc "Python packages via `pip`."
11
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
12
+ has_feature :installable, :uninstallable, :upgradeable, :versionable
20
13
 
21
14
  if pathname = `which pip`.chomp
22
15
  commands :pip => pathname
@@ -53,12 +46,22 @@ Puppet::Type.type(:package).provide :pip,
53
46
  nil
54
47
  end
55
48
 
49
+ def latest
50
+ client = XMLRPC::Client.new2("http://pypi.python.org/pypi")
51
+ client.http_header_extra = {"Content-Type" => "text/xml"}
52
+ result = client.call("package_releases", @resource[:name])
53
+ result.first
54
+ end
55
+
56
56
  def install
57
- arg = @resource[:name]
58
- if String === @resource[:ensure]
59
- arg = "#{arg}==#{@resource[:ensure]}"
57
+ case @resource[:ensure]
58
+ when String
59
+ pip "install", "-q", "#{@resource[:name]}==#{@resource[:ensure]}"
60
+ when :latest
61
+ pip "install", "-q", "--upgrade", @resource[:name]
62
+ else
63
+ pip "install", "-q", @resource[:name]
60
64
  end
61
- pip "install", "-q", arg
62
65
  end
63
66
 
64
67
  # Uninstall won't work unless this issue gets fixed.
@@ -67,4 +70,8 @@ Puppet::Type.type(:package).provide :pip,
67
70
  pip "uninstall", "-y", "-q", @resource[:name]
68
71
  end
69
72
 
73
+ def update
74
+ install
75
+ end
76
+
70
77
  end
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: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Richard Crowley
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-08 00:00:00 +00:00
18
+ date: 2010-12-08 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency