This is an automated email from the ASF dual-hosted git repository.

tqchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new bf45326720 [Fix][Python] Keep the Windows config CLI independent of 
native imports (#20791)
bf45326720 is described below

commit bf45326720b72904c8bff73c19f53b89ba92d671
Author: Darssal <[email protected]>
AuthorDate: Tue Oct 20 00:39:51 2026 +0800

    [Fix][Python] Keep the Windows config CLI independent of native imports 
(#20791)
    
    The Windows `tvm-config.exe` console entry point tries to initialize the
    native TVM package before handling configuration options. pip's launcher
    imports `tvm.config.__main__` before removing the `.exe` suffix from
    `sys.argv[0]`, while the package's config-mode check only recognizes
    `tvm-config`. Consequently even `tvm-config.exe --includedir` fails when
    native dependencies are unavailable, although `python -m tvm.config
    --includedir` works.
    
    Recognize both console entry-point basenames, following the existing
    `tvm_tirx` configuration guard. The change is limited to config-mode
    detection before native initialization.
    
    Local validation on Windows with Python 3.11:
    
    - Subprocess probes for the Windows console name, POSIX console name,
    and `python -m tvm.config` pass using `-S` and the real source package,
    without site-package dependencies. The Windows console case fails with
    the original guard.
    - An actual Windows launcher generated by pip's
    `distlib.scripts.ScriptMaker` failed with `ModuleNotFoundError: tvm_ffi`
    before the fix. After the fix, `--includedir`, `--cflags`, and
    `--cxxflags` returned the expected header path and compiler flags.
    - Changed-file pre-commit checks passed, including Ruff, formatting, ASF
    headers, and file checks.
---
 python/tvm/__init__.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/python/tvm/__init__.py b/python/tvm/__init__.py
index 8952ca68b3..82491bdce7 100644
--- a/python/tvm/__init__.py
+++ b/python/tvm/__init__.py
@@ -18,6 +18,7 @@
 # pylint: disable=redefined-builtin, wildcard-import
 """TVM compiler dialects and runtime extensions built on TIRx."""
 
+import os
 import sys
 
 from typing import TYPE_CHECKING
@@ -25,7 +26,7 @@ from typing import TYPE_CHECKING
 
 def _is_config_mode() -> bool:
     """Recognize the config CLI before loading Python or native TVM 
components."""
-    if sys.argv[0].endswith("tvm-config"):
+    if os.path.basename(sys.argv[0]) in ("tvm-config", "tvm-config.exe"):
         return True
     argv = getattr(sys, "orig_argv", [])
     return any(arg == "-m" and argv[i + 1 : i + 2] == ["tvm.config"] for i, 
arg in enumerate(argv))

Reply via email to