diff --git a/binding.gyp b/binding.gyp index c946f3c..cb24f1f 100644 --- a/binding.gyp +++ b/binding.gyp @@ -17,6 +17,7 @@ ["OS!='win'", { "cflags_c": [ "-std=c11", + "-fPIC" ], }, { # OS == "win" "cflags_c": [ diff --git a/bindings/python/tree_sitter_powershell/__init__.pyi b/bindings/python/tree_sitter_powershell/__init__.pyi index 5416666..0130edf 100644 --- a/bindings/python/tree_sitter_powershell/__init__.pyi +++ b/bindings/python/tree_sitter_powershell/__init__.pyi @@ -1 +1,6 @@ -def language() -> int: ... +from typing import Final + +HIGHLIGHTS_QUERY: Final[str] +TAGS_QUERY: Final[str] + +def language() -> object: ... diff --git a/package.json b/package.json index 10adbd7..39f3ee4 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { "name": "tree-sitter-powershell", - "version": "0.24.4", + "version": "1.2.0", "description": "", "main": "bindings/node", "types": "bindings/node", "scripts": { "generate": "tree-sitter generate", - "build-node": "tree-sitter generate && node-gyp build", + "build-node": "tree-sitter generate --no-bindings", "test": "tree-sitter test", "parse": "tree-sitter parse", "parse-debug": "tree-sitter parse -d", @@ -31,8 +31,21 @@ "devDependencies": { "node-gyp": "^9.4.0", "prebuildify": "^6.0.0", - "tree-sitter-cli": "0.24.4" + "tree-sitter-cli": "^0.22.6" }, + "tree-sitter": [ + { + "scope": "source.ps1", + "file-types": [ + "ps1", + "psm1" + ], + "injection-regex": "^(ps1|psm1)$", + "highlights": [ + "queries/highlights.scm" + ] + } + ], "files": [ "grammar.js", "binding.gyp", diff --git a/pyproject.toml b/pyproject.toml index d3b8a9e..fa47479 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,28 +2,26 @@ requires = ["setuptools>=42", "wheel"] build-backend = "setuptools.build_meta" -[project] +[tool.poetry] name = "tree-sitter-powershell" -description = "Powershell grammar for tree-sitter" version = "0.0.1" +description = "PowerShell grammar for tree-sitter" +authors = ["Your Name "] +license = "MIT" +readme = "README.md" +homepage = "https://github.com/tree-sitter/tree-sitter-powershell" keywords = ["incremental", "parsing", "tree-sitter", "powershell"] -classifiers = [ - "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", - "Topic :: Software Development :: Compilers", - "Topic :: Text Processing :: Linguistic", - "Typing :: Typed" +include = [ + "src/*", + "bindings/python/tree_sitter_powershell/binding.c" ] -requires-python = ">=3.8" -license.text = "MIT" -readme = "README.md" -[project.urls] -Homepage = "https://github.com/tree-sitter/tree-sitter-powershell" -[project.optional-dependencies] -core = ["tree-sitter=0.24"] +[tool.poetry.dependencies] +python = ">=3.11" +tree-sitter = { version = "^0.23", optional = true } + [tool.cibuildwheel] -build = "cp38-*" +build = "cp39-*" build-frontend = "build" diff --git a/setup.py b/setup.py index fb798c0..2655f69 100644 --- a/setup.py +++ b/setup.py @@ -16,10 +16,10 @@ def run(self): class BdistWheel(bdist_wheel): def get_tag(self): - python, abi, platform = super().get_tag() - if python.startswith("cp"): - python, abi = "cp38", "abi3" - return python, abi, platform + powershell, abi, platform = super().get_tag() + if powershell.startswith("cp"): + powershell, abi = "cp39", "abi3" + return powershell, abi, platform setup( @@ -36,17 +36,19 @@ def get_tag(self): sources=[ "bindings/python/tree_sitter_powershell/binding.c", "src/parser.c", - # NOTE: if your language uses an external scanner, add it here. + "src/scanner.c", ], extra_compile_args=[ "-std=c11", + "-fvisibility=hidden", ] if system() != "Windows" else [ "/std:c11", "/utf-8", ], define_macros=[ - ("Py_LIMITED_API", "0x03080000"), - ("PY_SSIZE_T_CLEAN", None) + ("Py_LIMITED_API", "0x03090000"), + ("PY_SSIZE_T_CLEAN", None), + ("TREE_SITTER_HIDE_SYMBOLS", None), ], include_dirs=["src"], py_limited_api=True,