0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-29 03:04:16 +01:00
posthog/hogql_parser/setup.py
Michael Matloka 21c699772c
chore(hogql): Use the C++ parser in 50% of queries (#18298)
* chore(hogql): Use the C++ parser in 50% of queries

* Ensure that C++ parser is used in tests deterministically

* Align table args behavior with Python

* Bump parser version to 1.0.1

* Use new hogql-parser version

* Don't add notices for internal expressions, like in Python

* Bump parser version to 1.0.2

* Use new hogql-parser version

* Update posthog/hogql/parser.py

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2023-11-01 11:52:44 +01:00

58 lines
1.8 KiB
Python

from setuptools import setup, Extension
import platform
system = platform.system()
if system not in ("Darwin", "Linux"):
raise Exception("Only Linux and macOS are supported by hogql_parser")
is_macos = system == "Darwin"
homebrew_location = "/opt/homebrew" if platform.machine() == "arm64" else "/usr/local"
module = Extension(
"hogql_parser",
sources=[
"HogQLLexer.cpp",
"HogQLParser.cpp",
"HogQLParserBaseVisitor.cpp",
"HogQLParserVisitor.cpp",
"error.cpp",
"string.cpp",
"parser.cpp",
],
include_dirs=[
f"{homebrew_location}/include/",
f"{homebrew_location}/include/antlr4-runtime/",
]
if is_macos
else ["/usr/include/", "/usr/include/antlr4-runtime/"],
library_dirs=[f"{homebrew_location}/lib/"] if is_macos else ["/usr/lib/", "/usr/lib64/"],
libraries=["antlr4-runtime"],
extra_compile_args=["-std=c++20"],
)
setup(
name="hogql_parser",
version="1.0.2",
url="https://github.com/PostHog/posthog/tree/master/hogql_parser",
author="PostHog Inc.",
author_email="hey@posthog.com",
maintainer="PostHog Inc.",
maintainer_email="hey@posthog.com",
description="HogQL parser for internal PostHog use",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
package_data={"hogql_parser": ["__init__.pyi", "py.typed"]},
ext_modules=[module],
python_requires=">=3.10",
classifiers=[
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: MIT License",
"Operating System :: MacOS",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
],
)