Skip to content

Commit 86ec2ed

Browse files
committed
Update setup.py and pyproject.toml
1 parent 46110a1 commit 86ec2ed

File tree

3 files changed

+66
-6
lines changed

3 files changed

+66
-6
lines changed

CMakeLists.txt

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
cmake_minimum_required(VERSION 3.13)
2+
3+
project(tree-sitter-elixir
4+
VERSION "0.3.4"
5+
DESCRIPTION "Elixir grammar for the tree-sitter parsing library"
6+
HOMEPAGE_URL "https://github.com/elixir-lang/tree-sitter-elixir"
7+
LANGUAGES C)
8+
9+
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
10+
option(TREE_SITTER_REUSE_ALLOCATOR "Reuse the library allocator" OFF)
11+
12+
set(TREE_SITTER_ABI_VERSION 14 CACHE STRING "Tree-sitter ABI version")
13+
if(NOT ${TREE_SITTER_ABI_VERSION} MATCHES "^[0-9]+$")
14+
unset(TREE_SITTER_ABI_VERSION CACHE)
15+
message(FATAL_ERROR "TREE_SITTER_ABI_VERSION must be an integer")
16+
endif()
17+
18+
find_program(TREE_SITTER_CLI tree-sitter DOC "Tree-sitter CLI")
19+
20+
add_custom_command(OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/src/parser.c"
21+
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/grammar.json"
22+
COMMAND "${TREE_SITTER_CLI}" generate src/grammar.json
23+
--abi=${TREE_SITTER_ABI_VERSION}
24+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
25+
COMMENT "Generating parser.c")
26+
27+
add_library(tree-sitter-elixir src/parser.c)
28+
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/scanner.c)
29+
target_sources(tree-sitter-elixir PRIVATE src/scanner.c)
30+
endif()
31+
target_include_directories(tree-sitter-elixir PRIVATE src)
32+
33+
target_compile_definitions(tree-sitter-elixir PRIVATE
34+
$<$<BOOL:${TREE_SITTER_REUSE_ALLOCATOR}>:TREE_SITTER_REUSE_ALLOCATOR>
35+
$<$<CONFIG:Debug>:TREE_SITTER_DEBUG>)
36+
37+
set_target_properties(tree-sitter-elixir
38+
PROPERTIES
39+
C_STANDARD 11
40+
POSITION_INDEPENDENT_CODE ON
41+
SOVERSION "${TREE_SITTER_ABI_VERSION}.${PROJECT_VERSION_MAJOR}"
42+
DEFINE_SYMBOL "")
43+
44+
configure_file(bindings/c/tree-sitter-elixir.pc.in
45+
"${CMAKE_CURRENT_BINARY_DIR}/tree-sitter-elixir.pc" @ONLY)
46+
47+
include(GNUInstallDirs)
48+
49+
install(FILES bindings/c/tree-sitter-elixir.h
50+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/tree_sitter")
51+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/tree-sitter-elixir.pc"
52+
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig")
53+
install(TARGETS tree-sitter-elixir
54+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
55+
56+
add_custom_target(ts-test "${TREE_SITTER_CLI}" test
57+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
58+
COMMENT "tree-sitter test")

pyproject.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ classifiers = [
1414
"Topic :: Text Processing :: Linguistic",
1515
"Typing :: Typed"
1616
]
17-
requires-python = ">=3.8"
18-
license.text = "MIT"
17+
requires-python = ">=3.9"
18+
license.text = "Apache-2.0"
1919
readme = "README.md"
2020

2121
[project.urls]
@@ -25,5 +25,5 @@ Homepage = "https://github.com/elixir-lang/tree-sitter-elixir"
2525
core = ["tree-sitter~=0.23"]
2626

2727
[tool.cibuildwheel]
28-
build = "cp38-*"
28+
build = "cp39-*"
2929
build-frontend = "build"

setup.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class BdistWheel(bdist_wheel):
1818
def get_tag(self):
1919
python, abi, platform = super().get_tag()
2020
if python.startswith("cp"):
21-
python, abi = "cp38", "abi3"
21+
python, abi = "cp39", "abi3"
2222
return python, abi, platform
2323

2424

@@ -40,13 +40,15 @@ def get_tag(self):
4040
],
4141
extra_compile_args=[
4242
"-std=c11",
43+
"-fvisibility=hidden",
4344
] if system() != "Windows" else [
4445
"/std:c11",
4546
"/utf-8",
4647
],
4748
define_macros=[
48-
("Py_LIMITED_API", "0x03080000"),
49-
("PY_SSIZE_T_CLEAN", None)
49+
("Py_LIMITED_API", "0x03090000"),
50+
("PY_SSIZE_T_CLEAN", None),
51+
("TREE_SITTER_HIDE_SYMBOLS", None),
5052
],
5153
include_dirs=["src"],
5254
py_limited_api=True,

0 commit comments

Comments
 (0)