-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
129 lines (111 loc) · 4.37 KB
/
setup.py
File metadata and controls
129 lines (111 loc) · 4.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
from __future__ import annotations
import subprocess
import re
import sys
from pathlib import Path
from pybind11.setup_helpers import Pybind11Extension, build_ext
from setuptools import setup
def package_version() -> str:
meta = Path("python/markql/_meta.py").read_text(encoding="utf-8")
match = re.search(r'__version__\s*=\s*"([0-9]+\.[0-9]+\.[0-9]+)"', meta)
if not match:
raise RuntimeError("Could not parse __version__ from python/markql/_meta.py")
return match.group(1)
PACKAGE_VERSION = package_version()
def git_commit_short() -> str:
try:
out = subprocess.check_output(["git", "rev-parse", "--short=12", "HEAD"], text=True)
return out.strip() or "unknown"
except Exception:
return "unknown"
def git_dirty_flag() -> str:
try:
result = subprocess.call(["git", "diff", "--quiet", "--ignore-submodules", "HEAD", "--"])
return "0" if result == 0 else "1"
except Exception:
return "0"
def core_sources() -> list[str]:
sources = [
"python/markql/_core.cpp",
"core/src/version.cpp",
"core/src/helper/helper_controller.cpp",
"core/src/helper/helper_json.cpp",
"core/src/helper/helper_policy.cpp",
"core/src/helper/helper_result_analysis.cpp",
"core/src/lang/ast.cpp",
"core/src/lang/diagnostics.cpp",
"core/src/lang/diagnostics_parse_support.cpp",
"core/src/lang/diagnostics_details.cpp",
"core/src/lang/diagnostics_render.cpp",
"core/src/lang/markql_parser.cpp",
"core/src/lang/parser/parser.cpp",
"core/src/lang/parser/parser_expr.cpp",
"core/src/lang/parser/parser_expr_scalar.cpp",
"core/src/lang/parser/parser_query.cpp",
"core/src/lang/parser/parser_select.cpp",
"core/src/lang/parser/parser_select_extract.cpp",
"core/src/lang/parser/parser_source.cpp",
"core/src/lang/parser/parser_util.cpp",
"core/src/lang/parser/lexer.cpp",
"core/src/dom/html_parser.cpp",
"core/src/dom/backend/parser_naive.cpp",
"core/src/dom/backend/parser_libxml2.cpp",
"core/src/runtime/executor/executor.cpp",
"core/src/runtime/executor/filter.cpp",
"core/src/runtime/executor/filter_scalar.cpp",
"core/src/runtime/executor/order.cpp",
"core/src/util/string_util.cpp",
"core/src/runtime/engine/execute.cpp",
"core/src/runtime/engine/execute_common.cpp",
"core/src/runtime/engine/execute_dom_descendants.cpp",
"core/src/runtime/engine/execute_dom_projection.cpp",
"core/src/runtime/engine/execute_dom.cpp",
"core/src/runtime/engine/execute_fragments.cpp",
"core/src/runtime/engine/execute_lint.cpp",
"core/src/runtime/engine/execute_meta.cpp",
"core/src/runtime/engine/execute_output.cpp",
"core/src/runtime/engine/execute_relation_join.cpp",
"core/src/runtime/engine/execute_relation_expr.cpp",
"core/src/runtime/engine/execute_relation_result.cpp",
"core/src/runtime/engine/execute_relation.cpp",
"core/src/runtime/engine/execute_source.cpp",
"core/src/runtime/engine/query_validation_entry.cpp",
"core/src/runtime/engine/io.cpp",
"core/src/runtime/engine/column_names.cpp",
"core/src/runtime/engine/query_validation_rules.cpp",
"core/src/runtime/engine/result_builder.cpp",
"core/src/runtime/engine/table_extract.cpp",
"core/src/runtime/engine/tfidf.cpp",
]
return sources
def platform_compile_args() -> list[str]:
if sys.platform == "win32":
return ["/bigobj", "/utf-8"]
return []
ext_modules = [
Pybind11Extension(
"markql._core",
core_sources(),
include_dirs=[
"core/include",
"core/src",
"core/src/lang",
"core/src/dom",
"core/src/runtime",
"core/src/util",
],
define_macros=[
("MARKQL_VERSION", f'"{PACKAGE_VERSION}"'),
("MARKQL_GIT_COMMIT", f'"{git_commit_short()}"'),
("MARKQL_GIT_DIRTY", git_dirty_flag()),
("MARKQL_WITH_ARTIFACTS", "0"),
],
extra_compile_args=platform_compile_args(),
cxx_std=20,
)
]
setup(
ext_modules=ext_modules,
cmdclass={"build_ext": build_ext},
entry_points={"console_scripts": ["markql-helper=markql.helper.cli:main"]},
)