From a60788e92e1fcb954723860c17fa4e6445f100d4 Mon Sep 17 00:00:00 2001 From: discord9 <55937128+discord9@users.noreply.github.com> Date: Tue, 14 Mar 2023 10:57:13 +0800 Subject: [PATCH] fix: use correct env var (#1166) * fix: use correct env var * fix: move COPY up so rustup know it's nightly * fix: add `pyo3_backend` in GHA yml * chore: name for `TODO` * temp: not set `pyo3_backend` before find DSO * fix: release linux with pyo3_backend --- .github/workflows/release.yml | 9 +++++++-- docker/aarch64/Dockerfile | 21 ++++++++++++++------- docker/aarch64/compile-python.sh | 2 +- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2a7f8fcba9..7032179350 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -103,7 +103,7 @@ jobs: run: | sudo chmod +x ./docker/aarch64/compile-python.sh sudo ./docker/aarch64/compile-python.sh - export PYO3_CROSS_LIB_DIR=${PWD}/python310-aarch64/lib + export PYO3_CROSS_LIB_DIR=$(pwd)/python_arm64_build/lib echo $PYO3_CROSS_LIB_DIR - name: Install rust toolchain @@ -118,7 +118,12 @@ jobs: - name: Run tests run: make unit-test integration-test sqlness-test - - name: Run cargo build + - name: Run cargo build with pyo3-backend + if: contains(matrix.arch, 'linux') && endsWith(matrix.arch, '-gnu') + run: cargo build ${{ matrix.opts }} --profile ${{ env.CARGO_PROFILE }} --locked --target ${{ matrix.arch }} -F pyo3_backend + + - name: Run cargo build with macos + if: contains(matrix.arch, 'darwin') run: cargo build ${{ matrix.opts }} --profile ${{ env.CARGO_PROFILE }} --locked --target ${{ matrix.arch }} - name: Calculate checksum and rename binary diff --git a/docker/aarch64/Dockerfile b/docker/aarch64/Dockerfile index 1510045f86..df0e280db6 100644 --- a/docker/aarch64/Dockerfile +++ b/docker/aarch64/Dockerfile @@ -22,20 +22,27 @@ RUN apt-get -y update && \ apt-get -y install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu && \ apt-get install binutils-aarch64-linux-gnu +COPY ./docker/aarch64/compile-python.sh ./docker/aarch64/ +RUN chmod +x ./docker/aarch64/compile-python.sh && \ + ./docker/aarch64/compile-python.sh + +COPY ./rust-toolchain.toml . +# Install rustup target for cross compiling. +RUN rustup target add aarch64-unknown-linux-gnu COPY . . +# Update dependency, using separate `RUN` to separate cache +RUN cargo fetch + # This three env var is set in script, so I set it manually in dockerfile. ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/ ENV LIBRARY_PATH=$LIBRARY_PATH:/usr/local/lib/ -ENV PY_INSTALL_PATH=${PWD}/python_arm64_build -RUN chmod +x ./docker/aarch64/compile-python.sh && \ - ./docker/aarch64/compile-python.sh -# Install rustup target for cross compiling. -RUN rustup target add aarch64-unknown-linux-gnu +ENV PY_INSTALL_PATH=/greptimedb/python_arm64_build + # Set the environment variable for cross compiling and compile it -# Build the project in release mode. Set Net fetch with git cli to true to avoid git error. +# cross compiled python is `python3` in path, but pyo3 need `python` in path so alias it +# Build the project in release mode. RUN export PYO3_CROSS_LIB_DIR=$PY_INSTALL_PATH/lib && \ alias python=python3 && \ - CARGO_NET_GIT_FETCH_WITH_CLI=1 && \ cargo build --target aarch64-unknown-linux-gnu --release -F pyo3_backend # Exporting the binary to the clean image diff --git a/docker/aarch64/compile-python.sh b/docker/aarch64/compile-python.sh index 62bdbca3ca..eaabb09265 100644 --- a/docker/aarch64/compile-python.sh +++ b/docker/aarch64/compile-python.sh @@ -26,7 +26,7 @@ make install cd .. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/ export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/lib/ -export PY_INSTALL_PATH=${PWD}/python_arm64_build +export PY_INSTALL_PATH=$(pwd)/python_arm64_build cd Python-3.10.10 && \ make clean && \ make distclean && \