Skip to content

Commit f229c86

Browse files
committed
pdal-python layer creation
1 parent 26a150d commit f229c86

File tree

5 files changed

+104
-53
lines changed

5 files changed

+104
-53
lines changed

Dockerfile

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@ RUN \
2727
glib2-devel libtiff-devel pkg-config libcurl-devel; # required for pkg-config
2828

2929

30+
# curl -O https://mirror.centos.org/centos/6/extras/x86_64/Packages/centos-release-scl-rh-2-3.el6.centos.noarch.rpm && \
31+
# curl -O https://mirror.centos.org/centos/6/extras/x86_64/Packages/centos-release-scl-7-3.el6.centos.noarch.rpm && \
3032

3133
RUN \
3234
yum install -y iso-codes && \
33-
curl -O http://vault.centos.org/6.5/SCL/x86_64/scl-utils/scl-utils-20120927-11.el6.centos.alt.x86_64.rpm && \
34-
curl -O http://vault.centos.org/6.5/SCL/x86_64/scl-utils/scl-utils-build-20120927-11.el6.centos.alt.x86_64.rpm && \
35-
curl -O http://mirror.centos.org/centos/6/extras/x86_64/Packages/centos-release-scl-rh-2-3.el6.centos.noarch.rpm && \
36-
curl -O http://mirror.centos.org/centos/6/extras/x86_64/Packages/centos-release-scl-7-3.el6.centos.noarch.rpm && \
35+
curl -O https://vault.centos.org/6.5/SCL/x86_64/scl-utils/scl-utils-20120927-11.el6.centos.alt.x86_64.rpm && \
36+
curl -O https://vault.centos.org/6.5/SCL/x86_64/scl-utils/scl-utils-build-20120927-11.el6.centos.alt.x86_64.rpm && \
37+
curl -O https://mirror.facebook.net/centos/6/extras/x86_64/Packages/centos-release-scl-rh-2-3.el6.centos.noarch.rpm && \
38+
curl -O https://mirror.facebook.net/centos/6/extras/x86_64/Packages/centos-release-scl-7-3.el6.centos.noarch.rpm && \
3739
rpm -Uvh *.rpm && \
3840
rm *.rpm && \
3941
yum install -y devtoolset-7-gcc-c++ devtoolset-7-make devtoolset-7-build ;
@@ -43,13 +45,15 @@ SHELL [ "/usr/bin/scl", "enable", "devtoolset-7"]
4345
RUN gcc --version
4446

4547

46-
RUN \
47-
wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-x86_64.sh \
48-
&& chmod +x cmake-${CMAKE_VERSION}-Linux-x86_64.sh \
49-
&& ./cmake-${CMAKE_VERSION}-Linux-x86_64.sh --skip-license --prefix=/usr \
50-
&& cd /var/task \
51-
&& rm -rf cmake*
48+
#RUN \
49+
# wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-x86_64.sh \
50+
# && chmod +x cmake-${CMAKE_VERSION}-Linux-x86_64.sh \
51+
# && ./cmake-${CMAKE_VERSION}-Linux-x86_64.sh --skip-license --prefix=/usr \
52+
# && cd /var/task \
53+
# && rm -rf cmake*
5254

55+
RUN \
56+
pip install cmake ninja
5357

