|
1 | 1 | import os |
2 | 2 | import sys |
| 3 | +import re |
3 | 4 | import subprocess |
4 | 5 | import sysconfig |
5 | 6 | from setuptools import setup, Extension |
@@ -57,6 +58,21 @@ def get_latest_git_tag(minor_ver_auto=False): |
57 | 58 | print(e) |
58 | 59 | raise |
59 | 60 |
|
| 61 | +# replace the version in chdb/__init__.py, which is `chdb_version = (0, 1, 0)` by default |
| 62 | +# regex replace the version string `chdb_version = (0, 1, 0)` with version parts |
| 63 | +def fix_version_init(version): |
| 64 | + # split version string into parts |
| 65 | + p1, p2, p3 = version.split('.') |
| 66 | + init_file = os.path.join(script_dir, "chdb", "__init__.py") |
| 67 | + with open(init_file, "r+") as f: |
| 68 | + init_content = f.read() |
| 69 | + # regex replace the version string `chdb_version = (0, 1, 0)` |
| 70 | + regPattern = r"chdb_version = \(\d+, \d+, \d+\)" |
| 71 | + init_content = re.sub(regPattern, f"chdb_version = ({p1}, {p2}, {p3})", init_content) |
| 72 | + f.seek(0) |
| 73 | + f.write(init_content) |
| 74 | + f.truncate() |
| 75 | + |
60 | 76 |
|
61 | 77 | # As of Python 3.6, CCompiler has a `has_flag` method. |
62 | 78 | # cf http://bugs.python.org/issue26689 |
@@ -147,15 +163,16 @@ def build_extensions(self): |
147 | 163 | extra_objects=[chdb_so], |
148 | 164 | ), |
149 | 165 | ] |
150 | | - |
| 166 | + # fix the version in chdb/__init__.py |
| 167 | + versionStr = get_latest_git_tag() |
| 168 | + fix_version_init(versionStr) |
151 | 169 | setup( |
152 | 170 | packages=['chdb'], |
153 | | - version=get_latest_git_tag(), |
| 171 | + version=versionStr, |
154 | 172 | package_data={'chdb': [chdb_so]}, |
155 | 173 | exclude_package_data={'': ['*.pyc', 'src/**']}, |
156 | 174 | ext_modules=ext_modules, |
157 | 175 | python_requires='>=3.7', |
158 | | - install_requires=['pyarrow', 'pandas'], |
159 | 176 | cmdclass={'build_ext': BuildExt}, |
160 | 177 | test_suite="tests", |
161 | 178 | zip_safe=False, |
|
0 commit comments