From 73e68ddb82675849bbe4e949b24be0a8ea7c317c Mon Sep 17 00:00:00 2001 From: Hao Wu Date: Sun, 27 Sep 2026 14:09:35 -0400 Subject: [PATCH 1/2] [FIX] Import pytest only when a CLI runs pytest tilelens.wrapper imported pytest at module level, but pytest is only in the test extra. After a plain `pip install tilelens`, tile-sanitizer, tile-profiler, tile-race and their triton-* aliases all failed with ModuleNotFoundError before running anything. pytest is now imported in the branch that forwards to pytest.main, the only place it is used. Add a test that imports tilelens.wrapper in a subprocess with pytest blocked. --- tests/unit/test_wrapper.py | 10 ++++++++++ tilelens/wrapper.py | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/unit/test_wrapper.py b/tests/unit/test_wrapper.py index 266cd1c1..12c47896 100644 --- a/tests/unit/test_wrapper.py +++ b/tests/unit/test_wrapper.py @@ -1,3 +1,6 @@ +import subprocess +import sys + import pytest from unittest.mock import MagicMock, patch @@ -246,3 +249,10 @@ def test_apply_wrapper_rejects_non_cli_invocation(): apply_sanitizer() with pytest.raises(RuntimeError, match="must be used as a CLI tool"): apply_profiler() + + +def test_wrapper_imports_without_pytest(): + """The CLIs import tilelens.wrapper; pytest is only a test extra.""" + code = "import sys; sys.modules['pytest'] = None; import tilelens.wrapper" + proc = subprocess.run([sys.executable, "-c", code], capture_output=True, text=True) + assert proc.returncode == 0, proc.stderr diff --git a/tilelens/wrapper.py b/tilelens/wrapper.py index 264700d3..d2759da8 100644 --- a/tilelens/wrapper.py +++ b/tilelens/wrapper.py @@ -2,7 +2,6 @@ import shutil import runpy import sys -import pytest import triton import tilelens from triton.experimental import gluon as _gluon @@ -132,6 +131,10 @@ def _apply_wrapper(wrapper_func, command_name, usage_msg): # Check if it's an executable command if shutil.which(cmd[0]): if cmd[0] == "pytest": + # pytest is only a test extra; import it just for this branch + # so the CLIs work in a plain `pip install tilelens`. + import pytest + sys.exit(pytest.main(cmd[1:])) elif cmd[0] == "python": sys.argv = cmd[1:] From a0e5f834b8377548ec5f76174199ea75ed20746d Mon Sep 17 00:00:00 2001 From: Hao Wu Date: Sun, 27 Sep 2026 14:09:38 -0400 Subject: [PATCH 2/2] [MISC] Bump version to 3.1.1 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 0cb0879d..2c1973ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta" [project] name = "tilelens" -version = "3.1" +version = "3.1.1" description = "A visualization tool for Triton" authors = [ {name = "Deep Learning Profiling Tools Team", email = "kzhou6@gmu.edu"}