Skip to content

Commit 1810c74

Browse files
committed
feat: Add pyproject.toml for project configuration and dependencies
1 parent 7eac853 commit 1810c74

File tree

3 files changed

+94
-0
lines changed

3 files changed

+94
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# CEDARScript (Concise Examination, Development, And Refactoring Script)
22

3+
[![PyPI version](https://badge.fury.io/py/cedarscript-grammar.svg)](https://pypi.org/project/cedarscript-grammar/)
4+
35
## A SQL-like language for code analysis and transformations
46

57
`CEDARScript` is a SQL-like language designed to _concisely_:

cedarscript_grammar/__init__.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import logging
2+
import sys
3+
from pathlib import Path
4+
5+
from tree_sitter import Language
6+
7+
__version__ = "0.0.3"
8+
__all__ = ("language",)
9+
10+
_ROOT_DIR = Path(__file__).parent
11+
12+
13+
# Explicitly cast to str as tree_sitter.Language.build expects str
14+
_SHARED_LIB_PATH = str((_ROOT_DIR / "cedarscript.so").absolute())
15+
16+
17+
def language() -> Language:
18+
"""Load the tree-sitter library for CEDARScript."""
19+
20+
logger = logging.getLogger(__name__)
21+
logger.setLevel("DEBUG")
22+
23+
# Determine the appropriate library file based on the current architecture
24+
if sys.platform.startswith('darwin'):
25+
lib_name = 'libtree-sitter-cedar.dylib'
26+
elif sys.platform.startswith('linux'):
27+
lib_name = 'libtree-sitter-cedar.so'
28+
else:
29+
raise OSError(f"Unsupported platform: {sys.platform}")
30+
31+
# Explicitly cast to str as tree_sitter.Language.build expects str
32+
cedar_language_path = str((_ROOT_DIR / lib_name).absolute())
33+
# cedar_language_path = os.path.abspath(os.path.join(_ROOT_DIR, lib_name))
34+
logger.warning(f"[{__name__}] Loading native CEDARScript parsing library from {cedar_language_path}")
35+
return Language(cedar_language_path, "CEDARScript")

pyproject.toml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
[build-system]
2+
requires = ["setuptools>=61.0", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "cedarscript_grammar"
7+
version = "0.0.3"
8+
description = "CEDARScript grammar.js for tree-sitter"
9+
authors = [
10+
{name = "Elifarley", email = "cedarscript@orgecc.com"},
11+
]
12+
readme = "README.md"
13+
license = {text = "MIT"}
14+
classifiers = [
15+
"Development Status :: 3 - Alpha",
16+
"Intended Audience :: Developers",
17+
"License :: OSI Approved :: MIT License",
18+
"Programming Language :: Python :: 3",
19+
"Programming Language :: Python :: 3.9",
20+
"Programming Language :: Python :: 3.10",
21+
"Programming Language :: Python :: 3.11",
22+
"Topic :: Software Development :: Compilers",
23+
"Topic :: Text Processing :: Linguistic",
24+
"Typing :: Typed"
25+
]
26+
keywords = ["incremental", "parsing", "tree-sitter", "cedarscript", "shared-library", "dylib", "so", "python-binding"]
27+
requires-python = ">=3.9"
28+
dependencies = [
29+
"tree-sitter~=0.21",
30+
]
31+
32+
[project.urls]
33+
Homepage = "https://github.com/CEDARScript/cedarscript-grammar#readme"
34+
"Bug Tracker" = "https://github.com/CEDARScript/cedarscript-grammar/issues"
35+
36+
[tool.setuptools]
37+
packages = ["cedarscript_grammar"]
38+
39+
[tool.setuptools.package-data]
40+
cedarscript_grammar = ["py.typed", "*.so", "*.dylib", "*.dll"]
41+
42+
[tool.setuptools.dynamic]
43+
version = {attr = "cedarscript_grammar.__version__"}
44+
45+
[tool.black]
46+
line-length = 100
47+
target-version = ['py39']
48+
49+
[tool.isort]
50+
profile = "black"
51+
line_length = 100
52+
53+
[tool.mypy]
54+
python_version = "3.9"
55+
strict = true
56+
warn_return_any = true
57+
warn_unused_configs = true

0 commit comments

Comments
 (0)