bibliothecary 8.5.0 → 8.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bibliothecary/parsers/maven.rb +7 -1
- data/lib/bibliothecary/parsers/pypi.rb +36 -3
- data/lib/bibliothecary/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69baa22eeba713511d022a85df1280b987885810f25e421f8d7eecf8af795317
|
4
|
+
data.tar.gz: c663614b9e7c5aee6613a403a14aa2faccbbe07bf69d3cb68a92faa09449803c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27bc063ab4832d89e65673935169d9ad78fb13a48bacaf4d8a640781f8bc5a1f4a486da73e7e7409e64eb721246695997471f342e966d9434d576f480238c253
|
7
|
+
data.tar.gz: aea0d2e9eea3a8e9dec803d040ea14299febdf52528d58a7479240e6e65def97a5e24c60a0c0955ee72929140698ae78f6ca6ecbe44c1d1b7240f64d90d6570a
|
@@ -322,6 +322,9 @@ module Bibliothecary
|
|
322
322
|
extract_pom_dep_info(xml, xml, location, parent_properties)
|
323
323
|
end
|
324
324
|
|
325
|
+
# TODO: it might be worth renaming parent_properties to parent_elements
|
326
|
+
# so that more can be inherited from the parent pom than just <properties>
|
327
|
+
# here (see https://maven.apache.org/pom.html#inheritance)
|
325
328
|
def self.extract_pom_dep_info(xml, dependency, name, parent_properties = {})
|
326
329
|
field = dependency.locate(name).first
|
327
330
|
return nil if field.nil?
|
@@ -363,7 +366,10 @@ module Bibliothecary
|
|
363
366
|
return "${#{property_name}}" if !xml.respond_to?("properties") && parent_properties.empty? && xml.locate(non_prop_name).empty?
|
364
367
|
|
365
368
|
prop_field = xml.properties.locate(property_name).first if xml.respond_to?("properties")
|
366
|
-
parent_prop = parent_properties[property_name]
|
369
|
+
parent_prop = parent_properties[property_name] || # e.g. "${foo}"
|
370
|
+
parent_properties[property_name.sub(/^project\./, '')] || # e.g. "${project.foo}"
|
371
|
+
parent_properties[property_name.sub(/^project\.parent\./, '')] # e.g. "${project.parent.foo}"
|
372
|
+
|
367
373
|
if prop_field
|
368
374
|
prop_field.nodes.first
|
369
375
|
elsif parent_prop
|
@@ -14,6 +14,9 @@ module Bibliothecary
|
|
14
14
|
MANIFEST_REGEXP = /.*require[^\/]*(\/)?[^\/]*\.(txt|pip|in)$/
|
15
15
|
PIP_COMPILE_REGEXP = /.*require.*$/
|
16
16
|
|
17
|
+
# Adapted from https://peps.python.org/pep-0508/#names
|
18
|
+
PEP_508_NAME_REGEX = /^([A-Z0-9][A-Z0-9._-]*[A-Z0-9]|[A-Z0-9])/i
|
19
|
+
|
17
20
|
def self.mapping
|
18
21
|
{
|
19
22
|
match_filenames('requirements-dev.txt', 'requirements/dev.txt',
|
@@ -56,7 +59,7 @@ module Bibliothecary
|
|
56
59
|
},
|
57
60
|
match_filename("pyproject.toml") => {
|
58
61
|
kind: 'manifest',
|
59
|
-
parser: :
|
62
|
+
parser: :parse_pyproject
|
60
63
|
},
|
61
64
|
match_filename("poetry.lock") => {
|
62
65
|
kind: 'lockfile',
|
@@ -90,9 +93,30 @@ module Bibliothecary
|
|
90
93
|
map_dependencies(manifest['packages'], 'runtime') + map_dependencies(manifest['dev-packages'], 'develop')
|
91
94
|
end
|
92
95
|
|
96
|
+
def self.parse_pyproject(file_contents, options: {})
|
97
|
+
deps = []
|
98
|
+
|
99
|
+
file_contents = Tomlrb.parse(file_contents)
|
100
|
+
|
101
|
+
# Parse poetry [tool.poetry] deps
|
102
|
+
poetry_manifest = file_contents.fetch('tool', {}).fetch('poetry', {})
|
103
|
+
deps += map_dependencies(poetry_manifest['dependencies'], 'runtime')
|
104
|
+
deps += map_dependencies(poetry_manifest['dev-dependencies'], 'develop')
|
105
|
+
|
106
|
+
# Parse PEP621 [project] deps
|
107
|
+
pep621_manifest = file_contents.fetch('project', {})
|
108
|
+
pep621_deps = pep621_manifest.fetch('dependencies', []).map { |d| parse_pep_508_dep_spec(d) }
|
109
|
+
deps += map_dependencies(pep621_deps, 'runtime')
|
110
|
+
|
111
|
+
# We're combining both poetry+PEP621 deps instead of making them mutually exclusive, until we
|
112
|
+
# find a reason not to ingest them both.
|
113
|
+
deps.uniq
|
114
|
+
end
|
115
|
+
|
116
|
+
# TODO: this was deprecated in 8.6.0. Remove this in any major version bump >= 9.*
|
93
117
|
def self.parse_poetry(file_contents, options: {})
|
94
|
-
|
95
|
-
|
118
|
+
puts "Warning: parse_poetry() is deprecated, use parse_pyproject() instead."
|
119
|
+
parse_pyproject(file_contents, options)
|
96
120
|
end
|
97
121
|
|
98
122
|
def self.parse_conda(file_contents, options: {})
|
@@ -252,6 +276,15 @@ module Bibliothecary
|
|
252
276
|
# parsing after we match.
|
253
277
|
false
|
254
278
|
end
|
279
|
+
|
280
|
+
# Simply parses out the name of a PEP 508 Dependency specification: https://peps.python.org/pep-0508/
|
281
|
+
# Leaves the rest as-is with any leading semicolons or spaces stripped
|
282
|
+
def self.parse_pep_508_dep_spec(dep)
|
283
|
+
name, requirement = dep.split(PEP_508_NAME_REGEX, 2).last(2).map(&:strip)
|
284
|
+
requirement = requirement.sub(/^[\s;]*/, "")
|
285
|
+
requirement = "*" if requirement == ""
|
286
|
+
return name, requirement
|
287
|
+
end
|
255
288
|
end
|
256
289
|
end
|
257
290
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bibliothecary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.
|
4
|
+
version: 8.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Nesbitt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tomlrb
|