From 503e75d7529e2f7eaca1bf79ee75a2d580bc5efd Mon Sep 17 00:00:00 2001 From: Tieg Zaharia Date: Sat, 9 Dec 2023 15:39:17 -0700 Subject: [PATCH 1/5] Support poetry 1.2.0+ dependency groups. --- lib/bibliothecary/parsers/pypi.rb | 10 +++++++++- spec/fixtures/pyproject.toml | 5 +++++ spec/parsers/pypi_spec.rb | 3 ++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/bibliothecary/parsers/pypi.rb b/lib/bibliothecary/parsers/pypi.rb index 010be1af..02c2e079 100644 --- a/lib/bibliothecary/parsers/pypi.rb +++ b/lib/bibliothecary/parsers/pypi.rb @@ -101,8 +101,16 @@ def self.parse_pyproject(file_contents, options: {}) # Parse poetry [tool.poetry] deps poetry_manifest = file_contents.fetch('tool', {}).fetch('poetry', {}) + # Poetry 1.0.0-1.2.0 way of defining dev deps deps += map_dependencies(poetry_manifest['dependencies'], 'runtime') - deps += map_dependencies(poetry_manifest['dev-dependencies'], 'develop') + deps += map_dependencies(poetry_manifest['dev-dependencies'], 'development') + # Poetry's 1.2.0+ of defining dev deps + poetry_manifest + .fetch("group", {}) + .each_pair do |group_name, obj| + group_name = "development" if group_name == "dev" + deps += map_dependencies(obj.fetch("dependencies", {}), group_name) + end # Parse PEP621 [project] deps pep621_manifest = file_contents.fetch('project', {}) diff --git a/spec/fixtures/pyproject.toml b/spec/fixtures/pyproject.toml index 4a9a0937..35a1f8ab 100644 --- a/spec/fixtures/pyproject.toml +++ b/spec/fixtures/pyproject.toml @@ -8,9 +8,14 @@ authors = ["Tyrel Souza "] python = "^3.7" django = "^3.0.7" +# Old way to defining dev deps (<1.2.0) [tool.poetry.dev-dependencies] pytest = "^5.2" +# New way to defining dev deps (>=1.2.0) +[tool.poetry.group.dev.dependencies] +wcwidth = "*" + [build-system] requires = ["poetry>=0.12"] build-backend = "poetry.masonry.api" diff --git a/spec/parsers/pypi_spec.rb b/spec/parsers/pypi_spec.rb index 17544ff6..567ccbff 100644 --- a/spec/parsers/pypi_spec.rb +++ b/spec/parsers/pypi_spec.rb @@ -287,7 +287,8 @@ 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: "development" }, + { name: "wcwidth", requirement: "*", type: "development" }, ], kind: 'manifest', success: true From 3ed42253b3046a72466b0cfaed0a1df0fbc974c1 Mon Sep 17 00:00:00 2001 From: Tieg Zaharia Date: Sat, 9 Dec 2023 15:40:29 -0700 Subject: [PATCH 2/5] 8.7.3 --- lib/bibliothecary/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bibliothecary/version.rb b/lib/bibliothecary/version.rb index 4f200bb5..7099bf39 100644 --- a/lib/bibliothecary/version.rb +++ b/lib/bibliothecary/version.rb @@ -1,3 +1,3 @@ module Bibliothecary - VERSION = "8.7.2" + VERSION = "8.7.3" end From 1905585adcf81098a35514299c81cc82574772fc Mon Sep 17 00:00:00 2001 From: Tieg Zaharia Date: Sat, 9 Dec 2023 16:02:43 -0700 Subject: [PATCH 3/5] Default to "runtime" type, and keep "develop" --- lib/bibliothecary/parsers/pypi.rb | 10 +++++----- spec/fixtures/pyproject.toml | 4 ++-- spec/parsers/pypi_spec.rb | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/bibliothecary/parsers/pypi.rb b/lib/bibliothecary/parsers/pypi.rb index 02c2e079..511e6903 100644 --- a/lib/bibliothecary/parsers/pypi.rb +++ b/lib/bibliothecary/parsers/pypi.rb @@ -101,14 +101,14 @@ def self.parse_pyproject(file_contents, options: {}) # Parse poetry [tool.poetry] deps poetry_manifest = file_contents.fetch('tool', {}).fetch('poetry', {}) - # Poetry 1.0.0-1.2.0 way of defining dev deps deps += map_dependencies(poetry_manifest['dependencies'], 'runtime') - deps += map_dependencies(poetry_manifest['dev-dependencies'], 'development') + # 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 = "development" if group_name == "dev" + group_name = "develop" if group_name == "dev" deps += map_dependencies(obj.fetch("dependencies", {}), group_name) end @@ -187,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 << { diff --git a/spec/fixtures/pyproject.toml b/spec/fixtures/pyproject.toml index 35a1f8ab..b7d86cd5 100644 --- a/spec/fixtures/pyproject.toml +++ b/spec/fixtures/pyproject.toml @@ -8,11 +8,11 @@ authors = ["Tyrel Souza "] python = "^3.7" django = "^3.0.7" -# Old way to defining dev deps (<1.2.0) +# Old way to define dev deps (<1.2.0) [tool.poetry.dev-dependencies] pytest = "^5.2" -# New way to defining dev deps (>=1.2.0) +# New way to define dev deps (>=1.2.0) [tool.poetry.group.dev.dependencies] wcwidth = "*" diff --git a/spec/parsers/pypi_spec.rb b/spec/parsers/pypi_spec.rb index 567ccbff..b02d7eee 100644 --- a/spec/parsers/pypi_spec.rb +++ b/spec/parsers/pypi_spec.rb @@ -287,8 +287,8 @@ dependencies: [ { name: "python", requirement: "^3.7", type: "runtime" }, { name: "django", requirement: "^3.0.7", type: "runtime" }, - { name: "pytest", requirement: "^5.2", type: "development" }, - { name: "wcwidth", requirement: "*", type: "development" }, + { name: "pytest", requirement: "^5.2", type: "develop" }, + { name: "wcwidth", requirement: "*", type: "develop" }, ], kind: 'manifest', success: true From 04f2af0e23994d3856740aacbe49067d529656d7 Mon Sep 17 00:00:00 2001 From: Tieg Zaharia Date: Mon, 11 Dec 2023 09:26:40 -0700 Subject: [PATCH 4/5] Add a test group example --- spec/fixtures/pyproject.toml | 7 +++++-- spec/parsers/pypi_spec.rb | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/spec/fixtures/pyproject.toml b/spec/fixtures/pyproject.toml index b7d86cd5..635523bf 100644 --- a/spec/fixtures/pyproject.toml +++ b/spec/fixtures/pyproject.toml @@ -8,14 +8,17 @@ authors = ["Tyrel Souza "] python = "^3.7" django = "^3.0.7" -# Old way to define dev deps (<1.2.0) +# Old way to define development deps (<1.2.0) [tool.poetry.dev-dependencies] pytest = "^5.2" -# New way to define dev deps (>=1.2.0) +# 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" diff --git a/spec/parsers/pypi_spec.rb b/spec/parsers/pypi_spec.rb index b02d7eee..fcd35b17 100644 --- a/spec/parsers/pypi_spec.rb +++ b/spec/parsers/pypi_spec.rb @@ -289,6 +289,7 @@ { name: "django", requirement: "^3.0.7", type: "runtime" }, { name: "pytest", requirement: "^5.2", type: "develop" }, { name: "wcwidth", requirement: "*", type: "develop" }, + { name: "sqlparse", requirement: "0.3.1", type: "test" }, ], kind: 'manifest', success: true From b6b64112318815e410797c823314e1ec7f69e6f0 Mon Sep 17 00:00:00 2001 From: Tieg Zaharia Date: Mon, 11 Dec 2023 10:12:46 -0700 Subject: [PATCH 5/5] 8.7.4 --- lib/bibliothecary/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bibliothecary/version.rb b/lib/bibliothecary/version.rb index 7099bf39..6856751a 100644 --- a/lib/bibliothecary/version.rb +++ b/lib/bibliothecary/version.rb @@ -1,3 +1,3 @@ module Bibliothecary - VERSION = "8.7.3" + VERSION = "8.7.4" end