5458
RUN git clone https://github.com/LASzip/LASzip.git laszip \
5559
&& cd laszip \
@@ -74,6 +78,7 @@ RUN \
7478
-G Ninja \
7579
-DCMAKE_INSTALL_PREFIX=/usr/ \
7680
-DCMAKE_BUILD_TYPE="Release" \
81+
-DBUILD_TESTING=OFF \
7782
. \
7883
&& ninja -j ${PARALLEL} \
7984
&& ninja install \
@@ -123,6 +128,7 @@ RUN \
123128
-G Ninja \
124129
-DCMAKE_INSTALL_PREFIX=/usr/ \
125130
-DCMAKE_BUILD_TYPE="Release" \
131+
-DBUILD_TESTING=OFF \
126132
.. \
127133
&& ninja -j ${PARALLEL} \
128134
&& ninja install \
@@ -167,6 +173,7 @@ RUN \
167173
-G "Ninja" \
168174
-DCMAKE_BUILD_TYPE=Release \
169175
-DCMAKE_INSTALL_PREFIX=/usr \
176+
-DBUILD_TESTING=OFF \
170177
&& ninja -j ${PARALLEL} \
171178
&& ninja install \
172179
&& DESTDIR= ninja install \
@@ -201,15 +208,6 @@ RUN \
201208
&& cd /var/task \
202209
&& rm -rf PDAL*
203210

204-
#RUN \
205-
# git clone https://github.com/PDAL/python.git pdal-python \
206-
# && cd pdal-python \
207-
# && python -m pip install --upgrade pip \
208-
# && pip install numpy scikit-build packaging ninja cmake cython \
209-
# && bash -c 'python setup.py build' \
210-
# && bash -c 'python setup.py bdist_wheel' \
211-
# && ls dist
212-
213211
RUN \
214212
git clone https://github.com/connormanning/entwine.git --branch ${ENTWINE_VERSION} \
215213
&& cd entwine \
@@ -224,14 +222,40 @@ RUN \
224222
&& cd /var/task \
225223
&& rm -rf entwine*
226224

225+
RUN wget https://github.com/Reference-LAPACK/lapack/archive/v3.9.0.tar.gz \
226+
&& tar zxvf v3.9.0.tar.gz \
227+
&& cd lapack-3.9.0/ \
228+
&& mkdir -p _build \
229+
&& cd _build \
230+
&& cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -G Ninja -DBUILD_SHARED_LIBS=ON \
231+
&& ninja -j ${PARALLEL} \
232+
&& ninja install \
233+
&& DESTDIR=/ ninja install \
234+
&& cd /var/task \
235+
&& rm -rf lapack*
236+
237+
RUN wget https://github.com/xianyi/OpenBLAS/archive/v0.3.10.tar.gz \
238+
&& tar zxvf v0.3.10.tar.gz \
239+
&& cd OpenBLAS-0.3.10/ \
240+
&& mkdir -p _build \
241+
&& cd _build \
242+
&& cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -G Ninja -DBUILD_SHARED_LIBS=ON \
243+
&& ninja -j ${PARALLEL} \
244+
&& ninja install \
245+
&& DESTDIR=/ ninja install \
246+
&& cd /var/task \
247+
&& rm -rf OpenBLAS*
227248

249+
# scikit-build will respect our DESTDIR and put things in the wrong directory
228250
RUN DESTDIR= python -m pip install PDAL --prefix /build/python \
229-
&& python -m pip install scipy scikit-learn --prefix /build/python \
251+
&& python -m pip install pandas scipy scikit-learn --no-binary :all: --verbose --prefix /build/python \
230252
&& cd /var/task \
231253
&& rm -rf pdal-python
232254

