mirror of
https://github.com/hanzo-ds/connect.git
synced 2026-10-30 20:31:24 +00:00
* simplify alembic wex, col settings & comments fixes * raise correct error
107 lines
3.9 KiB
Python
107 lines
3.9 KiB
Python
import os
|
|
import re
|
|
|
|
from setuptools import find_packages, setup
|
|
|
|
c_modules = []
|
|
|
|
try:
|
|
from Cython import __version__ as cython_version
|
|
from Cython.Build import cythonize
|
|
|
|
print(f"Using Cython {cython_version} to build cython modules")
|
|
c_modules = cythonize("clickhouse_connect/driverc/*.pyx", language_level="3str")
|
|
except ImportError as ex:
|
|
print("Cython Install Failed, Not Building C Extensions: ", ex)
|
|
cythonize = None
|
|
except Exception as ex:
|
|
print("Cython Build Failed, Not Building C Extensions: ", ex)
|
|
cythonize = None
|
|
|
|
|
|
def run_setup(try_c: bool = True):
|
|
if try_c:
|
|
kwargs = {
|
|
"ext_modules": c_modules,
|
|
}
|
|
else:
|
|
kwargs = {}
|
|
|
|
project_dir = os.path.abspath(os.path.dirname(__file__))
|
|
with open(os.path.join(project_dir, "README.md"), encoding="utf-8") as read_me:
|
|
long_desc = read_me.read()
|
|
|
|
version = "development"
|
|
if os.path.isfile(".dev_version"):
|
|
with open(os.path.join(project_dir, ".dev_version"), encoding="utf-8") as version_file:
|
|
version = version_file.readline()
|
|
else:
|
|
with open(os.path.join(project_dir, "clickhouse_connect", "_version.py"), encoding="utf-8") as version_file:
|
|
file_version = version_file.read().strip()
|
|
match = re.search(r"version\s*=\s*['\"](.+)['\"]", file_version)
|
|
if match is None:
|
|
raise ValueError(f"invalid version {file_version} in clickhouse_connect/_version.py")
|
|
version = match.group(1)
|
|
|
|
setup(
|
|
name="clickhouse-connect",
|
|
author="ClickHouse Inc.",
|
|
author_email="[email protected]",
|
|
keywords=["clickhouse", "superset", "sqlalchemy", "http", "driver"],
|
|
description="ClickHouse Database Core Driver for Python, Pandas, and Superset",
|
|
version=version,
|
|
long_description=long_desc,
|
|
long_description_content_type="text/markdown",
|
|
url="https://github.com/ClickHouse/clickhouse-connect",
|
|
packages=find_packages(exclude=["tests*"]),
|
|
python_requires=">=3.10,<3.15",
|
|
license="Apache-2.0",
|
|
install_requires=[
|
|
"certifi",
|
|
"urllib3>=1.26",
|
|
'tzdata; sys_platform == "win32"',
|
|
'zstandard; python_version<"3.14"',
|
|
'zstandard>=0.25.0; python_version>="3.14"',
|
|
'lz4; python_version<"3.14"',
|
|
'lz4>=4.4.5; python_version>="3.14"',
|
|
],
|
|
extras_require={
|
|
"sqlalchemy": ["sqlalchemy>=1.4.40,<3.0"],
|
|
"alembic": ["sqlalchemy>=1.4.40,<3.0", "alembic>=1.16"],
|
|
"numpy": ["numpy"],
|
|
"pandas": ["pandas>=2,<4"],
|
|
"polars": ["polars>=1.0"],
|
|
"arrow": ['pyarrow>=22.0; python_version>="3.14"', 'pyarrow; python_version<"3.14"'],
|
|
"orjson": ["orjson"],
|
|
"tzlocal": ["tzlocal>=4.0"],
|
|
"tzdata": ["tzdata"],
|
|
"async": ["aiohttp>=3.9.0"],
|
|
},
|
|
tests_require=["pytest"],
|
|
entry_points={
|
|
"sqlalchemy.dialects": [
|
|
"clickhousedb.connect=clickhouse_connect.cc_sqlalchemy.dialect:ClickHouseDialect",
|
|
"clickhousedb=clickhouse_connect.cc_sqlalchemy.dialect:ClickHouseDialect",
|
|
]
|
|
},
|
|
classifiers=[
|
|
"Development Status :: 5 - Production/Stable",
|
|
"Intended Audience :: Developers",
|
|
"License :: OSI Approved :: Apache Software License",
|
|
"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",
|
|
],
|
|
**kwargs,
|
|
)
|
|
|
|
|
|
try:
|
|
run_setup()
|
|
|
|
except (OSError, Exception, SystemExit) as e:
|
|
print(f"Unable to compile C extensions for faster performance due to {e}, will use pure Python")
|
|
run_setup(False)
|