From e7fcac51f78f1ee8afa33c3a6e5a40f60c357a86 Mon Sep 17 00:00:00 2001 From: Filip Seman Date: Wed, 14 Jan 2026 20:28:50 +0100 Subject: [PATCH] fix: auto-detect component name for Python packages and add missing schema properties - Add getDefaultPackageName() method to Python strategy to extract package name from pyproject.toml - Support both project.name and tool.poetry.name formats in pyproject.toml - Add fallback to setup.py if pyproject.toml doesn't contain package name - Add missing 'path', 'component', and 'package-name' properties to config schema Fixes #2573 --- schemas/config.json | 12 ++++++++++++ src/strategies/python.ts | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/schemas/config.json b/schemas/config.json index efa17fcd8..32f26e6dc 100644 --- a/schemas/config.json +++ b/schemas/config.json @@ -12,6 +12,18 @@ "description": "The strategy to use for this component.", "type": "string" }, + "path": { + "description": "Path to the package directory in a monorepo. Used to identify which package this configuration applies to.", + "type": "string" + }, + "component": { + "description": "Name of the component used for branch naming and release tagging. If not provided, the component may be automatically detected from the package manifest (e.g., package.json for Node, pyproject.toml for Python).", + "type": "string" + }, + "package-name": { + "description": "Name of the package. If not provided, it may be automatically detected from the package manifest.", + "type": "string" + }, "bump-minor-pre-major": { "description": "Breaking changes only bump semver minor if version < 1.0.0", "type": "boolean" diff --git a/src/strategies/python.ts b/src/strategies/python.ts index bd9325165..dfb4f11d6 100644 --- a/src/strategies/python.ts +++ b/src/strategies/python.ts @@ -168,6 +168,18 @@ export class Python extends BaseStrategy { } } + async getDefaultPackageName(): Promise { + const parsedPyProject = await this.getPyProject( + this.addPath('pyproject.toml') + ); + const pyProject = parsedPyProject?.project || parsedPyProject?.tool?.poetry; + if (pyProject?.name) { + return pyProject.name; + } + const nameFromSetupPy = await this.getNameFromSetupPy(); + return nameFromSetupPy ?? undefined; + } + protected async getNameFromSetupPy(): Promise { const ARTIFACT_NAME_REGEX = /name *= *['"](?.*)['"](\r|\n|$)/; const setupPyContents = await this.getSetupPyContents();