255+
RUN DESTDIR= python -m pip install pytz --target /build/python/lib/python3.7/site-packages/
256+
233257
RUN rm /build/usr/lib/*.la ; rm /build/usr/lib/*.a
234-
RUN rm /build/usr/lib64/*.a
258+
RUN rm /build/usr/lib64/*.a
235259
RUN ldconfig
236260
ADD package-pdal.sh /
237261

README.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ Instructions
4444
::
4545

4646
$ ./create-lambda-layer.sh
47-
Published version 38 for Lambda layer pdal
48-
Setting execution access to public for version 38 for Lambda layer pdal
49-
Layer pdal is available at 'arn:aws:lambda:us-east-1:163178234892:layer:pdal'
50-
Published version 2 for Lambda layer pdal-python
51-
Setting execution access to public for version 2 for Lambda layer pdal-python
52-
Layer pdal-python is available at 'arn:aws:lambda:us-east-1:163178234892:layer:pdal-python'
47+
Published version 40 for Lambda layer pdal
48+
Setting execution access to public for version 40 for Lambda layer pdal
49+
Layer pdal is available at 'arn:aws:lambda:us-east-1:163178234892:layer:pdal:40'
50+
Published version 17 for Lambda layer pdal-python
51+
Setting execution access to public for version 17 for Lambda layer pdal-python
52+
Layer pdal-python is available at 'arn:aws:lambda:us-east-1:163178234892:layer:pdal-python:17'
5353

5454
.. _`Lambda Layers`: https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html
5555
.. _`GeoLambda`: https://github.com/developmentseed/geolambda

build.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
CONTAINER="pdal-lambda"
44
docker build -t $CONTAINER -f Dockerfile .
55
rm -rf lambda
6-
rm lambda-deploy.zip
76
mkdir -p lambda
87

98
docker run -v `pwd`:/output $CONTAINER /package-pdal.sh

create-lambda-layer.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ create_layer()
77
LAYERNAME="$1"
88
ZIPFILE="$2"
99
DESCRIPTION="$3"
10+
RUNTIMES="$4"
1011

1112
LAYER=$(aws lambda publish-layer-version \
1213
--layer-name $LAYERNAME \
1314
--description "$DESCRIPTION" \
1415
--zip-file fileb://./$ZIPFILE\
15-
--compatible-runtimes "provided" \
16+
--compatible-runtimes "$RUNTIMES" \
1617
--license-info BSD \
1718
--region $AWS_REGION \
1819
--profile $AWS_PROFILE)
@@ -44,5 +45,6 @@ create_layer()
4445
echo "Layer $LAYERNAME is available at '$LAYERARN'"
4546

4647
}
47-
create_layer "pdal" "pdal-lambda-deploy.zip" "PDAL 2.2.0 software"
48-
create_layer "pdal-python" "sk-lambda-deploy.zip" "PDAL Python 2.3.5 software"
48+
49+
create_layer "pdal" "pdal-lambda-deploy.zip" "PDAL 2.2.0 software" "provided"
50+
create_layer "pdal-python" "pdal-python-lambda-deploy.zip" "PDAL Python 2.3.5 software" "python3.7"

package-pdal.sh

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,63 @@
11
#!/bin/sh
22

3-
export PDAL_DEPLOY_DIR=/output/pdal
4-
export SK_DEPLOY_DIR=/output/sk
3+
export PDAL_DEPLOY_DIR=/pdal-package
4+
export SK_DEPLOY_DIR=/sk-package
55

66
PDAL_PACKAGE_NAME="pdal-lambda-deploy.zip"
77
SK_PACKAGE_NAME="pdal-python-lambda-deploy.zip"
88

9-
make_dirs()
10-
{
11-
OUTDIR=$1
9+
mkdir -p $PDAL_DEPLOY_DIR/lib
10+
mkdir -p $PDAL_DEPLOY_DIR/bin
11+
mkdir -p $PDAL_DEPLOY_DIR/share
1212

13-
mkdir -p $OUTDIR/lib
14-
mkdir -p $OUTDIR/bin
15-
mkdir -p $OUTDIR/share
16-
}
13+
PYTHON_DEPLOY_DIR=$SK_DEPLOY_DIR/python/lib/python3.7/site-packages
14+
mkdir -p $PYTHON_DEPLOY_DIR
15+
mkdir -p $SK_DEPLOY_DIR/lib
1716

18-
make_dirs $PDAL_DEPLOY_DIR
19-
make_dirs $SK_DEPLOY_DIR
2017

21-
cd /build
22-
FILES=$(find . -name '*.so*')
18+
cp /build/python/lib/libpdal_plugin_filter_python.so $SK_DEPLOY_DIR/lib
19+
cp /build/python/lib/libpdal_plugin_reader_numpy.so $SK_DEPLOY_DIR/lib
20+
#cp -r /usr/lib64/atlas/lib*.so* $SK_DEPLOY_DIR/lib
21+
cp -r /usr/lib64/libgfortran.so* $SK_DEPLOY_DIR/lib
22+
cp -r /usr/lib64/libquadmath.so* $SK_DEPLOY_DIR/lib
23+
cp -r /usr/lib64/libblas.so* $SK_DEPLOY_DIR/lib
24+
cp -r /usr/lib64/libopenblas.so* $SK_DEPLOY_DIR/lib
25+
cp -r /usr/lib64/liblapack.so* $SK_DEPLOY_DIR/lib
2326

24-
for f in $FILES
25-
do
26-
echo "Stripping unneeded symbols from $f"
27-
strip --strip-unneeded $f
28-
done;
27+
28+
strip_symbols()
29+
{
30+
DIR=$1
31+
pushd $1
32+
33+
FILES=$(find . -name '*.so*')
34+
35+
for f in $FILES
36+
do
37+
echo "Stripping unneeded symbols from $f"
38+
strip --strip-unneeded $f
39+
done;
40+
popd
41+
}
42+
43+
strip_symbols /build
44+
strip_symbols $SK_DEPLOY_DIR
2945

3046
rm -rf /build/usr/lib/*.a
3147

3248
cd /build
3349
find . -name '*.pyc' -delete
3450
find . -name '*cmake*' -exec rm -rf {} +;
35-
find . -name '*tests*' -exec rm -rf {} +;
36-
find . -name '*test*' -exec rm -rf {} +;
51+
#find . -name '*tests*' -exec rm -rf {} +;
52+
#find . -name '*test*' -exec rm -rf {} +;
3753
find . -name '*__pycache__*' -exec rm -rf {} +;
3854
find . -name '*datasets*' -exec rm -rf {} +;
3955

4056
rm -rf ./python/lib/python3.7/site-packages/joblib/test
4157
cd python
4258
find . -type d -name "datasets" -exec rm -rf \;
4359
cp lib/libpdal_* $SK_DEPLOY_DIR/lib
60+
4461
cd ..
4562

4663
cp -r /build/usr/lib/* $PDAL_DEPLOY_DIR/lib
@@ -57,6 +74,7 @@ rm -rf /build/lib/cmake
5774
copy_support()
5875
{
5976
OUTDIR=$1
77+
6078
cp /usr/lib64/libjpeg.so.62.0.0 $OUTDIR/lib/
6179
cp /usr/lib64/libxml2.so.2.9.1 $OUTDIR/lib/
6280
cp /usr/lib64/liblzma.so.5.2.2 $OUTDIR/lib/
@@ -66,9 +84,15 @@ copy_support()
6684
}
6785

6886
copy_support $PDAL_DEPLOY_DIR
69-
copy_support $SK_DEPLOY_DIR
7087

71-
cp -r /build/python/lib/python3.7/ $SK_DEPLOY_DIR/lib/python3.7/
88+
89+
#cp -r /usr/lib64/atlas/libptf77blas.so* $SK_DEPLOY_DIR/lib
90+
#cp -r /usr/lib64/atlas/libgfortran.so* $SK_DEPLOY_DIR/lib
91+
92+
rm /build/python/lib/libpdal_plugin_filter_python.so
93+
rm /build/python/lib/libpdal_plugin_reader_numpy.so
94+
95+
cp -r /build/python/lib/python3.7/site-packages/* $PYTHON_DEPLOY_DIR
7296

7397

7498

@@ -86,5 +110,7 @@ zip --symlinks -9 -ruq ../$SK_PACKAGE_NAME ./
86110
rm -rf $SK_DEPLOY_DIR
87111
echo "writing deploy dir $SK_DEPLOY_DIR"
88112

113+
cp /$PDAL_PACKAGE_NAME /output
114+
cp /$SK_PACKAGE_NAME /output
89115

90116

0 commit comments

Comments
 (0)