|
| 1 | +#!/bin/bash |
| 2 | +# |
| 3 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 4 | +# or more contributor license agreements. See the NOTICE file |
| 5 | +# distributed with this work for additional information |
| 6 | +# regarding copyright ownership. The ASF licenses this file |
| 7 | +# to you under the Apache License, Version 2.0 (the |
| 8 | +# "License"); you may not use this file except in compliance |
| 9 | +# with the License. You may obtain a copy of the License at |
| 10 | +# |
| 11 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +# |
| 13 | +# Unless required by applicable law or agreed to in writing, |
| 14 | +# software distributed under the License is distributed on an |
| 15 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 16 | +# KIND, either express or implied. See the License for the |
| 17 | +# specific language governing permissions and limitations |
| 18 | +# under the License. |
| 19 | +# |
| 20 | + |
| 21 | +set -ex |
| 22 | + |
| 23 | +# See https://github.com/conda-forge/rust-feedstock/blob/master/recipe/build.sh for cc env explanation |
| 24 | +if [ "$c_compiler" = gcc ] ; then |
| 25 | + case "$target_platform" in |
| 26 | + linux-64) rust_env_arch=X86_64_UNKNOWN_LINUX_GNU ;; |
| 27 | + linux-aarch64) rust_env_arch=AARCH64_UNKNOWN_LINUX_GNU ;; |
| 28 | + linux-ppc64le) rust_env_arch=POWERPC64LE_UNKNOWN_LINUX_GNU ;; |
| 29 | + *) echo "unknown target_platform $target_platform" ; exit 1 ;; |
| 30 | + esac |
| 31 | + |
| 32 | + export CARGO_TARGET_${rust_env_arch}_LINKER=$CC |
| 33 | +fi |
| 34 | + |
| 35 | +declare -a _xtra_maturin_args |
| 36 | + |
| 37 | +mkdir -p $SRC_DIR/.cargo |
| 38 | + |
| 39 | +if [ "$target_platform" = "osx-64" ] ; then |
| 40 | + cat <<EOF >> $SRC_DIR/.cargo/config |
| 41 | +[target.x86_64-apple-darwin] |
| 42 | +linker = "$CC" |
| 43 | +rustflags = [ |
| 44 | + "-C", "link-arg=-undefined", |
| 45 | + "-C", "link-arg=dynamic_lookup", |
| 46 | +] |
| 47 | +
|
| 48 | +EOF |
| 49 | + |
| 50 | + _xtra_maturin_args+=(--target=x86_64-apple-darwin) |
| 51 | + |
| 52 | +elif [ "$target_platform" = "osx-arm64" ] ; then |
| 53 | + cat <<EOF >> $SRC_DIR/.cargo/config |
| 54 | +# Required for intermediate codegen stuff |
| 55 | +[target.x86_64-apple-darwin] |
| 56 | +linker = "$CC_FOR_BUILD" |
| 57 | +
|
| 58 | +# Required for final binary artifacts for target |
| 59 | +[target.aarch64-apple-darwin] |
| 60 | +linker = "$CC" |
| 61 | +rustflags = [ |
| 62 | + "-C", "link-arg=-undefined", |
| 63 | + "-C", "link-arg=dynamic_lookup", |
| 64 | +] |
| 65 | +
|
| 66 | +EOF |
| 67 | + _xtra_maturin_args+=(--target=aarch64-apple-darwin) |
| 68 | + |
| 69 | + # This variable must be set to the directory containing the target's libpython DSO |
| 70 | + export PYO3_CROSS_LIB_DIR=$PREFIX/lib |
| 71 | + |
| 72 | + # xref: https://github.com/PyO3/pyo3/commit/7beb2720 |
| 73 | + export PYO3_PYTHON_VERSION=${PY_VER} |
| 74 | + |
| 75 | + # xref: https://github.com/conda-forge/python-feedstock/issues/621 |
| 76 | + sed -i.bak 's,aarch64,arm64,g' $BUILD_PREFIX/venv/lib/os-patch.py |
| 77 | + sed -i.bak 's,aarch64,arm64,g' $BUILD_PREFIX/venv/lib/platform-patch.py |
| 78 | +fi |
| 79 | + |
| 80 | +maturin build -vv -j "${CPU_COUNT}" --release --strip --features substrait --manylinux off --interpreter="${PYTHON}" "${_xtra_maturin_args[@]}" |
| 81 | + |
| 82 | +"${PYTHON}" -m pip install $SRC_DIR/target/wheels/datafusion*.whl --no-deps -vv |
| 83 | + |
| 84 | +cargo-bundle-licenses --format yaml --output THIRDPARTY.yml |
0 commit comments