Skip to content

Commit

Permalink
8.7.4: Add support for Poetry 1.2.0+'s dependency groups (#584)
Browse files Browse the repository at this point in the history
* Support poetry 1.2.0+ dependency groups.

* Default to "runtime" type, and keep "develop"

* Add a test group example

* 8.7.4
  • Loading branch information
tiegz authored Dec 11, 2023
1 parent 62175df commit 3c77ca3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
12 changes: 10 additions & 2 deletions lib/bibliothecary/parsers/pypi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,15 @@ def self.parse_pyproject(file_contents, options: {})
# Parse poetry [tool.poetry] deps
poetry_manifest = file_contents.fetch('tool', {}).fetch('poetry', {})
deps += map_dependencies(poetry_manifest['dependencies'], 'runtime')
# Poetry 1.0.0-1.2.0 way of defining dev deps
deps += map_dependencies(poetry_manifest['dev-dependencies'], 'develop')
# Poetry's 1.2.0+ of defining dev deps
poetry_manifest
.fetch("group", {})
.each_pair do |group_name, obj|
group_name = "develop" if group_name == "dev"
deps += map_dependencies(obj.fetch("dependencies", {}), group_name)
end

# Parse PEP621 [project] deps
pep621_manifest = file_contents.fetch('project', {})
Expand Down Expand Up @@ -179,10 +187,10 @@ def self.parse_poetry_lock(file_contents, options: {})
manifest["package"].each do |package|
# next if group == "_meta"
group = case package['category']
when 'main'
'runtime'
when 'dev'
'develop'
else
'runtime'
end

deps << {
Expand Down
2 changes: 1 addition & 1 deletion lib/bibliothecary/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Bibliothecary
VERSION = "8.7.3"
VERSION = "8.7.4"
end
8 changes: 8 additions & 0 deletions spec/fixtures/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@ authors = ["Tyrel Souza <tyrel@tidelift.com>"]
python = "^3.7"
django = "^3.0.7"

# Old way to define development deps (<1.2.0)
[tool.poetry.dev-dependencies]
pytest = "^5.2"

# New way to define development deps (>=1.2.0)
[tool.poetry.group.dev.dependencies]
wcwidth = "*"

[tool.poetry.group.test.dependencies]
sqlparse = "0.3.1"

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
4 changes: 3 additions & 1 deletion spec/parsers/pypi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,9 @@
dependencies: [
{ name: "python", requirement: "^3.7", type: "runtime" },
{ name: "django", requirement: "^3.0.7", type: "runtime" },
{ name: "pytest", requirement: "^5.2", type: "develop" }
{ name: "pytest", requirement: "^5.2", type: "develop" },
{ name: "wcwidth", requirement: "*", type: "develop" },
{ name: "sqlparse", requirement: "0.3.1", type: "test" },
],
kind: 'manifest',
success: true
Expand Down

0 comments on commit 3c77ca3

Please sign in to comment.