Commit 3c740a1b authored by Zhao Wu's avatar Zhao Wu Committed by LeiWang1999
Browse files

[Enhancement] Support to find Cython path more automatically (#418)



* Support to find Cython path more automatically

* lint fix

---------
Co-authored-by: default avatarLeiWang1999 <leiwang1999@outlook.com>
parent 73a6cb8b
......@@ -23,6 +23,7 @@ import os
import fcntl
from pathlib import Path
import logging
import site
logger = logging.getLogger(__name__)
......@@ -37,7 +38,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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment