bibliothecary 8.2.3 → 8.2.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.
- checksums.yaml +4 -4
- data/lib/bibliothecary/parsers/pypi.rb +42 -7
- data/lib/bibliothecary/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 631a4574650b4e69a1aec283acf4c0d1fb8338a1c4b767500b3b613c51357d7c
|
|
4
|
+
data.tar.gz: 1f280d94aacce63d88302f767561d9e9f05e8d3381cd4a618cff5f04cc73511f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d5e68b0a9fe18880ce752f45e66ba68a31834ce35356e025f892eadb409c613c3d3d57b19fedb65362e0977393757c8a0d7fa521f5e8c3ebbe90dd1aa96b1f86
|
|
7
|
+
data.tar.gz: 0ce08bdc863f9e82ed831d99b6132c043d6da012c297f81f5a0a801e847143b5a60a4545d2ce177a1deeaa7e62ed3a50010268b396d34c3f9794d04dccfbd365
|
|
@@ -179,20 +179,55 @@ module Bibliothecary
|
|
|
179
179
|
deps
|
|
180
180
|
end
|
|
181
181
|
|
|
182
|
+
# While the thing in the repo that PyPI is using might be either in
|
|
183
|
+
# egg format or wheel format, PyPI uses "egg" in the fragment of the
|
|
184
|
+
# VCS URL to specify what package in the PyPI index the VCS URL
|
|
185
|
+
# should be treated as.
|
|
186
|
+
NoEggSpecified = Class.new(ArgumentError)
|
|
187
|
+
|
|
188
|
+
# Parses a requirements.txt file, following the
|
|
189
|
+
# https://pip.pypa.io/en/stable/cli/pip_install/#requirement-specifiers
|
|
190
|
+
# and https://pip.pypa.io/en/stable/topics/vcs-support/#git.
|
|
191
|
+
# Invalid lines in requirements.txt are skipped.
|
|
182
192
|
def self.parse_requirements_txt(file_contents, options: {})
|
|
183
193
|
deps = []
|
|
184
194
|
file_contents.split("\n").each do |line|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
195
|
+
if line['://']
|
|
196
|
+
begin
|
|
197
|
+
result = parse_requirements_txt_url(line)
|
|
198
|
+
rescue URI::Error, NoEggSpecified => e
|
|
199
|
+
next
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
deps << result.merge(
|
|
203
|
+
type: 'runtime'
|
|
204
|
+
)
|
|
205
|
+
else
|
|
206
|
+
match = line.delete(' ').match(REQUIREMENTS_REGEXP)
|
|
207
|
+
next unless match
|
|
208
|
+
|
|
209
|
+
deps << {
|
|
210
|
+
name: match[1],
|
|
211
|
+
requirement: match[-1] || '*',
|
|
212
|
+
type: 'runtime'
|
|
213
|
+
}
|
|
214
|
+
end
|
|
192
215
|
end
|
|
193
216
|
deps
|
|
194
217
|
end
|
|
195
218
|
|
|
219
|
+
def self.parse_requirements_txt_url(url)
|
|
220
|
+
uri = URI.parse(url)
|
|
221
|
+
raise NoEggSpecified, "No egg specified in #{url}" unless uri.fragment
|
|
222
|
+
|
|
223
|
+
name = uri.fragment[/^egg=([^&]+)([&]|$)/, 1]
|
|
224
|
+
raise NoEggSpecified, "No egg specified in #{url}" unless name
|
|
225
|
+
|
|
226
|
+
requirement = uri.path[/@(.+)$/, 1]
|
|
227
|
+
|
|
228
|
+
{ name: name, requirement: requirement || "*" }
|
|
229
|
+
end
|
|
230
|
+
|
|
196
231
|
def self.pip_compile?(file_contents)
|
|
197
232
|
return file_contents.include?("This file is autogenerated by pip-compile")
|
|
198
233
|
rescue Exception # rubocop:disable Lint/RescueException
|