chdb 3.6.0__cp38-abi3-macosx_11_0_arm64.whl → 3.7.0__cp38-abi3-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of chdb might be problematic. Click here for more details.
- chdb/.flake8 +5 -0
- chdb/__init__.py +132 -11
- chdb/_chdb.abi3.so +0 -0
- chdb/build-musl.sh +166 -0
- chdb/build.sh +370 -0
- chdb/build_linux_arm64.sh +63 -0
- chdb/build_mac_arm64.sh +121 -0
- chdb/build_pybind11.sh +131 -0
- chdb/dataframe/__init__.py +7 -2
- chdb/dataframe/query.py +211 -23
- chdb/dbapi/__init__.py +57 -2
- chdb/dbapi/connections.py +169 -12
- chdb/dbapi/converters.py +352 -34
- chdb/dbapi/cursors.py +264 -70
- chdb/dbapi/err.py +269 -30
- chdb/dbapi/times.py +171 -0
- chdb/libpybind11nonlimitedapi_chdb_3.10.dylib +0 -0
- chdb/libpybind11nonlimitedapi_chdb_3.11.dylib +0 -0
- chdb/libpybind11nonlimitedapi_chdb_3.12.dylib +0 -0
- chdb/libpybind11nonlimitedapi_chdb_3.13.dylib +0 -0
- chdb/libpybind11nonlimitedapi_chdb_3.8.dylib +0 -0
- chdb/libpybind11nonlimitedapi_chdb_3.9.dylib +0 -0
- chdb/libpybind11nonlimitedapi_stubs.dylib +0 -0
- chdb/session/state.py +167 -4
- chdb/state/sqlitelike.py +608 -34
- chdb/test_smoke.sh +32 -0
- chdb/udf/__init__.py +7 -0
- chdb/udf/udf.py +41 -25
- chdb/utils/__init__.py +6 -0
- chdb/utils/trace.py +31 -0
- chdb/utils/types.py +62 -64
- chdb/vars.sh +48 -0
- {chdb-3.6.0.dist-info → chdb-3.7.0.dist-info}/METADATA +29 -18
- chdb-3.7.0.dist-info/RECORD +43 -0
- chdb-3.6.0.dist-info/RECORD +0 -35
- {chdb-3.6.0.dist-info → chdb-3.7.0.dist-info}/LICENSE.txt +0 -0
- {chdb-3.6.0.dist-info → chdb-3.7.0.dist-info}/WHEEL +0 -0
- {chdb-3.6.0.dist-info → chdb-3.7.0.dist-info}/top_level.txt +0 -0
chdb/build.sh
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
|
|
5
|
+
# default to build Release
|
|
6
|
+
build_type=${1:-Release}
|
|
7
|
+
|
|
8
|
+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
|
9
|
+
|
|
10
|
+
. ${DIR}/vars.sh
|
|
11
|
+
|
|
12
|
+
BUILD_DIR=${PROJ_DIR}/buildlib
|
|
13
|
+
|
|
14
|
+
HDFS="-DENABLE_HDFS=1 -DENABLE_GSASL_LIBRARY=1 -DENABLE_KRB5=1"
|
|
15
|
+
MYSQL="-DENABLE_MYSQL=1"
|
|
16
|
+
RUST_FEATURES="-DENABLE_RUST=0"
|
|
17
|
+
# check current os type
|
|
18
|
+
if [ "$(uname)" == "Darwin" ]; then
|
|
19
|
+
export CXX=$(brew --prefix llvm@19)/bin/clang++
|
|
20
|
+
export CC=$(brew --prefix llvm@19)/bin/clang
|
|
21
|
+
export PATH=$(brew --prefix llvm@19)/bin:$PATH
|
|
22
|
+
GLIBC_COMPATIBILITY="-DGLIBC_COMPATIBILITY=0"
|
|
23
|
+
UNWIND="-DUSE_UNWIND=0"
|
|
24
|
+
JEMALLOC="-DENABLE_JEMALLOC=0"
|
|
25
|
+
PYINIT_ENTRY="-Wl,-exported_symbol,_PyInit_${CHDB_PY_MOD}"
|
|
26
|
+
HDFS="-DENABLE_HDFS=0 -DENABLE_GSASL_LIBRARY=0 -DENABLE_KRB5=0"
|
|
27
|
+
MYSQL="-DENABLE_MYSQL=0"
|
|
28
|
+
ICU="-DENABLE_ICU=0"
|
|
29
|
+
SED_INPLACE="sed -i ''"
|
|
30
|
+
# if Darwin ARM64 (M1, M2), disable AVX
|
|
31
|
+
if [ "$(uname -m)" == "arm64" ]; then
|
|
32
|
+
CPU_FEATURES="-DENABLE_AVX=0 -DENABLE_AVX2=0"
|
|
33
|
+
LLVM="-DENABLE_EMBEDDED_COMPILER=0 -DENABLE_DWARF_PARSER=0"
|
|
34
|
+
else
|
|
35
|
+
LLVM="-DENABLE_EMBEDDED_COMPILER=0 -DENABLE_DWARF_PARSER=0"
|
|
36
|
+
# disable AVX on Darwin for macos11
|
|
37
|
+
if [ "$(sw_vers -productVersion | cut -d. -f1)" -le 11 ]; then
|
|
38
|
+
CPU_FEATURES="-DENABLE_AVX=0 -DENABLE_AVX2=0"
|
|
39
|
+
else
|
|
40
|
+
# for M1, M2 using x86_64 emulation, we need to disable AVX and AVX2
|
|
41
|
+
CPU_FEATURES="-DENABLE_AVX=0 -DENABLE_AVX2=0"
|
|
42
|
+
# # If target macos version is 12, we need to test if support AVX2,
|
|
43
|
+
# # because some Mac Pro Late 2013 (MacPro6,1) support AVX but not AVX2
|
|
44
|
+
# # just test it on the github action, hope you don't using Mac Pro Late 2013.
|
|
45
|
+
# # https://everymac.com/mac-answers/macos-12-monterey-faq/macos-monterey-macos-12-compatbility-list-system-requirements.html
|
|
46
|
+
# if [ "$(sysctl -n machdep.cpu.leaf7_features | grep AVX2)" != "" ]; then
|
|
47
|
+
# CPU_FEATURES="-DENABLE_AVX=1 -DENABLE_AVX2=1"
|
|
48
|
+
# else
|
|
49
|
+
# CPU_FEATURES="-DENABLE_AVX=1 -DENABLE_AVX2=0"
|
|
50
|
+
# fi
|
|
51
|
+
fi
|
|
52
|
+
fi
|
|
53
|
+
elif [ "$(uname)" == "Linux" ]; then
|
|
54
|
+
GLIBC_COMPATIBILITY="-DGLIBC_COMPATIBILITY=1"
|
|
55
|
+
UNWIND="-DUSE_UNWIND=1"
|
|
56
|
+
JEMALLOC="-DENABLE_JEMALLOC=1"
|
|
57
|
+
PYINIT_ENTRY="-Wl,-ePyInit_${CHDB_PY_MOD}"
|
|
58
|
+
ICU="-DENABLE_ICU=1"
|
|
59
|
+
SED_INPLACE="sed -i"
|
|
60
|
+
# only x86_64, enable AVX, enable embedded compiler
|
|
61
|
+
if [ "$(uname -m)" == "x86_64" ]; then
|
|
62
|
+
CPU_FEATURES="-DENABLE_AVX=1 -DENABLE_AVX2=0"
|
|
63
|
+
LLVM="-DENABLE_EMBEDDED_COMPILER=1 -DENABLE_DWARF_PARSER=1"
|
|
64
|
+
RUST_FEATURES="-DENABLE_RUST=1 -DENABLE_DELTA_KERNEL_RS=1"
|
|
65
|
+
CORROSION_CMAKE_FILE="${PROJ_DIR}/contrib/corrosion-cmake/CMakeLists.txt"
|
|
66
|
+
if [ -f "${CORROSION_CMAKE_FILE}" ]; then
|
|
67
|
+
if ! grep -q 'OPENSSL_NO_DEPRECATED_3_0' "${CORROSION_CMAKE_FILE}"; then
|
|
68
|
+
echo "Modifying corrosion CMakeLists.txt for Linux x86_64..."
|
|
69
|
+
${SED_INPLACE} 's/corrosion_set_env_vars(${target_name} "RUSTFLAGS=${RUSTFLAGS}")/corrosion_set_env_vars(${target_name} "RUSTFLAGS=${RUSTFLAGS} --cfg osslconf=\\\"OPENSSL_NO_DEPRECATED_3_0\\\"")/g' "${CORROSION_CMAKE_FILE}"
|
|
70
|
+
else
|
|
71
|
+
echo "corrosion CMakeLists.txt already modified, skipping..."
|
|
72
|
+
fi
|
|
73
|
+
else
|
|
74
|
+
echo "Warning: corrosion CMakeLists.txt not found at ${CORROSION_CMAKE_FILE}"
|
|
75
|
+
fi
|
|
76
|
+
else
|
|
77
|
+
CPU_FEATURES="-DENABLE_AVX=0 -DENABLE_AVX2=0 -DNO_ARMV81_OR_HIGHER=1"
|
|
78
|
+
LLVM="-DENABLE_EMBEDDED_COMPILER=0 -DENABLE_DWARF_PARSER=0"
|
|
79
|
+
fi
|
|
80
|
+
else
|
|
81
|
+
echo "OS not supported"
|
|
82
|
+
exit 1
|
|
83
|
+
fi
|
|
84
|
+
|
|
85
|
+
if [ ! -d $BUILD_DIR ]; then
|
|
86
|
+
mkdir $BUILD_DIR
|
|
87
|
+
fi
|
|
88
|
+
|
|
89
|
+
cd ${BUILD_DIR}
|
|
90
|
+
CMAKE_ARGS="-DCMAKE_BUILD_TYPE=${build_type} -DENABLE_THINLTO=0 -DENABLE_TESTS=0 -DENABLE_CLICKHOUSE_SERVER=0 -DENABLE_CLICKHOUSE_CLIENT=0 \
|
|
91
|
+
-DENABLE_CLICKHOUSE_KEEPER=0 -DENABLE_CLICKHOUSE_KEEPER_CONVERTER=0 -DENABLE_CLICKHOUSE_LOCAL=1 -DENABLE_CLICKHOUSE_SU=0 -DENABLE_CLICKHOUSE_BENCHMARK=0 \
|
|
92
|
+
-DENABLE_AZURE_BLOB_STORAGE=1 -DENABLE_CLICKHOUSE_COPIER=0 -DENABLE_CLICKHOUSE_DISKS=0 -DENABLE_CLICKHOUSE_FORMAT=0 -DENABLE_CLICKHOUSE_GIT_IMPORT=0 \
|
|
93
|
+
-DENABLE_AWS_S3=1 -DENABLE_HIVE=0 -DENABLE_AVRO=1 \
|
|
94
|
+
-DENABLE_CLICKHOUSE_OBFUSCATOR=0 -DENABLE_CLICKHOUSE_ODBC_BRIDGE=0 -DENABLE_CLICKHOUSE_STATIC_FILES_DISK_UPLOADER=0 \
|
|
95
|
+
-DENABLE_KAFKA=1 -DENABLE_LIBPQXX=1 -DENABLE_NATS=0 -DENABLE_AMQPCPP=0 -DENABLE_NURAFT=0 \
|
|
96
|
+
-DENABLE_CASSANDRA=0 -DENABLE_ODBC=0 -DENABLE_NLP=0 \
|
|
97
|
+
-DENABLE_LDAP=0 \
|
|
98
|
+
${MYSQL} \
|
|
99
|
+
${HDFS} \
|
|
100
|
+
-DENABLE_LIBRARIES=0 ${RUST_FEATURES} \
|
|
101
|
+
${GLIBC_COMPATIBILITY} \
|
|
102
|
+
-DENABLE_UTILS=0 ${LLVM} ${UNWIND} \
|
|
103
|
+
${ICU} -DENABLE_UTF8PROC=1 ${JEMALLOC} \
|
|
104
|
+
-DENABLE_PARQUET=1 -DENABLE_ROCKSDB=1 -DENABLE_SQLITE=1 -DENABLE_VECTORSCAN=1 \
|
|
105
|
+
-DENABLE_PROTOBUF=1 -DENABLE_THRIFT=1 -DENABLE_MSGPACK=1 \
|
|
106
|
+
-DENABLE_BROTLI=1 -DENABLE_H3=1 -DENABLE_CURL=1 \
|
|
107
|
+
-DENABLE_CLICKHOUSE_ALL=0 -DUSE_STATIC_LIBRARIES=1 -DSPLIT_SHARED_LIBRARIES=0 \
|
|
108
|
+
-DENABLE_SIMDJSON=1 -DENABLE_RAPIDJSON=1 \
|
|
109
|
+
${CPU_FEATURES} \
|
|
110
|
+
-DENABLE_AVX512=0 -DENABLE_AVX512_VBMI=0 \
|
|
111
|
+
-DENABLE_LIBFIU=1 \
|
|
112
|
+
-DCHDB_VERSION=${CHDB_VERSION} \
|
|
113
|
+
"
|
|
114
|
+
|
|
115
|
+
# # Generate libchdb.so linkage command:
|
|
116
|
+
# # 1. Use ar to delete the LocalChdb.cpp.o from libclickhouse-local-lib.a
|
|
117
|
+
# # `ar d programs/local/libclickhouse-local-lib.a LocalChdb.cpp.o`
|
|
118
|
+
# # 2. Change the entry point from `PyInit_chdb` to `query_stable`
|
|
119
|
+
# # `-Wl,-ePyInit_chdb` to `-Wl,-equery_stable` on Linux
|
|
120
|
+
# # `-Wl,-exported_symbol,_PyInit_${CHDB_PY_MOD}` to
|
|
121
|
+
# # `-Wl,-exported_symbol,_query_stable -Wl,-exported_symbol,_free_result` on Darwin
|
|
122
|
+
# # 3. Change the output file name from `_chdb.cpython-xx-x86_64-linux-gnu.s` to `libchdb.so`
|
|
123
|
+
# # `-o _chdb.cpython-39-x86_64-linux-gnu.so` to `-o libchdb.so`
|
|
124
|
+
# # 4. Write the command to a file for debug
|
|
125
|
+
# # 5. Run the command to generate libchdb.so
|
|
126
|
+
|
|
127
|
+
# # Remove object from archive and save it to a new archive like:
|
|
128
|
+
# # path/to/oldname.a -> path/to/oldname-nopy.a
|
|
129
|
+
# remove_obj_from_archive() {
|
|
130
|
+
# local archive=$1
|
|
131
|
+
# local obj=$2
|
|
132
|
+
# local new_archive=$(echo ${archive} | sed 's/\.a$/-nopy.a/')
|
|
133
|
+
# cp -a ${archive} ${new_archive}
|
|
134
|
+
# ${AR} d ${new_archive} ${obj}
|
|
135
|
+
# echo "Old archive: ${archive}"
|
|
136
|
+
# ls -l ${archive}
|
|
137
|
+
# echo "New archive: ${new_archive}"
|
|
138
|
+
# ls -l ${new_archive}
|
|
139
|
+
# local oldfile=$(basename ${archive})
|
|
140
|
+
# local newfile=$(basename ${new_archive})
|
|
141
|
+
# LIBCHDB_CMD=$(echo ${LIBCHDB_CMD} | sed "s/${oldfile}/${newfile}/g")
|
|
142
|
+
# ${SED_INPLACE} "s/${oldfile}/${newfile}/g" CMakeFiles/libchdb.rsp
|
|
143
|
+
# }
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
# # Step 1, 2, 3:
|
|
147
|
+
# # Backup the libclickhouse-local-lib.a and restore it after ar d
|
|
148
|
+
# # LIBCHDB_SO="libchdb.so"
|
|
149
|
+
# # CLEAN_CHDB_A="libclickhouse-local-chdb.a"
|
|
150
|
+
# # cp -a ${BUILD_DIR}/programs/local/libclickhouse-local-lib.a ${BUILD_DIR}/programs/local/libclickhouse-local-lib.a.bak
|
|
151
|
+
# # ${AR} d ${BUILD_DIR}/programs/local/libclickhouse-local-lib.a LocalChdb.cpp.o
|
|
152
|
+
# # mv ${BUILD_DIR}/programs/local/libclickhouse-local-lib.a ${BUILD_DIR}/programs/local/${CLEAN_CHDB_A}
|
|
153
|
+
# # mv ${BUILD_DIR}/programs/local/libclickhouse-local-lib.a.bak ${BUILD_DIR}/programs/local/libclickhouse-local-lib.a
|
|
154
|
+
# # ls -l ${BUILD_DIR}/programs/local/
|
|
155
|
+
# LIBCHDB_SO="libchdb.so"
|
|
156
|
+
# LIBCHDB_CMD=${PYCHDB_CMD}
|
|
157
|
+
# if [ "${build_type}" == "Debug" ]; then
|
|
158
|
+
# remove_obj_from_archive ${BUILD_DIR}/programs/local/libclickhouse-local-libd.a LocalChdb.cpp.o
|
|
159
|
+
# remove_obj_from_archive ${BUILD_DIR}/src/libdbmsd.a StoragePython.cpp.o
|
|
160
|
+
# remove_obj_from_archive ${BUILD_DIR}/src/libdbmsd.a PythonSource.cpp.o
|
|
161
|
+
# remove_obj_from_archive ${BUILD_DIR}/src/libclickhouse_common_iod.a PythonUtils.cpp.o
|
|
162
|
+
# remove_obj_from_archive ${BUILD_DIR}/src/TableFunctions/libclickhouse_table_functionsd.a TableFunctionPython.cpp.o
|
|
163
|
+
# else
|
|
164
|
+
# remove_obj_from_archive ${BUILD_DIR}/programs/local/libclickhouse-local-lib.a LocalChdb.cpp.o
|
|
165
|
+
# remove_obj_from_archive ${BUILD_DIR}/src/libdbms.a StoragePython.cpp.o
|
|
166
|
+
# remove_obj_from_archive ${BUILD_DIR}/src/libdbms.a PythonSource.cpp.o
|
|
167
|
+
# remove_obj_from_archive ${BUILD_DIR}/src/libclickhouse_common_io.a PythonUtils.cpp.o
|
|
168
|
+
# remove_obj_from_archive ${BUILD_DIR}/src/TableFunctions/libclickhouse_table_functions.a TableFunctionPython.cpp.o
|
|
169
|
+
# fi
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
LIBCHDB_SO="libchdb.so"
|
|
173
|
+
# Build libchdb.so
|
|
174
|
+
cmake ${CMAKE_ARGS} -DENABLE_PYTHON=0 ..
|
|
175
|
+
ninja -d keeprsp
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
BINARY=${BUILD_DIR}/programs/clickhouse
|
|
179
|
+
echo -e "\nBINARY: ${BINARY}"
|
|
180
|
+
ls -lh ${BINARY}
|
|
181
|
+
echo -e "\nldd ${BINARY}"
|
|
182
|
+
${LDD} ${BINARY}
|
|
183
|
+
rm -f ${BINARY}
|
|
184
|
+
|
|
185
|
+
cd ${BUILD_DIR}
|
|
186
|
+
ninja -d keeprsp -v > build.log || true
|
|
187
|
+
USING_RESPONSE_FILE=$(grep -m 1 'clang++.*-o programs/clickhouse .*' build.log | grep '@CMakeFiles/clickhouse.rsp' || true)
|
|
188
|
+
|
|
189
|
+
if [ ! "${USING_RESPONSE_FILE}" == "" ]; then
|
|
190
|
+
if [ -f CMakeFiles/clickhouse.rsp ]; then
|
|
191
|
+
cp -a CMakeFiles/clickhouse.rsp CMakeFiles/libchdb.rsp
|
|
192
|
+
else
|
|
193
|
+
echo "CMakeFiles/clickhouse.rsp not found"
|
|
194
|
+
exit 1
|
|
195
|
+
fi
|
|
196
|
+
fi
|
|
197
|
+
|
|
198
|
+
LIBCHDB_CMD=$(grep -m 1 'clang++.*-o programs/clickhouse .*' build.log \
|
|
199
|
+
| sed "s/-o programs\/clickhouse/-fPIC -shared -o ${LIBCHDB_SO}/" \
|
|
200
|
+
| sed 's/^[^&]*&& //' | sed 's/&&.*//' \
|
|
201
|
+
| sed 's/ -Wl,-undefined,error/ -Wl,-undefined,dynamic_lookup/g' \
|
|
202
|
+
| sed 's/ -Xlinker --no-undefined//g' \
|
|
203
|
+
| sed 's/@CMakeFiles\/clickhouse.rsp/@CMakeFiles\/libchdb.rsp/g' \
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
# generate the command to generate libchdb.so
|
|
207
|
+
LIBCHDB_CMD=$(echo ${LIBCHDB_CMD} | sed 's/ '${CHDB_PY_MODULE}'/ '${LIBCHDB_SO}'/g')
|
|
208
|
+
|
|
209
|
+
if [ ! "${USING_RESPONSE_FILE}" == "" ]; then
|
|
210
|
+
${SED_INPLACE} 's/ '${CHDB_PY_MODULE}'/ '${LIBCHDB_SO}'/g' CMakeFiles/libchdb.rsp
|
|
211
|
+
fi
|
|
212
|
+
|
|
213
|
+
if [ "$(uname)" == "Linux" ]; then
|
|
214
|
+
LIBCHDB_CMD=$(echo ${LIBCHDB_CMD} | sed 's/ '${PYINIT_ENTRY}'/ /g')
|
|
215
|
+
if [ ! "${USING_RESPONSE_FILE}" == "" ]; then
|
|
216
|
+
${SED_INPLACE} 's/ '${PYINIT_ENTRY}'/ /g' CMakeFiles/libchdb.rsp
|
|
217
|
+
fi
|
|
218
|
+
fi
|
|
219
|
+
|
|
220
|
+
if [ "$(uname)" == "Darwin" ]; then
|
|
221
|
+
LIBCHDB_CMD=$(echo ${LIBCHDB_CMD} | sed 's/ '${PYINIT_ENTRY}'/ -Wl,-exported_symbol,_query_stable -Wl,-exported_symbol,_free_result -Wl,-exported_symbol,_query_stable_v2 -Wl,-exported_symbol,_free_result_v2/g')
|
|
222
|
+
# ${SED_INPLACE} 's/ '${PYINIT_ENTRY}'/ -Wl,-exported_symbol,_query_stable -Wl,-exported_symbol,_free_result -Wl,-exported_symbol,_query_stable_v2 -Wl,-exported_symbol,_free_result_v2/g' CMakeFiles/libchdb.rsp
|
|
223
|
+
fi
|
|
224
|
+
|
|
225
|
+
LIBCHDB_CMD=$(echo ${LIBCHDB_CMD} | sed 's/@CMakeFiles\/clickhouse.rsp/@CMakeFiles\/libchdb.rsp/g')
|
|
226
|
+
|
|
227
|
+
# Step 4:
|
|
228
|
+
# save the command to a file for debug
|
|
229
|
+
echo ${LIBCHDB_CMD} > libchdb_cmd.sh
|
|
230
|
+
|
|
231
|
+
# Step 5:
|
|
232
|
+
${LIBCHDB_CMD}
|
|
233
|
+
|
|
234
|
+
LIBCHDB_DIR=${BUILD_DIR}/
|
|
235
|
+
LIBCHDB=${LIBCHDB_DIR}/${LIBCHDB_SO}
|
|
236
|
+
ls -lh ${LIBCHDB}
|
|
237
|
+
|
|
238
|
+
# build chdb python module
|
|
239
|
+
py_version="3.8"
|
|
240
|
+
# check current os type and architecture for py_version
|
|
241
|
+
if [ "$(uname)" == "Darwin" ] && [ "$(uname -m)" == "x86_64" ]; then
|
|
242
|
+
py_version="3.9"
|
|
243
|
+
fi
|
|
244
|
+
current_py_version=$(python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
|
|
245
|
+
if [ "$current_py_version" != "$py_version" ]; then
|
|
246
|
+
echo "Error: Current Python version is $current_py_version, but required version is $py_version"
|
|
247
|
+
echo "Please switch to Python $py_version using: pyenv shell $py_version"
|
|
248
|
+
exit 1
|
|
249
|
+
fi
|
|
250
|
+
echo "Using Python version: $current_py_version"
|
|
251
|
+
cmake ${CMAKE_ARGS} -DENABLE_PYTHON=1 -DPYBIND11_NONLIMITEDAPI_PYTHON_HEADERS_VERSION=${py_version} ..
|
|
252
|
+
ninja -d keeprsp || true
|
|
253
|
+
|
|
254
|
+
# del the binary and run ninja -v again to capture the command, then modify it to generate CHDB_PY_MODULE
|
|
255
|
+
/bin/rm -f ${BINARY}
|
|
256
|
+
cd ${BUILD_DIR}
|
|
257
|
+
ninja -d keeprsp -v > build.log || true
|
|
258
|
+
|
|
259
|
+
USING_RESPONSE_FILE=$(grep -m 1 'clang++.*-o programs/clickhouse .*' build.log | grep '@CMakeFiles/clickhouse.rsp' || true)
|
|
260
|
+
|
|
261
|
+
if [ ! "${USING_RESPONSE_FILE}" == "" ]; then
|
|
262
|
+
if [ -f CMakeFiles/clickhouse.rsp ]; then
|
|
263
|
+
cp -a CMakeFiles/clickhouse.rsp CMakeFiles/pychdb.rsp
|
|
264
|
+
else
|
|
265
|
+
echo "CMakeFiles/clickhouse.rsp not found"
|
|
266
|
+
exit 1
|
|
267
|
+
fi
|
|
268
|
+
fi
|
|
269
|
+
|
|
270
|
+
# extract the command to generate CHDB_PY_MODULE
|
|
271
|
+
PYCHDB_CMD=$(grep -m 1 'clang++.*-o programs/clickhouse .*' build.log \
|
|
272
|
+
| sed "s/-o programs\/clickhouse/-fPIC -Wl,-undefined,dynamic_lookup -shared ${PYINIT_ENTRY} -o ${CHDB_PY_MODULE}/" \
|
|
273
|
+
| sed 's/^[^&]*&& //' | sed 's/&&.*//' \
|
|
274
|
+
| sed 's/ -Wl,-undefined,error/ -Wl,-undefined,dynamic_lookup/g' \
|
|
275
|
+
| sed 's/ -Xlinker --no-undefined//g' \
|
|
276
|
+
| sed 's/@CMakeFiles\/clickhouse.rsp/@CMakeFiles\/pychdb.rsp/g' \
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
# # inplace modify the CMakeFiles/pychdb.rsp
|
|
281
|
+
# ${SED_INPLACE} 's/-o programs\/clickhouse/-fPIC -Wl,-undefined,dynamic_lookup -shared ${PYINIT_ENTRY} -o ${CHDB_PY_MODULE}/' CMakeFiles/pychdb.rsp
|
|
282
|
+
# ${SED_INPLACE} 's/ -Wl,-undefined,error/ -Wl,-undefined,dynamic_lookup/g' CMakeFiles/pychdb.rsp
|
|
283
|
+
# ${SED_INPLACE} 's/ -Xlinker --no-undefined//g' CMakeFiles/pychdb.rsp
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
if [ "$(uname)" == "Linux" ]; then
|
|
287
|
+
# remove src/CMakeFiles/clickhouse_malloc.dir/Common/stubFree.c.o
|
|
288
|
+
PYCHDB_CMD=$(echo ${PYCHDB_CMD} | sed 's/ src\/CMakeFiles\/clickhouse_malloc.dir\/Common\/stubFree.c.o//g')
|
|
289
|
+
# put -Wl,-wrap,malloc ... after -DUSE_JEMALLOC=1
|
|
290
|
+
PYCHDB_CMD=$(echo ${PYCHDB_CMD} | sed 's/ -DUSE_JEMALLOC=1/ -DUSE_JEMALLOC=1 -Wl,-wrap,malloc -Wl,-wrap,valloc -Wl,-wrap,pvalloc -Wl,-wrap,calloc -Wl,-wrap,realloc -Wl,-wrap,memalign -Wl,-wrap,aligned_alloc -Wl,-wrap,posix_memalign -Wl,-wrap,free/g')
|
|
291
|
+
if [ ! "${USING_RESPONSE_FILE}" == "" ]; then
|
|
292
|
+
${SED_INPLACE} 's/ src\/CMakeFiles\/clickhouse_malloc.dir\/Common\/stubFree.c.o//g' CMakeFiles/pychdb.rsp
|
|
293
|
+
${SED_INPLACE} 's/ -DUSE_JEMALLOC=1/ -DUSE_JEMALLOC=1 -Wl,-wrap,malloc -Wl,-wrap,valloc -Wl,-wrap,pvalloc -Wl,-wrap,calloc -Wl,-wrap,realloc -Wl,-wrap,memalign -Wl,-wrap,aligned_alloc -Wl,-wrap,posix_memalign -Wl,-wrap,free/g' CMakeFiles/pychdb.rsp
|
|
294
|
+
fi
|
|
295
|
+
fi
|
|
296
|
+
|
|
297
|
+
if [ "$(uname)" == "Darwin" ]; then
|
|
298
|
+
PYCHDB_CMD=$(echo ${PYCHDB_CMD} | sed 's|-Wl,-rpath,/[^[:space:]]*/pybind11-cmake|-Wl,-rpath,@loader_path|g')
|
|
299
|
+
else
|
|
300
|
+
PYCHDB_CMD=$(echo ${PYCHDB_CMD} | sed 's|-Wl,-rpath,/[^[:space:]]*/pybind11-cmake|-Wl,-rpath,\$ORIGIN|g')
|
|
301
|
+
fi
|
|
302
|
+
|
|
303
|
+
# save the command to a file for debug
|
|
304
|
+
echo ${PYCHDB_CMD} > pychdb_cmd.sh
|
|
305
|
+
|
|
306
|
+
${PYCHDB_CMD}
|
|
307
|
+
|
|
308
|
+
ls -lh ${CHDB_PY_MODULE}
|
|
309
|
+
|
|
310
|
+
## check all the so files
|
|
311
|
+
LIBCHDB_DIR=${BUILD_DIR}/
|
|
312
|
+
|
|
313
|
+
PYCHDB=${LIBCHDB_DIR}/${CHDB_PY_MODULE}
|
|
314
|
+
LIBCHDB=${LIBCHDB_DIR}/${LIBCHDB_SO}
|
|
315
|
+
|
|
316
|
+
if [ ${build_type} == "Debug" ]; then
|
|
317
|
+
echo -e "\nDebug build, skip strip"
|
|
318
|
+
else
|
|
319
|
+
echo -e "\nStrip the binary:"
|
|
320
|
+
${STRIP} --remove-section=.comment --remove-section=.note ${PYCHDB}
|
|
321
|
+
${STRIP} --remove-section=.comment --remove-section=.note ${LIBCHDB}
|
|
322
|
+
fi
|
|
323
|
+
echo -e "\nStripe the binary:"
|
|
324
|
+
|
|
325
|
+
echo -e "\nPYCHDB: ${PYCHDB}"
|
|
326
|
+
ls -lh ${PYCHDB}
|
|
327
|
+
echo -e "\nLIBCHDB: ${LIBCHDB}"
|
|
328
|
+
ls -lh ${LIBCHDB}
|
|
329
|
+
echo -e "\nldd ${PYCHDB}"
|
|
330
|
+
${LDD} ${PYCHDB}
|
|
331
|
+
echo -e "\nfile info of ${PYCHDB}"
|
|
332
|
+
file ${PYCHDB}
|
|
333
|
+
echo -e "\nldd ${LIBCHDB}"
|
|
334
|
+
${LDD} ${LIBCHDB}
|
|
335
|
+
echo -e "\nfile info of ${LIBCHDB}"
|
|
336
|
+
file ${LIBCHDB}
|
|
337
|
+
|
|
338
|
+
rm -f ${CHDB_DIR}/*.so
|
|
339
|
+
cp -a ${PYCHDB} ${CHDB_DIR}/${CHDB_PY_MODULE}
|
|
340
|
+
cp -a ${LIBCHDB} ${PROJ_DIR}/${LIBCHDB_SO}
|
|
341
|
+
|
|
342
|
+
echo -e "\nSymbols:"
|
|
343
|
+
echo -e "\nPyInit in PYCHDB: ${PYCHDB}"
|
|
344
|
+
${NM} ${PYCHDB} | grep PyInit || true
|
|
345
|
+
echo -e "\nPyInit in LIBCHDB: ${LIBCHDB}"
|
|
346
|
+
${NM} ${LIBCHDB} | grep PyInit || echo "PyInit not found in ${LIBCHDB}, it's OK"
|
|
347
|
+
echo -e "\nquery_stable in PYCHDB: ${PYCHDB}"
|
|
348
|
+
${NM} ${PYCHDB} | grep query_stable || true
|
|
349
|
+
echo -e "\nquery_stable in LIBCHDB: ${LIBCHDB}"
|
|
350
|
+
${NM} ${LIBCHDB} | grep query_stable || true
|
|
351
|
+
|
|
352
|
+
echo -e "\nAfter copy:"
|
|
353
|
+
cd ${PROJ_DIR} && pwd
|
|
354
|
+
# ls -lh ${PROJ_DIR}
|
|
355
|
+
|
|
356
|
+
# strip the binary (no debug info at all)
|
|
357
|
+
# strip ${CHDB_DIR}/${CHDB_PY_MODULE} || true
|
|
358
|
+
|
|
359
|
+
# echo -e "\nAfter strip:"
|
|
360
|
+
# echo -e "\nLIBCHDB: ${PYCHDB}"
|
|
361
|
+
# ls -lh ${CHDB_DIR}
|
|
362
|
+
# echo -e "\nfile info of ${PYCHDB}"
|
|
363
|
+
# file ${CHDB_DIR}/${CHDB_PY_MODULE}
|
|
364
|
+
|
|
365
|
+
ccache -s || true
|
|
366
|
+
|
|
367
|
+
# bash ${DIR}/build_bind.sh
|
|
368
|
+
# bash ${DIR}/test_smoke.sh
|
|
369
|
+
|
|
370
|
+
CMAKE_ARGS="${CMAKE_ARGS}" bash ${DIR}/build_pybind11.sh --all
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#!/bin/bash -e
|
|
2
|
+
|
|
3
|
+
export PYENV_ROOT="$HOME/.pyenv"
|
|
4
|
+
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
|
|
5
|
+
eval "$(pyenv init -)"
|
|
6
|
+
|
|
7
|
+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
|
8
|
+
PROJ_DIR=$(dirname ${DIR})
|
|
9
|
+
|
|
10
|
+
[ -z "${PYTHON_VERSIONS}" ] && { echo "please provide PYTHON_VERSIONS env, e.g: PYTHON_VERSIONS='3.8 3.9'"; exit 1; }
|
|
11
|
+
|
|
12
|
+
# echo ${PROJ_DIR}
|
|
13
|
+
|
|
14
|
+
for PY_VER in ${PYTHON_VERSIONS}; do
|
|
15
|
+
cd ${PROJ_DIR}
|
|
16
|
+
pyenv local "${PY_VER}"
|
|
17
|
+
python3 --version
|
|
18
|
+
python3 -m pip install pybind11 setuptools
|
|
19
|
+
export CC=/usr/bin/clang
|
|
20
|
+
export CXX=/usr/bin/clang++
|
|
21
|
+
# Install universal2 pkg
|
|
22
|
+
python3 -VV
|
|
23
|
+
python3-config --includes
|
|
24
|
+
# if python3 -VV does not contain ${PY_VER}, then exit
|
|
25
|
+
if ! python3 -VV 2>&1 | grep -q "${PY_VER}"; then
|
|
26
|
+
echo "Error: Required version of Python (${PY_VER}) not found. Aborting."
|
|
27
|
+
exit 1
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
python3 -m pip install -U pybind11 wheel build tox
|
|
31
|
+
rm -rf ./buildlib
|
|
32
|
+
|
|
33
|
+
./chdb/build.sh
|
|
34
|
+
cd chdb && python3 -c "import _chdb; res = _chdb.query('select 1112222222,555', 'JSON'); print(res)" && cd -
|
|
35
|
+
|
|
36
|
+
./gen_manifest.sh
|
|
37
|
+
cat ./MANIFEST.in
|
|
38
|
+
|
|
39
|
+
# try delete
|
|
40
|
+
whl_file=$(find dist | grep 'whl$' | grep cp${PY_VER//./}-cp${PY_VER//./} || echo "notfound.whl")
|
|
41
|
+
rm -f ${whl_file} || :
|
|
42
|
+
|
|
43
|
+
python3 -m build --wheel
|
|
44
|
+
|
|
45
|
+
python3 -m wheel tags --platform-tag=manylinux_2_17_aarch64
|
|
46
|
+
|
|
47
|
+
find dist
|
|
48
|
+
|
|
49
|
+
python3 -m pip install pandas pyarrow psutil
|
|
50
|
+
find dist
|
|
51
|
+
whl_file=$(find dist | grep 'whl$' | grep cp${PY_VER//./}-cp${PY_VER//./})
|
|
52
|
+
python3 -m pip install --force-reinstall ${whl_file}
|
|
53
|
+
|
|
54
|
+
python3 -c "import chdb; res = chdb.query('select version()', 'CSV'); print(res)"
|
|
55
|
+
|
|
56
|
+
python3 -m chdb "SELECT 1, 'ab'" arrowtable
|
|
57
|
+
|
|
58
|
+
python3 -m chdb "SELECT 1, 'ab'" dataframe
|
|
59
|
+
|
|
60
|
+
bash -x ./chdb/test_smoke.sh
|
|
61
|
+
|
|
62
|
+
make test
|
|
63
|
+
done
|
chdb/build_mac_arm64.sh
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
#!/usr/bin/arch -arm64 /bin/bash
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
|
|
5
|
+
# check current arch
|
|
6
|
+
if [ "$(uname -m)" != "arm64" ]; then
|
|
7
|
+
echo "OS not supported, run with arch -arm64 /bin/bash"
|
|
8
|
+
exit 1
|
|
9
|
+
fi
|
|
10
|
+
|
|
11
|
+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
|
12
|
+
PROJ_DIR=$(dirname ${DIR})
|
|
13
|
+
|
|
14
|
+
cd ${PROJ_DIR}
|
|
15
|
+
|
|
16
|
+
# Download py39 py310 py311 universal2 pkg from python.org
|
|
17
|
+
if [ ! -d ${PROJ_DIR}/python_pkg ]; then
|
|
18
|
+
mkdir ${PROJ_DIR}/python_pkg
|
|
19
|
+
fi
|
|
20
|
+
|
|
21
|
+
# prefer /usr/local/opt/llvm@19/bin/clang++ then /usr/local/opt/llvm/bin/clang++
|
|
22
|
+
if [ -f /usr/local/opt/llvm@19/bin/clang++ ]; then
|
|
23
|
+
export CXX=/usr/local/opt/llvm@19/bin/clang++
|
|
24
|
+
elif [ -f /usr/local/opt/llvm/bin/clang++ ]; then
|
|
25
|
+
export CXX=/usr/local/opt/llvm/bin/clang++
|
|
26
|
+
fi
|
|
27
|
+
if [ -f /usr/local/opt/llvm@19/bin/clang ]; then
|
|
28
|
+
export CC=/usr/local/opt/llvm@19/bin/clang
|
|
29
|
+
elif [ -f /usr/local/opt/llvm/bin/clang ]; then
|
|
30
|
+
export CC=/usr/local/opt/llvm/bin/clang
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
# Download MacOSX11.0.sdk.tar.xz
|
|
34
|
+
if [ ! -f ${PROJ_DIR}/python_pkg/MacOSX11.0.sdk.tar.xz ]; then
|
|
35
|
+
wget "https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.0.sdk.tar.xz" -O ${PROJ_DIR}/python_pkg/MacOSX11.0.sdk.tar.xz
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
# Extract MacOSX11.0.sdk.tar.xz
|
|
39
|
+
if [ ! -f ${PROJ_DIR}/cmake/toolchain/darwin-x86_64/Entitlements.plist ]; then
|
|
40
|
+
tar xJf ${PROJ_DIR}/python_pkg/MacOSX11.0.sdk.tar.xz -C cmake/toolchain/darwin-x86_64 --strip-components=1
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
# Fix soft link if darwin-aarch64 not linked to darwin-x86_64
|
|
44
|
+
if [ -L ${PROJ_DIR}/cmake/toolchain/darwin-aarch64 ]; then
|
|
45
|
+
dest=$(readlink ${PROJ_DIR}/cmake/toolchain/darwin-aarch64)
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
if [ "${dest}" != "darwin-x86_64" ]; then
|
|
49
|
+
rm -f ${PROJ_DIR}/cmake/toolchain/darwin-aarch64
|
|
50
|
+
ln -sf darwin-x86_64 ${PROJ_DIR}/cmake/toolchain/darwin-aarch64
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
for PY_VER in 3.9.13 3.10.11 3.11.3 3.12.9 3.13.2; do
|
|
55
|
+
if [ ! -f ${PROJ_DIR}/python_pkg/python-${PY_VER}-macos11.pkg ]; then
|
|
56
|
+
wget https://www.python.org/ftp/python/${PY_VER}/python-${PY_VER}-macos11.pkg -O ${PROJ_DIR}/python_pkg/python-${PY_VER}-macos11.pkg
|
|
57
|
+
fi
|
|
58
|
+
|
|
59
|
+
PY_SHORT_VER=$(echo ${PY_VER} | cut -d. -f1,2)
|
|
60
|
+
# Install universal2 pkg
|
|
61
|
+
sudo installer -pkg ${PROJ_DIR}/python_pkg/python-${PY_VER}-macos11.pkg -target /
|
|
62
|
+
export PATH=/Library/Frameworks/Python.framework/Versions/${PY_SHORT_VER}/bin:/Library/Frameworks/Python.framework/Versions/${PY_SHORT_VER}/Resources/Python.app/Contents/MacOS/:$PATH
|
|
63
|
+
python3 -VV
|
|
64
|
+
python3-config --includes
|
|
65
|
+
# if python3 -VV does not contain ${PY_VER}, then exit
|
|
66
|
+
if ! python3 -VV 2>&1 | grep -q "${PY_VER}"; then
|
|
67
|
+
echo "Error: Required version of Python (${PY_VER}) not found. Aborting."
|
|
68
|
+
exit 1
|
|
69
|
+
fi
|
|
70
|
+
# if python3-config --includes does not contain ${PY_SHORT_VER}, then exit
|
|
71
|
+
if ! python3-config --includes 2>&1 | grep -q "${PY_SHORT_VER}"; then
|
|
72
|
+
echo "Error: Required version of Python (${PY_VER}) not found. Aborting."
|
|
73
|
+
exit 1
|
|
74
|
+
fi
|
|
75
|
+
|
|
76
|
+
python3 -m pip install -U pybind11 wheel build tox psutil setuptools pyarrow pandas certifi
|
|
77
|
+
rm -rf ${PROJ_DIR}/buildlib
|
|
78
|
+
|
|
79
|
+
${PROJ_DIR}/chdb/build.sh
|
|
80
|
+
cd ${PROJ_DIR}/chdb && python3 -c "import _chdb; res = _chdb.query('select 1112222222,555', 'JSON'); print(res)"
|
|
81
|
+
|
|
82
|
+
cd ${PROJ_DIR}
|
|
83
|
+
${PROJ_DIR}/gen_manifest.sh
|
|
84
|
+
cat ${PROJ_DIR}/MANIFEST.in
|
|
85
|
+
|
|
86
|
+
python3 -m build --wheel
|
|
87
|
+
|
|
88
|
+
python3 -m wheel tags --platform-tag=macosx_11_0_arm64 --remove dist/chdb-*-cp${PY_SHORT_VER//./}-cp${PY_SHORT_VER//./}-macosx_*_universal2.whl
|
|
89
|
+
|
|
90
|
+
python3 -m pip install --force-reinstall dist/chdb-*-cp${PY_SHORT_VER//./}-cp${PY_SHORT_VER//./}-macosx_11_0_arm64.whl
|
|
91
|
+
|
|
92
|
+
python3 -c "import chdb; res = chdb.query('select version()', 'CSV'); print(res)"
|
|
93
|
+
|
|
94
|
+
python3 -m chdb "SELECT 1, 'ab'" arrowtable
|
|
95
|
+
|
|
96
|
+
python3 -m chdb "SELECT 1, 'ab'" dataframe
|
|
97
|
+
|
|
98
|
+
CHDB_VERSION=$(python3 -c "import chdb; print(chdb.__version__)")
|
|
99
|
+
make test
|
|
100
|
+
done
|
|
101
|
+
|
|
102
|
+
cp programs/local/chdb.h chdb.h
|
|
103
|
+
tar -czvf macos-arm64-libchdb.tar.gz libchdb.so chdb.h
|
|
104
|
+
gh release upload v${CHDB_VERSION} macos-arm64-libchdb.tar.gz --clobber
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
cd ${PROJ_DIR}
|
|
108
|
+
# Set environment variables for PyPI upload
|
|
109
|
+
export TWINE_USERNAME=__token__
|
|
110
|
+
export TWINE_PASSWORD=$(cat ~/.config/pypi.token)
|
|
111
|
+
|
|
112
|
+
make pub
|
|
113
|
+
|
|
114
|
+
# Upload wheel files to GitHub release
|
|
115
|
+
echo "Uploading wheel files to GitHub release..."
|
|
116
|
+
for wheel in dist/*.whl; do
|
|
117
|
+
if [ -f "$wheel" ]; then
|
|
118
|
+
gh release upload v${CHDB_VERSION} "$wheel" --clobber
|
|
119
|
+
echo "Uploaded $wheel"
|
|
120
|
+
fi
|
|
121
|
+
done
|
chdb/build_pybind11.sh
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
|
|
5
|
+
build_all=false
|
|
6
|
+
py_version=""
|
|
7
|
+
|
|
8
|
+
for arg in "$@"; do
|
|
9
|
+
case $arg in
|
|
10
|
+
--all)
|
|
11
|
+
build_all=true
|
|
12
|
+
shift
|
|
13
|
+
;;
|
|
14
|
+
--version=*)
|
|
15
|
+
py_version="${arg#*=}"
|
|
16
|
+
shift
|
|
17
|
+
;;
|
|
18
|
+
esac
|
|
19
|
+
done
|
|
20
|
+
|
|
21
|
+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
|
22
|
+
. ${DIR}/vars.sh
|
|
23
|
+
|
|
24
|
+
# Check if CMAKE_ARGS is passed from build.sh
|
|
25
|
+
if [ -z "$CMAKE_ARGS" ]; then
|
|
26
|
+
echo "Error: CMAKE_ARGS not provided. This script should be called from build.sh."
|
|
27
|
+
exit 1
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
build_pybind11_nonlimitedapi() {
|
|
31
|
+
cd "${BUILD_DIR}"
|
|
32
|
+
|
|
33
|
+
local py_version=$1
|
|
34
|
+
echo "Building pybind11 nonlimitedapi library for Python ${py_version}..."
|
|
35
|
+
|
|
36
|
+
local py_cmake_args="${CMAKE_ARGS} -DPYBIND11_NONLIMITEDAPI_PYTHON_HEADERS_VERSION=${py_version}"
|
|
37
|
+
|
|
38
|
+
cmake ${py_cmake_args} -DENABLE_PYTHON=1 ..
|
|
39
|
+
|
|
40
|
+
# Build only the pybind11 targets
|
|
41
|
+
ninja pybind11nonlimitedapi_chdb_${py_version} || {
|
|
42
|
+
echo "Failed to build pybind11nonlimitedapi library for Python ${py_version}"
|
|
43
|
+
return 1
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
# Copy the built library to output directory
|
|
47
|
+
local lib_name="pybind11nonlimitedapi_chdb_${py_version}"
|
|
48
|
+
if [ "$(uname)" == "Darwin" ]; then
|
|
49
|
+
local lib_file="lib${lib_name}.dylib"
|
|
50
|
+
else
|
|
51
|
+
local lib_file="lib${lib_name}.so"
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
if [ -f "${BUILD_DIR}/contrib/pybind11-cmake/${lib_file}" ]; then
|
|
55
|
+
cp "${BUILD_DIR}/contrib/pybind11-cmake/${lib_file}" "${CHDB_DIR}/${lib_file}"
|
|
56
|
+
echo "Copied ${lib_file} to ${CHDB_DIR}/"
|
|
57
|
+
echo "Library location: $(realpath ${CHDB_DIR}/${lib_file})"
|
|
58
|
+
else
|
|
59
|
+
echo "Warning: ${lib_file} not found in ${BUILD_DIR}/contrib/pybind11-cmake/"
|
|
60
|
+
echo "Available files in contrib/pybind11-cmake/:"
|
|
61
|
+
ls -la "${BUILD_DIR}/contrib/pybind11-cmake/" || true
|
|
62
|
+
fi
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
build_all_pybind11_nonlimitedapi() {
|
|
66
|
+
local python_versions=("3.8" "3.9" "3.10" "3.11" "3.12" "3.13")
|
|
67
|
+
|
|
68
|
+
# Skip Python 3.8 for macOS x86_64
|
|
69
|
+
if [ "$(uname)" == "Darwin" ] && [ "$(uname -m)" == "x86_64" ]; then
|
|
70
|
+
python_versions=("3.9" "3.10" "3.11" "3.12" "3.13")
|
|
71
|
+
fi
|
|
72
|
+
|
|
73
|
+
echo "Building pybind11 nonlimitedapi libraries for all Python versions..."
|
|
74
|
+
|
|
75
|
+
# Check if pyenv is available
|
|
76
|
+
if [ -z "$(command -v pyenv)" ]; then
|
|
77
|
+
echo "Error: pyenv not found. Please install pyenv first."
|
|
78
|
+
exit 1
|
|
79
|
+
fi
|
|
80
|
+
|
|
81
|
+
for version in "${python_versions[@]}"; do
|
|
82
|
+
# Use pyenv to find specific version
|
|
83
|
+
local pyenv_version=$(pyenv versions --bare | grep "^${version}\." | head -1)
|
|
84
|
+
if [ -z "$pyenv_version" ]; then
|
|
85
|
+
echo "Error: Python ${version} not found in pyenv. Please install it with: pyenv install ${version}.x"
|
|
86
|
+
exit 1
|
|
87
|
+
fi
|
|
88
|
+
|
|
89
|
+
echo "Found pyenv Python ${pyenv_version}"
|
|
90
|
+
export PYENV_VERSION=$pyenv_version
|
|
91
|
+
|
|
92
|
+
local python_include=$(python -c "import sysconfig; print(sysconfig.get_path('include'))" 2>/dev/null)
|
|
93
|
+
local active_version=$(python --version 2>&1)
|
|
94
|
+
echo " Active Python: $active_version"
|
|
95
|
+
|
|
96
|
+
if [ -f "$python_include/Python.h" ]; then
|
|
97
|
+
echo " Headers found at: $python_include"
|
|
98
|
+
build_pybind11_nonlimitedapi "${version}"
|
|
99
|
+
else
|
|
100
|
+
echo "Error: Python.h not found for Python ${version} at $python_include"
|
|
101
|
+
unset PYENV_VERSION
|
|
102
|
+
exit 1
|
|
103
|
+
fi
|
|
104
|
+
|
|
105
|
+
unset PYENV_VERSION
|
|
106
|
+
done
|
|
107
|
+
|
|
108
|
+
echo "Finished building pybind11 nonlimitedapi libraries"
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
copy_stubs() {
|
|
112
|
+
if [ "$(uname)" == "Darwin" ]; then
|
|
113
|
+
local lib_file="libpybind11nonlimitedapi_stubs.dylib"
|
|
114
|
+
else
|
|
115
|
+
local lib_file="libpybind11nonlimitedapi_stubs.so"
|
|
116
|
+
fi
|
|
117
|
+
if [ -f ${BUILD_DIR}/contrib/pybind11-cmake/${lib_file} ]; then
|
|
118
|
+
cp -a ${BUILD_DIR}/contrib/pybind11-cmake/${lib_file} ${CHDB_DIR}/
|
|
119
|
+
fi
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if [ "$build_all" = true ]; then
|
|
123
|
+
copy_stubs
|
|
124
|
+
build_all_pybind11_nonlimitedapi
|
|
125
|
+
elif [ -n "$py_version" ]; then
|
|
126
|
+
copy_stubs
|
|
127
|
+
build_pybind11_nonlimitedapi "$py_version"
|
|
128
|
+
else
|
|
129
|
+
echo "No action specified."
|
|
130
|
+
exit 1
|
|
131
|
+
fi
|