[Mlir-commits] [mlir] [MLIR][Python] quiet stubgen (PR #160368)

Maksim Levental llvmlistbot at llvm.org
Tue Sep 23 12:05:37 PDT 2025


https://github.com/makslevental updated https://github.com/llvm/llvm-project/pull/160368

>From b247e597808b78a31003eea80fe852d443b42581 Mon Sep 17 00:00:00 2001
From: makslevental <maksim.levental at gmail.com>
Date: Tue, 23 Sep 2025 12:04:10 -0700
Subject: [PATCH] [MLIR][Python] quiet stubgen

---
 mlir/cmake/modules/AddMLIRPython.cmake         | 10 ++++++++--
 mlir/examples/standalone/python/CMakeLists.txt |  1 +
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/mlir/cmake/modules/AddMLIRPython.cmake b/mlir/cmake/modules/AddMLIRPython.cmake
index f25595116edca..208cbdd1dd535 100644
--- a/mlir/cmake/modules/AddMLIRPython.cmake
+++ b/mlir/cmake/modules/AddMLIRPython.cmake
@@ -113,11 +113,12 @@ endfunction()
 #   DEPENDS_TARGET_SRC_DEPS: List of cpp sources for extension library (for generating a DEPFILE).
 #   IMPORT_PATHS: List of paths to add to PYTHONPATH for stubgen.
 #   PATTERN_FILE: (Optional) Pattern file (see https://nanobind.readthedocs.io/en/latest/typing.html#pattern-files).
+#   VERBOSE: Emit logging/status messages during stub generation (default: OFF).
 # Outputs:
 #   NB_STUBGEN_CUSTOM_TARGET: The target corresponding to generation which other targets can depend on.
 function(mlir_generate_type_stubs)
   cmake_parse_arguments(ARG
-    ""
+    "VERBOSE"
     "MODULE_NAME;OUTPUT_DIR;PATTERN_FILE"
     "IMPORT_PATHS;DEPENDS_TARGETS;OUTPUTS;DEPENDS_TARGET_SRC_DEPS"
     ${ARGN})
@@ -152,6 +153,9 @@ function(mlir_generate_type_stubs)
       --include-private
       --output-dir
       "${ARG_OUTPUT_DIR}")
+  if(NOT ARG_VERBOSE)
+    list(APPEND _nb_stubgen_cmd "--quiet")
+  endif()
   if(ARG_PATTERN_FILE)
     list(APPEND _nb_stubgen_cmd "-p;${ARG_PATTERN_FILE}")
     list(APPEND ARG_DEPENDS_TARGETS "${ARG_PATTERN_FILE}")
@@ -166,7 +170,9 @@ function(mlir_generate_type_stubs)
     file(GENERATE OUTPUT "${_depfile}" CONTENT "${_depfiles}")
   endif()
 
-  message(DEBUG "Generating type-stubs outputs ${_generated_type_stubs}")
+  if(ARG_VERBOSE)
+    message(STATUS "Generating type-stubs outputs ${_generated_type_stubs}")
+  endif()
   add_custom_command(
     OUTPUT ${_generated_type_stubs}
     COMMAND ${_nb_stubgen_cmd}
diff --git a/mlir/examples/standalone/python/CMakeLists.txt b/mlir/examples/standalone/python/CMakeLists.txt
index d48c5bcdde137..5404128e5fa27 100644
--- a/mlir/examples/standalone/python/CMakeLists.txt
+++ b/mlir/examples/standalone/python/CMakeLists.txt
@@ -92,6 +92,7 @@ if(NOT EXTERNAL_PROJECT_BUILD)
     OUTPUTS "${_core_type_stub_sources}"
     DEPENDS_TARGET_SRC_DEPS "${_core_extension_srcs}"
     IMPORT_PATHS "${StandalonePythonModules_ROOT_PREFIX}/_mlir_libs"
+    VERBOSE
   )
   set(_mlir_typestub_gen_target "${NB_STUBGEN_CUSTOM_TARGET}")
 



More information about the Mlir-commits mailing list