Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

2.0 KB
Raw Blame
import platform

from setuptools import Extension, setup

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",
        "json.cpp",
        "parser_python.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.3.85",
    url="https://github.com/PostHog/posthog/tree/master/common/hogql_parser",
    description="HogQL parser for internal PostHog use",
    author="PostHog Inc.",
    author_email="[email protected]",
    maintainer="PostHog Inc.",
    maintainer_email="[email protected]",
    long_description=open("README.md").read(),
    long_description_content_type="text/markdown",
    packages=["hogql_parser-stubs"],
    include_package_data=True,
    ext_modules=[module],
    python_requires=">=3.10",
    license="MIT",
    classifiers=[
        "Development Status :: 5 - Production/Stable",
        "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",
        "Programming Language :: Python :: 3.13",
        "Programming Language :: Python :: 3.14",
    ],
)