Skip to content

Commit bde172c

Browse files
committed
Revisiting the lambda layer building
1 parent a4d23dc commit bde172c

File tree

8 files changed

+113
-104
lines changed

8 files changed

+113
-104
lines changed

building/build-lambda-layers.sh

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,35 @@
22
set -ex
33

44
VERSION=$(python -c "import awswrangler as wr; print(wr.__version__)")
5-
echo "Building Lambda Layers for AWS Data Wrangler ${VERSION}"
65
DIR_NAME=$(dirname "$PWD")
76

7+
echo "Building Lambda Layers for AWS Data Wrangler ${VERSION}"
8+
89
pushd lambda
910

1011
# Building all related docker images
1112
./build-docker-images.sh
1213

13-
# Building Apache Arrow binary artifacts
14+
# Python 3.6
1415
docker run \
15-
--volume "$DIR_NAME":/aws-data-wrangler/ \
16-
--workdir /aws-data-wrangler/building/lambda \
17-
-it \
18-
awswrangler-build-py36 \
19-
build-apache-arrow.sh
16+
--volume "$DIR_NAME":/aws-data-wrangler/ \
17+
--workdir /aws-data-wrangler/building/lambda \
18+
-it \
19+
awswrangler-build-py36 \
20+
build-lambda-layer.sh "${VERSION}-py3.6" "ninja"
2021

21-
# Generating PyArrow Files for Python 3.6
22-
#docker run \
23-
# --volume "$DIR_NAME":/aws-data-wrangler/ \
24-
# --workdir /aws-data-wrangler/building/lambda \
25-
# -it \
26-
# awswrangler-build-py36 \
27-
# build-pyarrow.sh
22+
# Python 3.7
23+
docker run \
24+
--volume "$DIR_NAME":/aws-data-wrangler/ \
25+
--workdir /aws-data-wrangler/building/lambda \
26+
-it \
27+
awswrangler-build-py37 \
28+
build-lambda-layer.sh "${VERSION}-py3.7" "ninja"
2829

29-
# Building the AWS Lambda Layer for Python 3.6
30-
#docker run \
31-
# --volume "$DIR_NAME":/aws-data-wrangler/ \
32-
# --workdir /aws-data-wrangler/building/lambda \
33-
# -it \
34-
# awswrangler-build-py36 \
35-
# build-layer.sh "${VERSION}-py3.6"
30+
# Python 3.8
31+
docker run \
32+
--volume "$DIR_NAME":/aws-data-wrangler/ \
33+
--workdir /aws-data-wrangler/building/lambda \
34+
-it \
35+
awswrangler-build-py38 \
36+
build-lambda-layer.sh "${VERSION}-py3.8" "ninja-build"

building/lambda/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ RUN yum install -y \
99
bison \
1010
flex \
1111
autoconf \
12+
ninja-build \
1213
${py_dev}
1314

14-
RUN pip3 install --upgrade pip six cython cmake
15+
RUN pip3 install --upgrade pip six cython cmake hypothesis
1516

1617
ADD requirements.txt /root/
1718
RUN pip3 install -r /root/requirements.txt

building/lambda/build-apache-arrow.sh

Lines changed: 0 additions & 37 deletions
This file was deleted.

building/lambda/build-docker-images.sh

100755100644
File mode changed.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/usr/bin/env bash
2+
set -ex
3+
4+
FILENAME="awswrangler-layer-${1}.zip"
5+
NINJA=${2}
6+
7+
pushd /aws-data-wrangler
8+
rm -rf python dist/pyarrow_files "dist/${FILENAME}" "${FILENAME}"
9+
popd
10+
11+
rm -rf dist arrow
12+
13+
export ARROW_HOME=$(pwd)/dist
14+
export LD_LIBRARY_PATH=$(pwd)/dist/lib:$LD_LIBRARY_PATH
15+
16+
git clone \
17+
--branch apache-arrow-0.16.0 \
18+
--single-branch \
19+
https://github.com/apache/arrow.git
20+
21+
mkdir dist
22+
mkdir arrow/cpp/build
23+
pushd arrow/cpp/build
24+
25+
cmake \
26+
-DCMAKE_INSTALL_PREFIX=$ARROW_HOME \
27+
-DCMAKE_INSTALL_LIBDIR=lib \
28+
-DARROW_FLIGHT=OFF \
29+
-DARROW_GANDIVA=OFF \
30+
-DARROW_ORC=OFF \
31+
-DARROW_WITH_SNAPPY=ON \
32+
-DARROW_WITH_ZLIB=ON \
33+
-DARROW_PARQUET=ON \
34+
-DARROW_CSV=OFF \
35+
-DARROW_PYTHON=ON \
36+
-DARROW_PLASMA=OFF \
37+
-DARROW_BUILD_TESTS=OFF \
38+
-GNinja \
39+
..
40+
41+
eval $NINJA
42+
eval "${NINJA} install"
43+
44+
popd
45+
46+
pushd arrow/python
47+
48+
export ARROW_PRE_0_15_IPC_FORMAT=0
49+
export PYARROW_WITH_HDFS=0
50+
export PYARROW_WITH_FLIGHT=0
51+
export PYARROW_WITH_GANDIVA=0
52+
export PYARROW_WITH_ORC=0
53+
export PYARROW_WITH_CUDA=0
54+
export PYARROW_WITH_PLASMA=0
55+
export PYARROW_WITH_PARQUET=1
56+
57+
python setup.py build_ext \
58+
--build-type=release \
59+
--bundle-arrow-cpp \
60+
bdist_wheel
61+
62+
pip install dist/pyarrow-*.whl -t /aws-data-wrangler/dist/pyarrow_files
63+
64+
popd
65+
66+
pushd /aws-data-wrangler
67+
68+
pip install . -t ./python
69+
70+
rm -rf python/pyarrow*
71+
rm -rf python/boto*
72+
73+
rm -f /aws-data-wrangler/dist/pyarrow_files/pyarrow/libarrow.so
74+
rm -f /aws-data-wrangler/dist/pyarrow_files/pyarrow/libparquet.so
75+
rm -f /aws-data-wrangler/dist/pyarrow_files/pyarrow/libarrow_python.so
76+
77+
cp -r /aws-data-wrangler/dist/pyarrow_files/pyarrow* python/
78+
79+
find python -wholename "*/tests/*" -type f -delete
80+
81+
zip -r9 "${FILENAME}" ./python
82+
mv "${FILENAME}" dist/
83+
84+
rm -rf python dist/pyarrow_files "${FILENAME}"
85+
86+
popd
87+
88+
rm -rf dist arrow

building/lambda/build-layer.sh

Lines changed: 0 additions & 22 deletions
This file was deleted.

building/lambda/build-pyarrow.sh

Lines changed: 0 additions & 23 deletions
This file was deleted.

setup-dev-env.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ set -ex
44
pip install --upgrade pip
55
pip install -r requirements-dev.txt
66
pip install -r requirements.txt
7+
pip install -e .

0 commit comments

Comments
 (0)