From c2bc238433c1177c33dd004709c53c92e07a0706 Mon Sep 17 00:00:00 2001
From: Patrick Lannigan
Date: Wed, 27 Dec 2023 13:07:11 -0500
Subject: [PATCH 1/2] Add support for python build-system
---
lib/modules/manager/pep621/extract.spec.ts | 38 ++++++++++++++++++++++
lib/modules/manager/pep621/extract.ts | 6 ++++
lib/modules/manager/pep621/readme.md | 1 +
lib/modules/manager/pep621/schema.ts | 5 +++
lib/modules/manager/pep621/utils.ts | 1 +
5 files changed, 51 insertions(+)
diff --git a/lib/modules/manager/pep621/extract.spec.ts b/lib/modules/manager/pep621/extract.spec.ts
index 63aa8bcbdd11ff..55b9682af3a39b 100644
--- a/lib/modules/manager/pep621/extract.spec.ts
+++ b/lib/modules/manager/pep621/extract.spec.ts
@@ -281,6 +281,13 @@ describe('modules/manager/pep621/extract', () => {
depType: 'project.dependencies',
packageName: 'requests',
},
+ {
+ datasource: 'pypi',
+ depName: 'hatchling',
+ depType: 'build-system.requires',
+ packageName: 'hatchling',
+ skipReason: 'unspecified-version',
+ },
{
currentValue: '==6.5',
datasource: 'pypi',
@@ -323,5 +330,36 @@ describe('modules/manager/pep621/extract', () => {
const res = extractPackageFile(content, 'pyproject.toml');
expect(res?.packageFileVersion).toBe('0.0.2');
});
+
+ it('should extract dependencies from build-system.requires', function () {
+ const content = codeBlock`
+ [build-system]
+ requires = ["hatchling==1.18.0", "setuptools==69.0.3"]
+ build-backend = "hatchling.build"
+
+ [project]
+ name = "test"
+ version = "0.0.2"
+ dependencies = [ "requests==2.30.0" ]
+ `;
+ const result = extractPackageFile(content, 'pyproject.toml');
+
+ expect(result?.deps).toEqual([
+ {
+ currentValue: '==1.18.0',
+ datasource: 'pypi',
+ depName: 'hatchling',
+ depType: 'build-system.requires',
+ packageName: 'hatchling',
+ },
+ {
+ currentValue: '==69.0.3',
+ datasource: 'pypi',
+ depName: 'setuptools',
+ depType: 'build-system.requires',
+ packageName: 'setuptools',
+ },
+ ]);
+ });
});
});
diff --git a/lib/modules/manager/pep621/extract.ts b/lib/modules/manager/pep621/extract.ts
index d1f8e4accf7bf2..66648663dcddaf 100644
--- a/lib/modules/manager/pep621/extract.ts
+++ b/lib/modules/manager/pep621/extract.ts
@@ -43,6 +43,12 @@ export function extractPackageFile(
def.project?.['optional-dependencies'],
),
);
+ deps.push(
+ ...parseDependencyList(
+ depTypes.buildSystemRequires,
+ def['build-system']?.requires,
+ ),
+ );
// process specific tool sets
let processedDeps = deps;
diff --git a/lib/modules/manager/pep621/readme.md b/lib/modules/manager/pep621/readme.md
index 344e3948559e4e..3d3009e5b55856 100644
--- a/lib/modules/manager/pep621/readme.md
+++ b/lib/modules/manager/pep621/readme.md
@@ -9,5 +9,6 @@ Available `depType`s:
- `project.dependencies`
- `project.optional-dependencies`
+- `build-system.requires`
- `tool.pdm.dev-dependencies`
- `tool.hatch.envs.`
diff --git a/lib/modules/manager/pep621/schema.ts b/lib/modules/manager/pep621/schema.ts
index 880336adb38dc5..212a1301c1b257 100644
--- a/lib/modules/manager/pep621/schema.ts
+++ b/lib/modules/manager/pep621/schema.ts
@@ -16,6 +16,11 @@ export const PyProjectSchema = z.object({
'optional-dependencies': DependencyRecordSchema,
})
.optional(),
+ 'build-system': z
+ .object({
+ requires: DependencyListSchema,
+ })
+ .optional(),
tool: z
.object({
pdm: z
diff --git a/lib/modules/manager/pep621/utils.ts b/lib/modules/manager/pep621/utils.ts
index 4420992bcb4f43..5b28541993508f 100644
--- a/lib/modules/manager/pep621/utils.ts
+++ b/lib/modules/manager/pep621/utils.ts
@@ -15,6 +15,7 @@ export const depTypes = {
dependencies: 'project.dependencies',
optionalDependencies: 'project.optional-dependencies',
pdmDevDependencies: 'tool.pdm.dev-dependencies',
+ buildSystemRequires: 'build-system.requires',
};
export function parsePEP508(
From 3bc6b7f7ec7e58a9f55f22bbabe12ac113476f5f Mon Sep 17 00:00:00 2001
From: Patrick Lannigan
Date: Wed, 27 Dec 2023 13:36:36 -0500
Subject: [PATCH 2/2] Correct expected result of test case
---
lib/modules/manager/pep621/extract.spec.ts | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/lib/modules/manager/pep621/extract.spec.ts b/lib/modules/manager/pep621/extract.spec.ts
index 55b9682af3a39b..4911bc35b732ad 100644
--- a/lib/modules/manager/pep621/extract.spec.ts
+++ b/lib/modules/manager/pep621/extract.spec.ts
@@ -345,6 +345,13 @@ describe('modules/manager/pep621/extract', () => {
const result = extractPackageFile(content, 'pyproject.toml');
expect(result?.deps).toEqual([
+ {
+ currentValue: '==2.30.0',
+ datasource: 'pypi',
+ depName: 'requests',
+ depType: 'project.dependencies',
+ packageName: 'requests',
+ },
{
currentValue: '==1.18.0',
datasource: 'pypi',