Skip to content

Commit 8d9f19e

Browse files
Haowei Yusmtakeda
authored andcommitted
Enable arrow tests in linux
1 parent 54d4fa3 commit 8d9f19e

File tree

6 files changed

+130
-2
lines changed

6 files changed

+130
-2
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# We use manylinux1 base image because pyarrow_manylinux2010 has a bug and wheel failed to be audited
2+
FROM quay.io/pypa/manylinux1_x86_64
3+
4+
# This is to solve permission issue, read https://denibertovic.com/posts/handling-permissions-with-docker-volumes/
5+
RUN curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/1.11/gosu-amd64"
6+
RUN chmod +x /usr/local/bin/gosu
7+
8+
COPY scripts/entrypoint.sh /usr/local/bin/entrypoint.sh
9+
RUN chmod +x /usr/local/bin/entrypoint.sh
10+
11+
12+
WORKDIR /home/user
13+
RUN chmod 777 /home/user
14+
RUN git clone https://github.com/matthew-brett/multibuild.git && cd /home/user/multibuild && git checkout 1a7f31be677185f2dface2643284846e14130c3f
15+
16+
ADD scripts/build_virtualenvs.sh /home/user
17+
RUN /home/user/build_virtualenvs.sh
18+
19+
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash -e
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
19+
# Build upon the scripts in https://github.com/matthew-brett/manylinux-builds
20+
# * Copyright (c) 2013-2016, Matt Terry and Matthew Brett (BSD 2-clause)
21+
22+
PYTHON_VERSIONS="${PYTHON_VERSIONS:-35 36 37}"
23+
24+
source /home/user/multibuild/manylinux_utils.sh
25+
26+
for PYTHON in ${PYTHON_VERSIONS}; do
27+
U_WIDTH=16
28+
PYTHON_INTERPRETER="$(cpython_path $PYTHON {U_WIDTH})/bin/python"
29+
PIP="$(cpython_path $PYTHON ${U_WIDTH})/bin/pip"
30+
PATH="$PATH:$(cpython_path $PYTHON ${U_WIDTH})"
31+
32+
echo "=== (${PYTHON}, ${U_WIDTH}) Installing build dependencies ==="
33+
$PIP install "virtualenv==16.3.0"
34+
35+
echo "=== (${PYTHON}, ${U_WIDTH}) Preparing virtualenv for build ==="
36+
"$(cpython_path $PYTHON ${U_WIDTH})/bin/virtualenv" -p ${PYTHON_INTERPRETER} --no-download /home/user/venv-build-${PYTHON}
37+
source /home/user/venv-build-${PYTHON}/bin/activate
38+
pip install "cython==0.29.8" "setuptools" "flake8" "wheel" "pyarrow==0.14.1"
39+
deactivate
40+
done
41+
42+
# Remove pip cache again. It's useful during the virtualenv creation but we
43+
# don't want it persisted in the docker layer, ~264MiB
44+
rm -rf /root/.cache
45+
# Remove unused Python versions
46+
rm -rf /opt/_internal/cpython-3.4*
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
# Add local user
4+
# Either use the LOCAL_USER_ID if passed in at runtime or
5+
# fallback
6+
7+
USER_ID=${LOCAL_USER_ID:-9001}
8+
9+
echo "Starting with UID : $USER_ID"
10+
useradd --shell /bin/bash -u $USER_ID -o -c "" -m user
11+
export HOME=/home/user
12+
13+
/usr/local/bin/gosu user "$@"

scripts/build_connector_linux.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash -e
2+
#
3+
# Install Snowflake Python Connector
4+
#
5+
set -o pipefail
6+
7+
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
8+
9+
cd $THIS_DIR/..
10+
PYTHON_VERSION=$1
11+
source "/home/user/venv-build-${PYTHON_VERSION}/bin/activate"
12+
rm -rf build/
13+
export ENABLE_EXT_MODULES=true
14+
rm -f generated_version.py
15+
CC=g++ python setup.py bdist_wheel -d $THIS_DIR/../dist/docker/$PYTHON_VERSION/
16+
unset ENABLE_EXT_MODULES
17+
18+
mkdir -p $THIS_DIR/../dist/docker/repaired_wheels
19+
auditwheel repair --plat manylinux2010_x86_64 -L connector $THIS_DIR/../dist/docker/$PYTHON_VERSION/*.whl -w $THIS_DIR/../dist/docker/repaired_wheels
20+
rm $THIS_DIR/../dist/docker/repaired_wheels/*manylinux1_x86_64.whl || true

scripts/build_inside_docker.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash -e
2+
#
3+
# Install Snowflake Python Connector
4+
#
5+
set -o pipefail
6+
7+
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
8+
9+
cd $THIS_DIR/../docker/manylinux2010
10+
11+
echo "[Info] Start building dokcer image"
12+
docker build -t manylinux:1.0 -f Dockerfile-x86_64_base .
13+
14+
user_id=$(id -u $USER)
15+
docker run -e LOCAL_USER_ID=$user_id --mount type=bind,source="$THIS_DIR/..",target=/home/user/connector manylinux:1.0 \
16+
/home/user/connector/scripts/build_connector_linux.sh $1

scripts/install.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#
55
set -o pipefail
66

7+
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
8+
79
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
810
brew update
911
brew install openssl readline sqlite3 xz zlib
@@ -33,10 +35,22 @@ source ./venv/bin/activate
3335
pip install pandas
3436
pip install numpy
3537
pip install pendulum
36-
pip install pyarrow
3738
pip install pytest pytest-cov pytest-rerunfailures
3839
if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]] || [[ $PYTHON_VERSION == "2.7"* ]]; then
3940
pip install mock
4041
fi
41-
pip install .
42+
43+
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
44+
pip install .
45+
else
46+
if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
47+
pip install .
48+
else
49+
pv=${TRAVIS_PYTHON_VERSION/./}
50+
$THIS_DIR/build_inside_docker.sh $pv
51+
CONNECTOR_WHL=$(ls $THIS_DIR/../dist/docker/repaired_wheels/snowflake_connector_python*cp${PYTHON_ENV}*.whl | sort -r | head -n 1)
52+
pip install -U $CONNECTOR_WHL[pandas]
53+
cd $THIS_DIR/..
54+
fi
55+
fi
4256
pip list --format=columns

0 commit comments

Comments
 (0)