Skip to content

Commit

Permalink
✅ Fix pytest in macosx
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Feb 15, 2024
1 parent a09a368 commit 22d788a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 25 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
_version.py

# create by https://github.com/iamcco/coc-gitignore (Thu Nov 30 2023 16:50:01 GMT+0800 (China Standard Time))
# Node.gitignore:
# Logs
Expand Down
21 changes: 13 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,32 @@ if(NOT VERSION)
endif()
if(ENV{GITHUB_REPOSITORY})
set(HOMEPAGE_URL "https://github.com/$ENV{GITHUB_REPOSITORY}")
string(REGEX REPLACE ".*/tree-sitter-([^/]*)$" "\\1" LANGUAGE $ENV{GITHUB_REPOSITORY})
string(REGEX REPLACE ".*/tree-sitter-([^/]*)$" "\\1" NAME $ENV{GITHUB_REPOSITORY})
else()
set(HOMEPAGE_URL "")
file(GLOB LANGUAGE "${CMAKE_CURRENT_SOURCE_DIR}/bindings/python/*")
string(REGEX REPLACE ".*/tree_sitter_([^/]*)$" "\\1" LANGUAGE ${LANGUAGE})
file(GLOB NAME "${CMAKE_CURRENT_SOURCE_DIR}/bindings/python/*")
string(REGEX REPLACE ".*/tree_sitter_([^/]*)$" "\\1" NAME ${NAME})
endif()
project(
tree-sitter-${LANGUAGE}
tree-sitter-${NAME}
VERSION ${VERSION}
DESCRIPTION tree-sitter-${LANGUAGE}
DESCRIPTION tree-sitter-${NAME}
HOMEPAGE_URL "${HOMEPAGE_URL}")
include_directories(src)
add_library(${LANGUAGE} SHARED src/parser.c)
set_target_properties(${LANGUAGE} PROPERTIES PREFIX "")
add_library(${NAME} SHARED src/parser.c)
set_target_properties(${NAME} PROPERTIES PREFIX "")
if(DEFINED SKBUILD_DATA_DIR)
set(CMAKE_INSTALL_FULL_LIBDIR ${SKBUILD_DATA_DIR}/lib)
endif()
# https://docs.python.org/3/library/ctypes.html#finding-shared-libraries
if(DEFINED SKBUILD_PLATLIB_DIR)
# it may be better to determine the shared library name at development time, and hardcode that into the wrapper module
configure_file(__init__.py.in ${SKBUILD_PLATLIB_DIR}/tree_sitter_${NAME}/__init__.py)
endif()
if(NOT DEFINED CMAKE_INSTALL_FULL_LIBDIR)
include(GNUInstallDirs)
endif()
install(TARGETS ${LANGUAGE} DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/parser)
install(TARGETS ${NAME} DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/parser)

set(CPACK_PACKAGE_CONTACT ${HOMEPAGE_URL}/issues)
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Wu Zhenyu <wuzhenyu@ustc.edu>")
Expand Down
15 changes: 3 additions & 12 deletions ...ngs/python/tree_sitter_muttrc/__init__.py → __init__.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,9 @@

from tree_sitter import Language, Parser

from . import __name__ as NAME

NAME = NAME.split("_")[-1]
DLL = sysconfig.get_config_var("SHLIB_SUFFIX")
if DLL is None:
DLL = ".dll"

try:
from ._version import __version__, __version_tuple__ # type: ignore
except ImportError: # for setuptools-generate
__version__ = "rolling"
__version_tuple__ = (0, 0, 0, __version__, "")
__version__ = "@VERSION@"
NAME = "@NAME@"
DLL = "@CMAKE_SHARED_LIBRARY_SUFFIX@"

paths = [
os.path.join(
Expand Down
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ experimental = true
provider = "scikit_build_core.metadata.setuptools_scm"

[tool.scikit-build.sdist]
include = ["bindings/python/tree_sitter_muttrc/_version.py", "py.typed"]
include = ["py.typed"]

[tool.scikit-build.wheel]
packages = ["bindings/python/tree_sitter_muttrc"]
Expand All @@ -72,7 +72,6 @@ file = "requirements/dev.txt"
# end: scripts/update-pyproject.toml.pl

[tool.setuptools_scm]
write_to = "bindings/python/tree_sitter_muttrc/_version.py"

[tool.mdformat]
number = true
Expand Down Expand Up @@ -119,6 +118,6 @@ exclude_lines = [
archs = ["all"]
skip = "*37-* *38-* *39-*"
# https://github.com/pypa/cibuildwheel/issues/287#issuecomment-1937451870
test-skip = "*-win32 *-macosx_*"
test-skip = "*-win32"
before-test = "pip install -rrequirements.txt -rrequirements/dev.txt"
test-command = "pytest {project}"

0 comments on commit 22d788a

Please sign in to comment.