Package org.sonar.plugins.python.indexer
Class PyProjectTomlSourceRoots
java.lang.Object
org.sonar.plugins.python.indexer.PyProjectTomlSourceRoots
Extracts source root directories from pyproject.toml build system configurations.
Supports the following build systems:
- setuptools:
[tool.setuptools.packages.find] where = ["src"] - Poetry:
[tool.poetry] packages = [{from = "src", include = "pkg"}]or auto-detects src/ layout when build-backend is poetry.core.masonry.api - Hatchling:
[tool.hatch.build.targets.wheel] sources = ["src"] - uv_build:
[build-system] build-backend = "uv_build"or[tool.uv.build-backend] module-root = "src"- auto-detects src/ layout by convention - PDM:
[tool.pdm] package-dir = "src" - Flit: auto-detects src/ layout by convention
-
Method Summary
Modifier and TypeMethodDescriptionstatic PyProjectExtractionResultextractWithBuildSystem(File file) Extracts source root directories from a pyproject.toml File, including build system info.static ConfigSourceRootsextractWithLocation(File file) Extracts source root directories from a pyproject.toml File, preserving the config file location.
-
Method Details
-
extractWithBuildSystem
Extracts source root directories from a pyproject.toml File, including build system info.- Parameters:
file- the pyproject.toml file- Returns:
- extraction result with source roots and build system info
-
extractWithLocation
Extracts source root directories from a pyproject.toml File, preserving the config file location.This method returns a
ConfigSourceRootsthat associates the extracted relative paths with the config file, allowing callers to resolve absolute paths relative to the config file's directory rather than the project base directory.- Parameters:
file- the pyproject.toml file- Returns:
- ConfigSourceRoots containing the config file and its relative source roots
-