|
| 1 | +#!/usr/bin/arch -arm64 /bin/bash |
| 2 | + |
| 3 | +set -e |
| 4 | + |
| 5 | +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" |
| 6 | +PROJ_DIR=$(dirname ${DIR}) |
| 7 | + |
| 8 | +cd ${PROJ_DIR} |
| 9 | + |
| 10 | +# Download py39 py310 py311 universal2 pkg from python.org |
| 11 | +if [ ! -d ${PROJ_DIR}/python_pkg ]; then |
| 12 | + mkdir ${PROJ_DIR}/python_pkg |
| 13 | +fi |
| 14 | + |
| 15 | +# prefer /usr/local/opt/llvm@15/bin/clang++ then /usr/local/opt/llvm/bin/clang++ |
| 16 | +if [ -f /usr/local/opt/llvm@15/bin/clang++ ]; then |
| 17 | + export CXX=/usr/local/opt/llvm@15/bin/clang++ |
| 18 | +elif [ -f /usr/local/opt/llvm/bin/clang++ ]; then |
| 19 | + export CXX=/usr/local/opt/llvm/bin/clang++ |
| 20 | +fi |
| 21 | +if [ -f /usr/local/opt/llvm@15/bin/clang ]; then |
| 22 | + export CC=/usr/local/opt/llvm@15/bin/clang |
| 23 | +elif [ -f /usr/local/opt/llvm/bin/clang ]; then |
| 24 | + export CC=/usr/local/opt/llvm/bin/clang |
| 25 | +fi |
| 26 | + |
| 27 | +for PY_VER in 3.9.13 3.10.11 3.11.3; do |
| 28 | + if [ ! -f ${PROJ_DIR}/python_pkg/python-${PY_VER}-macos11.pkg ]; then |
| 29 | + wget https://www.python.org/ftp/python/${PY_VER}/python-${PY_VER}-macos11.pkg -O ${PROJ_DIR}/python_pkg/python-${PY_VER}-macos11.pkg |
| 30 | + fi |
| 31 | + |
| 32 | + PY_SHORT_VER=$(echo ${PY_VER} | cut -d. -f1,2) |
| 33 | + # Install universal2 pkg |
| 34 | + sudo installer -pkg ${PROJ_DIR}/python_pkg/python-${PY_VER}-macos11.pkg -target / |
| 35 | + 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 |
| 36 | + python3 -VV |
| 37 | + python3-config --includes |
| 38 | + # if python3 -VV does not contain ${PY_VER}, then exit |
| 39 | + if ! python3 -VV 2>&1 | grep -q "${PY_VER}"; then |
| 40 | + echo "Error: Required version of Python (${PY_VER}) not found. Aborting." |
| 41 | + exit 1 |
| 42 | + fi |
| 43 | + # if python3-config --includes does not contain ${PY_SHORT_VER}, then exit |
| 44 | + if ! python3-config --includes 2>&1 | grep -q "${PY_SHORT_VER}"; then |
| 45 | + echo "Error: Required version of Python (${PY_VER}) not found. Aborting." |
| 46 | + exit 1 |
| 47 | + fi |
| 48 | + |
| 49 | + python3 -m pip install -U pybind11 wheel build tox |
| 50 | + rm -rf ${PROJ_DIR}/buildlib |
| 51 | + |
| 52 | + ${PROJ_DIR}/chdb/build.sh |
| 53 | + cd ${PROJ_DIR}/chdb && python3 -c "import _chdb; res = _chdb.query('select 1112222222,555', 'JSON'); print(res.get_memview().tobytes())" |
| 54 | + |
| 55 | + cd ${PROJ_DIR} |
| 56 | + ${PROJ_DIR}/gen_manifest.sh |
| 57 | + cat ${PROJ_DIR}/MANIFEST.in |
| 58 | + |
| 59 | + python3 -m build --wheel |
| 60 | + |
| 61 | + python3 -m wheel tags --platform-tag=macosx_11_0_arm64 --remove dist/chdb-*-cp${PY_SHORT_VER//./}-cp${PY_SHORT_VER//./}-macosx_*_universal2.whl |
| 62 | + |
| 63 | + python3 -m pip install --force-reinstall dist/chdb-*-cp${PY_SHORT_VER//./}-cp${PY_SHORT_VER//./}-macosx_11_0_arm64.whl |
| 64 | + |
| 65 | + python3 -c "import chdb; res = chdb.query('select version()', 'CSV'); print(str(res.get_memview().tobytes()))" |
| 66 | +done |
| 67 | + |
| 68 | +cd ${PROJ_DIR} |
| 69 | +make pub |
| 70 | + |
0 commit comments