Skip to content

Commit

Permalink
feat: support Python 3.12 again
Browse files Browse the repository at this point in the history
Only Language.build_library will not be supported
  • Loading branch information
ObserverOfTime committed Mar 19, 2024
1 parent 52f29fa commit cf1c8e9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ concurrency:
jobs:
build_asan:
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch'
env:
PYTHON_VERSION: "3.8"
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
CIBW_ARCHS_WINDOWS: AMD64
CIBW_ARCHS_LINUX: x86_64
CIBW_ARCHS_MACOS: x86_64 arm64
CIBW_TEST_SKIP: "*arm64"
CIBW_TEST_SKIP: cp12* *arm64
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "tree-sitter"
version = "0.21.0"
version = "0.21.1"
description = "Python bindings for the Tree-Sitter parsing library"
keywords = ["incremental", "parsing", "tree-sitter"]
classifiers = [
Expand All @@ -17,7 +17,7 @@ classifiers = [
"Topic :: Text Processing :: Linguistic",
"Typing :: Typed",
]
requires-python = ">=3.8,<3.12"
requires-python = ">=3.8"
readme = "README.md"

[project.urls]
Expand Down
16 changes: 10 additions & 6 deletions tree_sitter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from os import path
from platform import system
from tempfile import TemporaryDirectory
from typing import Callable, List, Optional, Union
from typing import List, Optional, Union
from warnings import warn

from tree_sitter._binding import (
Expand Down Expand Up @@ -83,10 +83,14 @@ def build_library(output_path: str, repo_paths: List[str]) -> bool:
if max(source_mtimes) <= output_mtime:
return False

# local import saves import time in the common case that nothing is
# compiled
from distutils.ccompiler import new_compiler
from distutils.unixccompiler import UnixCCompiler
# local import saves import time in the common case that nothing is compiled
try:
from distutils.ccompiler import new_compiler
from distutils.unixccompiler import UnixCCompiler
except ImportError as err:
raise RuntimeError(
"Failed to import distutils. You may need to install setuptools."
) from err

compiler = new_compiler()
if isinstance(compiler, UnixCCompiler):
Expand Down Expand Up @@ -126,7 +130,7 @@ def __init__(self, path_or_ptr: Union[str, int], name: str):
_deprecate("Language(path, name)", "Language(ptr, name)")
self.name = name
self.lib = cdll.LoadLibrary(path_or_ptr)
language_function: Callable[[], int] = getattr(self.lib, "tree_sitter_%s" % name)
language_function = getattr(self.lib, "tree_sitter_%s" % name)
language_function.restype = c_void_p
self.language_id = language_function()
elif isinstance(path_or_ptr, int):
Expand Down

0 comments on commit cf1c8e9

Please sign in to comment.