From 82644c91662125491305092e5884194395872439 Mon Sep 17 00:00:00 2001 From: Zhao Wu Date: Mon, 21 Apr 2025 09:53:32 +0000 Subject: [PATCH 1/2] Support to find Cython path more automatically --- tilelang/jit/adapter/cython/adapter.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tilelang/jit/adapter/cython/adapter.py b/tilelang/jit/adapter/cython/adapter.py index a67dc6d9b..d7b8907f9 100644 --- a/tilelang/jit/adapter/cython/adapter.py +++ b/tilelang/jit/adapter/cython/adapter.py @@ -25,6 +25,7 @@ import fcntl from pathlib import Path import logging +import site logger = logging.getLogger(__name__) @@ -39,7 +40,23 @@ def get_cython_compiler() -> Optional[str]: """ cython_names = ["cython", "cython3"] - dirs_in_path = os.get_exec_path() + + # Check system PATH + dirs_in_path = list(os.get_exec_path()) + + # Add user site-packages bin directory + user_base = site.getuserbase() + if user_base: + user_bin = os.path.join(user_base, "bin") + if os.path.exists(user_bin): + dirs_in_path = [user_bin] + dirs_in_path + + # If in a virtual environment, add its bin directory + if sys.prefix != sys.base_prefix: + venv_bin = os.path.join(sys.prefix, "bin") + if os.path.exists(venv_bin): + dirs_in_path = [venv_bin] + dirs_in_path + for cython_name in cython_names: for d in dirs_in_path: cython_path = os.path.join(d, cython_name) From 2c8289717aa2a3bd27932d3c1d7a884a3bff4bbb Mon Sep 17 00:00:00 2001 From: LeiWang1999 Date: Mon, 21 Apr 2025 23:45:40 +0800 Subject: [PATCH 2/2] lint fix --- tilelang/jit/adapter/cython/adapter.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tilelang/jit/adapter/cython/adapter.py b/tilelang/jit/adapter/cython/adapter.py index d7b8907f9..ca164cfdc 100644 --- a/tilelang/jit/adapter/cython/adapter.py +++ b/tilelang/jit/adapter/cython/adapter.py @@ -40,17 +40,17 @@ def get_cython_compiler() -> Optional[str]: """ cython_names = ["cython", "cython3"] - + # Check system PATH dirs_in_path = list(os.get_exec_path()) - + # Add user site-packages bin directory user_base = site.getuserbase() if user_base: user_bin = os.path.join(user_base, "bin") if os.path.exists(user_bin): dirs_in_path = [user_bin] + dirs_in_path - + # If in a virtual environment, add its bin directory if sys.prefix != sys.base_prefix: venv_bin = os.path.join(sys.prefix, "bin")