sublime-treesitter / TreeSitter

Sublime Text Tree-sitter configuration and abstraction layer
MIT License
19 stars 1 forks source link

Fails compiling languages on Windows #3

Closed deathaxe closed 7 months ago

deathaxe commented 7 months ago

Not familiar with TreeSitter at all, but this package fails to compile languages on Windows 11 x64, with python 3.8 installed.

Tree-sitter: Python bindings installed at "<st_path>\Packages\TreeSitter\deps"
Tree-sitter: language repos and .so files installed at "<st_path>\Packages\TreeSitter\build"
Tree-sitter: installing tree-sitter/tree-sitter-python repo for python language
git: tracking working dir <st_path>\Packages\TreeSitter\build\tree-sitter-python
Package Control: Removed orphaned library "tree_sitter" for Python 3.8
Tree-sitter: installing tree-sitter/tree-sitter-json repo for json language
git: tracking working dir <st_path>\Packages\TreeSitter\build\tree-sitter-json
Tree-sitter: building python language from files at tree-sitter-python
Exception in thread Thread-7:
Traceback (most recent call last):
  File "./python3.8/threading.py", line 932, in _bootstrap_inner
  File "./python3.8/threading.py", line 870, in run
  File "<st_path>\Packages\TreeSitter\src\core.py", line 492, in install_languages
    build_languages()
  File "<st_path>\Packages\TreeSitter\src\core.py", line 221, in build_languages
    subprocess.run(
  File "./python3.8/subprocess.py", line 516, in run
subprocess.CalledProcessError: Command '['python.exe', '<st_path>\\Data\\Packages\\TreeSitter\\src\\build.py', '<st_path>\\Data\\Packages\\TreeSitter\\build\\tree-sitter-python', '<st_path>\\Data\\Packages\\TreeSitter\\build\\language-python.so']' returned non-zero exit status 1.

When trying to invoke build command, manually via ST's built-in interpreter it seems, the package requires a C++ compiler (or better ms build tools) to be present in order to be functional.

>>> from tree_sitter import Language
>>> import os
>>> Language.build_library(os.path.join(sublime.package_path(), "TreeSitter/build/langs.so"), [os.path.join(sublime.package_path(), "TreeSitter/build/tree-sitter-json")])
Traceback (most recent call last):
  File "__main__", line 1, in <module>
AttributeError: module 'sublime' has no attribute 'package_path'
>>> Language.build_library(os.path.join(sublime.packages_path(), "TreeSitter/build/langs.so"), [os.path.join(sublime.packages_path(), "TreeSitter/build/tree-sitter-json")])
Traceback (most recent call last):
  File "__main__", line 1, in <module>
  File "C:\Apps\Sublime Text\Data\Lib\python38\tree_sitter\__init__.py", line 111, in build_library
    compiler.compile(
  File "./python3.8/distutils/_msvccompiler.py", line 327, in compile
  File "./python3.8/distutils/_msvccompiler.py", line 224, in initialize
  File "./python3.8/distutils/_msvccompiler.py", line 126, in _get_vc_env
distutils.errors.DistutilsPlatformError: Unable to find vcvarsall.bat
kylebebak commented 7 months ago

This is closed by this release: https://github.com/sublime-treesitter/TreeSitter/releases/tag/1.1.0

STS now bundles tree_sitter and tree_sitter_languages as dependencies. Setting python_path is no longer required. Thanks deathaxe and kaste

See more context here: https://github.com/wbond/package_control_channel/pull/8862#issuecomment-1916027470