Skip to content

Commit

Permalink
feat(manager/pep621): Add support for python build-system dependencies (
Browse files Browse the repository at this point in the history
  • Loading branch information
plannigan authored Dec 27, 2023
1 parent 9e171ff commit 3a8574b
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
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

0 comments on commit 3a8574b

Please sign in to comment.