Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(manager/pep621): Add support for python build-system dependencies #26440

Merged
merged 2 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions lib/modules/manager/pep621/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
},
]);
});
});
});
6 changes: 6 additions & 0 deletions lib/modules/manager/pep621/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions lib/modules/manager/pep621/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ Available `depType`s:

- `project.dependencies`
- `project.optional-dependencies`
- `build-system.requires`
- `tool.pdm.dev-dependencies`
- `tool.hatch.envs.<env-name>`
5 changes: 5 additions & 0 deletions lib/modules/manager/pep621/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/modules/manager/pep621/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down