From 3a8574bbd7e0a95006d6cfe847d00b7e0ffb4f95 Mon Sep 17 00:00:00 2001
From: Patrick Lannigan
Date: Wed, 27 Dec 2023 14:52:22 -0500
Subject: [PATCH] feat(manager/pep621): Add support for python build-system
dependencies (#26440)
---
lib/modules/manager/pep621/extract.spec.ts | 45 ++++++++++++++++++++++
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, 58 insertions(+)
diff --git a/lib/modules/manager/pep621/extract.spec.ts b/lib/modules/manager/pep621/extract.spec.ts
index 63aa8bcbdd11ff..4911bc35b732ad 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,43 @@ 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: '==2.30.0',
+ datasource: 'pypi',
+ depName: 'requests',
+ depType: 'project.dependencies',
+ packageName: 'requests',
+ },
+ {
+ 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(