Skip to content

Commit f57e31e

Browse files
Merge pull request #9311 from joshcooper/backport_9280
[Backport 7.x] Support pip freeze URL format
2 parents 6b24346 + 28c5881 commit f57e31e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/puppet/provider/package/pip.rb

+3
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,12 @@ def self.instances(target_command = nil)
9999

100100
# Parse lines of output from `pip freeze`, which are structured as:
101101
# _package_==_version_ or _package_===_version_
102+
# or _package_ @ someURL@_version_
102103
def self.parse(line)
103104
if line.chomp =~ /^([^=]+)===?([^=]+)$/
104105
{:ensure => $2, :name => $1, :provider => name}
106+
elsif line.chomp =~ /^([^@]+) @ [^@]+@(.+)$/
107+
{ :ensure => Regexp.last_match(2), :name => Regexp.last_match(1), :provider => name }
105108
end
106109
end
107110

spec/unit/provider/package/pip_spec.rb

+8
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@
3838
})
3939
end
4040

41+
it "should correctly parse URL format" do
42+
expect(described_class.parse("real_package @ git+https://github.com/example/test.git@6b4e203b66c1de7345984882e2b13bf87c700095")).to eq({
43+
:ensure => "6b4e203b66c1de7345984882e2b13bf87c700095",
44+
:name => "real_package",
45+
:provider => :pip,
46+
})
47+
end
48+
4149
it "should return nil on invalid input" do
4250
expect(described_class.parse("foo")).to eq(nil)
4351
end

0 commit comments

Comments
 (0)