PY-87265 Check tool.<toolId> in pyproject.toml-based projects

Before the changes, we didn't check tool specific info in
pyproject.toml. This led to an effect when you've had a uv module (with
tool.uv.* sections specified), but also hatchling build system. And
since we're checking for a build system, we suggest to configure a
project using Hatch, which is incorrect.


(cherry picked from commit 9e5195e2e3c97d4772065528344aaf7c8533841b)

IJ-MR-192700

GitOrigin-RevId: aea284c87fb78e1c6029b07f2a290e10a4151399
This commit is contained in:
Alexey Katsman
2026-02-20 22:09:21 +00:00
committed by intellij-monorepo-bot
parent fbaaccf8e9
commit 17c0f647d6
@@ -138,10 +138,18 @@ private suspend fun generatePyProjectTomlEntries(
}
usedNamed.add(projectNameAsString)
val projectName = ProjectName(projectNameAsString)
val sourceRootsAndTools = Tool.EP.extensionList.flatMap { tool -> tool.getSrcRoots(toml.toml, root).map { Pair(tool, it) } }.toSet()
val sourceRootsAndTools = tools.flatMap { tool -> tool.getSrcRoots(toml.toml, root).map { Pair(tool, it) } }.toSet()
val sourceRoots = sourceRootsAndTools.map { it.second }.toSet() + findSrc(root)
participatedTools.addAll(sourceRootsAndTools.map { it.first.id })
val excludedDirs = allExcludeDirs.filter { it.startsWith(root) }
if (participatedTools.isEmpty()) {
// If a tool is mentioned as a tool.<toolId> in pyproject.toml, we consider it participated in project configuration
for (tool in tools) {
if (toml.toml.contains("tool.${tool.id.id}")) {
participatedTools.add(tool.id)
}
}
}
if (participatedTools.isEmpty()) {
// Try to use build-tool as last resort
toml.toml.getString("build-system.build-backend")?.let { buildBackend ->