-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.template
130 lines (112 loc) · 4.03 KB
/
setup.template
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
130
import fnmatch
import os
import platform
from pathlib import Path
from typing import List
from setuptools import Extension, setup, find_packages
from fugue_sql_antlr_version import __version__
with open("README.md") as f:
_text = ["# Fugue SQL Antlr Parser"] + f.read().splitlines()[1:]
LONG_DESCRIPTION = "\n".join(_text)
def package_files(directory: str) -> List[str]:
files = [str(x)[len(directory) + 1 :] for x in Path(directory).glob("*/**/*")]
return files
def get_version() -> str:
tag = os.environ.get("RELEASE_TAG", "")
if "dev" in tag.split(".")[-1]:
return tag
if tag != "":
assert tag == __version__, "release tag and version mismatch"
return __version__
def get_files(path: str, pattern: str) -> List[str]:
"""
Recursive file search that is compatible with python3.4 and older
"""
matches = []
for root, _, filenames in os.walk(path):
for filename in fnmatch.filter(filenames, pattern):
matches.append(os.path.join(root, filename))
return matches
def get_target() -> str:
target = platform.system().lower()
for known in ["windows", "linux", "darwin", "cygwin"]:
if target.startswith(known):
return known
return target
def get_ext_modules() -> List[str]:
if not _BUILD_CPP:
return []
extra_compile_args = {
"windows": ["/DANTLR4CPP_STATIC", "/Zc:__cplusplus", "/std:c++17"],
"linux": ["-std=c++17"],
"darwin": ["-std=c++17"],
"cygwin": ["-std=c++17"],
}
# Define an Extension object that describes the Antlr accelerator
parser_ext = Extension(
name="fugue_sql_antlr_cpp.sa_fugue_sql_cpp_parser",
include_dirs=["fugue_sql_antlr_cpp/antlr4-cpp-runtime"],
sources=get_files("fugue_sql_antlr_cpp/src", "*.cpp")
+ get_files("fugue_sql_antlr_cpp/antlr4-cpp-runtime", "*.cpp"),
depends=get_files("fugue_sql_antlr_cpp/src", "*.h")
+ get_files("fugue_sql_antlr_cpp/antlr4-cpp-runtime", "*.h"),
extra_compile_args=extra_compile_args.get(get_target(), []),
)
return [parser_ext]
def get_packages():
pkgs = find_packages()
if _BUILD_CPP:
return [
x
for x in pkgs
if x.split(".")[0] in ["fugue_sql_antlr_cpp", "fugue_sql_antlr_version"]
]
return [
x
for x in pkgs
if x.split(".")[0] in ["fugue_sql_antlr", "fugue_sql_antlr_version"]
]
setup(
name="fugue-sql-antlr-cpp" if _BUILD_CPP else "fugue-sql-antlr",
version=get_version(),
packages=get_packages(),
description="Fugue SQL Antlr C++ Parser"
if _BUILD_CPP
else "Fugue SQL Antlr Parser",
long_description=LONG_DESCRIPTION,
long_description_content_type="text/markdown",
license="Apache-2.0",
author="The Fugue Development Team",
author_email="[email protected]",
keywords="distributed spark dask sql dsl domain specific language",
url="http://github.com/fugue-project/fugue",
install_requires=[
"triad>=0.6.8",
"antlr4-python3-runtime<4.12",
"jinja2",
"packaging",
],
extras_require={}
if _BUILD_CPP
else {
"cpp": ["fugue-sql-antlr-cpp==" + get_version()],
"test": ["speedy_antlr_tool"],
},
classifiers=[
# "3 - Alpha", "4 - Beta" or "5 - Production/Stable"
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries :: Python Modules",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3 :: Only",
],
python_requires=">=3.8",
package_data={"fugue_sql_antlr_cpp": package_files("fugue_sql_antlr_cpp")},
ext_modules=get_ext_modules(),
)