Skip to content

Commit

Permalink
Skip language build, use pre-built get_language
Browse files Browse the repository at this point in the history
  • Loading branch information
minhna1112 committed Jul 1, 2024
1 parent f70f5eb commit 44fafa1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/codetext/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,17 @@ def parse_code(raw_code: str, language: str='Auto', tree_sitter_path: str=None)
parser = Parser()
try:
from tree_sitter_languages import get_language, get_parser
parser = get_parser(get_language(language))
language = get_language(language)
except ImportError:
# Work-around when pre-built binaries wheels for tree-sitter-languages are not available
logger.warning(f"Troubled importing 'tree-sitter-languages', attemp to look for pre-built binaries in the workspace")
ts_lang_path = os.path.join(load_path, 'tree-sitter', f'{language}.so')
if not os.path.exists(ts_lang_path):
logger.warning(f"Not found `{language}.so` in `{load_path}/tree-sitter/`, attemp to build language")
build_language(language, load_path)
language = Language(load_path + f"/tree-sitter/{language}.so", language)
parser.set_language(language)
language = Language(load_path + f"/tree-sitter/{language}.so", language)
parser.set_language(language)

if isinstance(raw_code, str):
raw_code = bytes(raw_code, 'utf8')
elif isinstance(raw_code, bytes):
Expand Down

0 comments on commit 44fafa1

Please sign in to comment.