Skip to content

Commit 26a150d

Browse files
committed
pdal and pdal-python layers
1 parent 2731bb5 commit 26a150d

File tree

4 files changed

+128
-63
lines changed

4 files changed

+128
-63
lines changed

Dockerfile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,6 @@ RUN \
173173
&& cd /var/task \
174174
&& rm -rf xerces*
175175

176-
ADD https://api.github.com/repos/PDAL/PDAL/commits?sha=${PDAL_VERSION} \
177-
/tmp/bust-cache
178-
179176

180177
RUN \
181178
git clone https://github.com/PDAL/PDAL.git --branch ${PDAL_VERSION} \
@@ -194,15 +191,15 @@ RUN \
194191
-DWITH_ZSTD=ON \
195192
-DCMAKE_LIBRARY_PATH:FILEPATH="$DESTDIR/usr/lib" \
196193
-DCMAKE_INCLUDE_PATH:FILEPATH="$DESTDIR/usr/include" \
197-
-DCMAKE_INSTALL_PREFIX=$PREFIX \
194+
-DCMAKE_INSTALL_PREFIX=/usr \
198195
-DWITH_TESTS=OFF \
199196
-DCMAKE_INSTALL_LIBDIR=lib \
200197
&& make -j ${PARALLEL} \
201198
&& make install \
202199
&& make install DESTDIR=/ \
203200
&& DESTDIR=/ make install \
204201
&& cd /var/task \
205-
&& rm -rf pdal*
202+
&& rm -rf PDAL*
206203

207204
#RUN \
208205
# git clone https://github.com/PDAL/python.git pdal-python \
@@ -227,6 +224,12 @@ RUN \
227224
&& cd /var/task \
228225
&& rm -rf entwine*
229226

227+
228+
RUN DESTDIR= python -m pip install PDAL --prefix /build/python \
229+
&& python -m pip install scipy scikit-learn --prefix /build/python \
230+
&& cd /var/task \
231+
&& rm -rf pdal-python
232+
230233
RUN rm /build/usr/lib/*.la ; rm /build/usr/lib/*.a
231234
RUN rm /build/usr/lib64/*.a
232235
RUN ldconfig

README.rst

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

4646
$ ./create-lambda-layer.sh
47-
Published version 32 for Lambda layer pdal
48-
Setting execution access to public for version 32 for Lambda layer pdal
47+
Published version 38 for Lambda layer pdal
48+
Setting execution access to public for version 38 for Lambda layer pdal
4949
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'
5053

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

create-lambda-layer.sh

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,48 @@
1+
#!/bin/bash
12

2-
LAYERNAME="pdal"
3-
LAYER=$(aws lambda publish-layer-version \
4-
--layer-name $LAYERNAME \
5-
--description "PDAL 2.0.1 softare" \
6-
--zip-file fileb://./lambda-deploy.zip \
7-
--compatible-runtimes "provided" \
8-
--license-info BSD \
9-
--region $AWS_REGION \
10-
--profile $AWS_PROFILE)
3+
#LAYERNAME="pdal"
114

5+
create_layer()
6+
{
7+
LAYERNAME="$1"
8+
ZIPFILE="$2"
9+
DESCRIPTION="$3"
1210

13-
VERSION=$(aws lambda list-layers --region $AWS_REGION |jq '.Layers[]| select(.LayerName=="'$LAYERNAME'").LatestMatchingVersion.Version' -r)
11+
LAYER=$(aws lambda publish-layer-version \
12+
--layer-name $LAYERNAME \
13+
--description "$DESCRIPTION" \
14+
--zip-file fileb://./$ZIPFILE\
15+
--compatible-runtimes "provided" \
16+
--license-info BSD \
17+
--region $AWS_REGION \
18+
--profile $AWS_PROFILE)
1419

15-
echo "Published version $VERSION for Lambda layer $LAYERNAME"
1620

17-
LAYER=$(aws lambda get-layer-version \
18-
--layer-name pdal \
19-
--version-number $VERSION \
20-
--region $AWS_REGION \
21-
--profile $AWS_PROFILE)
21+
VERSION=$(aws lambda list-layers --region $AWS_REGION |jq '.Layers[]| select(.LayerName=="'$LAYERNAME'").LatestMatchingVersion.Version' -r)
2222

23+
echo "Published version $VERSION for Lambda layer $LAYERNAME"
2324

24-
echo "Setting execution access to public for version $VERSION for Lambda layer $LAYERNAME"
25-
PERMISSION=$(aws lambda add-layer-version-permission \
26-
--layer-name pdal \
27-
--version-number $VERSION \
28-
--statement-id "run-pdal-publicly" \
29-
--principal '*' \
30-
--action lambda:GetLayerVersion \
31-
--region $AWS_REGION \
32-
--profile $AWS_PROFILE )
25+
LAYER=$(aws lambda get-layer-version \
26+
--layer-name $LAYERNAME \
27+
--version-number $VERSION \
28+
--region $AWS_REGION \
29+
--profile $AWS_PROFILE)
3330

34-
LAYERARN=$(echo $LAYER | jq -r .LayerArn)
3531

36-
echo "Layer $LAYERNAME is available at '$LAYERARN'"
32+
echo "Setting execution access to public for version $VERSION for Lambda layer $LAYERNAME"
33+
PERMISSION=$(aws lambda add-layer-version-permission \
34+
--layer-name $LAYERNAME \
35+
--version-number $VERSION \
36+
--statement-id "run-pdal-publicly" \
37+
--principal '*' \
38+
--action lambda:GetLayerVersion \
39+
--region $AWS_REGION \
40+
--profile $AWS_PROFILE )
3741

42+
LAYERARN=$(echo $LAYER | jq -r .LayerArn)
43+
44+
echo "Layer $LAYERNAME is available at '$LAYERARN'"
45+
46+
}
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"

package-pdal.sh

Lines changed: 77 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,90 @@
11
#!/bin/sh
22

3-
export DEPLOY_DIR=/output/lambda
4-
5-
PACKAGE_NAME="lambda-deploy.zip"
6-
mkdir -p $DEPLOY_DIR/lib
7-
mkdir -p $DEPLOY_DIR/share
8-
9-
cp -r /build/usr/lib/* $DEPLOY_DIR/lib
10-
cp -r /build/usr/lib64/* $DEPLOY_DIR/lib
11-
cp -r /build/usr/bin $DEPLOY_DIR/bin
12-
cp /usr/lib64/libjpeg.so.62.0.0 $DEPLOY_DIR/lib/
13-
cp /usr/lib64/libxml2.so.2.9.1 $DEPLOY_DIR/lib/
14-
cp /usr/lib64/liblzma.so.5.2.2 $DEPLOY_DIR/lib/
15-
cp /usr/lib64/libtiff.so.5.2.0 $DEPLOY_DIR/lib/
16-
cp /usr/lib64/libpng.so.3.49.0 $DEPLOY_DIR/lib/
17-
cp /usr/lib/libsqlite3.so.0.8.6 $DEPLOY_DIR/lib/
18-
rm -rf $DEPLOY_DIR/lib/*.a
19-
rm -rf $DEPLOY_DIR/bin/projinfo
20-
rm -rf $DEPLOY_DIR/bin/gie
21-
rm -rf $DEPLOY_DIR/lib/libpdal_plugin*
22-
rm -rf $DEPLOY_DIR/lib/python3.6
23-
cp -r /build/python/* $DEPLOY_DIR
24-
25-
FILES=$DEPLOY_DIR/lib/*.so*
3+
export PDAL_DEPLOY_DIR=/output/pdal
4+
export SK_DEPLOY_DIR=/output/sk
5+
6+
PDAL_PACKAGE_NAME="pdal-lambda-deploy.zip"
7+
SK_PACKAGE_NAME="pdal-python-lambda-deploy.zip"
8+
9+
make_dirs()
10+
{
11+
OUTDIR=$1
12+
13+
mkdir -p $OUTDIR/lib
14+
mkdir -p $OUTDIR/bin
15+
mkdir -p $OUTDIR/share
16+
}
17+
18+
make_dirs $PDAL_DEPLOY_DIR
19+
make_dirs $SK_DEPLOY_DIR
20+
21+
cd /build
22+
FILES=$(find . -name '*.so*')
23+
2624
for f in $FILES
2725
do
2826
echo "Stripping unneeded symbols from $f"
2927
strip --strip-unneeded $f
3028
done;
3129

32-
rsync -ax /build/usr/share/gdal $DEPLOY_DIR/share/
33-
rsync -ax /build/usr/share/proj $DEPLOY_DIR/share/
30+
rm -rf /build/usr/lib/*.a
31+
32+
cd /build
33+
find . -name '*.pyc' -delete
34+
find . -name '*cmake*' -exec rm -rf {} +;
35+
find . -name '*tests*' -exec rm -rf {} +;
36+
find . -name '*test*' -exec rm -rf {} +;
37+
find . -name '*__pycache__*' -exec rm -rf {} +;
38+
find . -name '*datasets*' -exec rm -rf {} +;
39+
40+
rm -rf ./python/lib/python3.7/site-packages/joblib/test
41+
cd python
42+
find . -type d -name "datasets" -exec rm -rf \;
43+
cp lib/libpdal_* $SK_DEPLOY_DIR/lib
44+
cd ..
45+
46+
cp -r /build/usr/lib/* $PDAL_DEPLOY_DIR/lib
47+
cp -r /build/usr/lib/libpdal_* $PDAL_DEPLOY_DIR/lib
48+
cp -r /build/usr/lib64/* $PDAL_DEPLOY_DIR/lib
49+
cp -r /build/usr/bin/gdal* $PDAL_DEPLOY_DIR/bin
50+
cp -r /build/usr/bin/entwine $PDAL_DEPLOY_DIR/bin
51+
cp -r /build/usr/bin/pdal $PDAL_DEPLOY_DIR/bin
52+
cp -r /build/usr/bin/cs2cs $PDAL_DEPLOY_DIR/bin
53+
cp -r /build/usr/bin/ogr* $PDAL_DEPLOY_DIR/bin
54+
55+
rm -rf /build/lib/cmake
56+
57+
copy_support()
58+
{
59+
OUTDIR=$1
60+
cp /usr/lib64/libjpeg.so.62.0.0 $OUTDIR/lib/
61+
cp /usr/lib64/libxml2.so.2.9.1 $OUTDIR/lib/
62+
cp /usr/lib64/liblzma.so.5.2.2 $OUTDIR/lib/
63+
cp /usr/lib64/libtiff.so.5.2.0 $OUTDIR/lib/
64+
cp /usr/lib64/libpng.so.3.49.0 $OUTDIR/lib/
65+
cp /usr/lib/libsqlite3.so.0.8.6 $OUTDIR/lib/
66+
}
67+
68+
copy_support $PDAL_DEPLOY_DIR
69+
copy_support $SK_DEPLOY_DIR
70+
71+
cp -r /build/python/lib/python3.7/ $SK_DEPLOY_DIR/lib/python3.7/
72+
73+
74+
75+
76+
#rsync -ax /build/usr/share/gdal $PDAL_DEPLOY_DIR/share/
77+
rsync -ax /build/usr/share/proj/proj.db $PDAL_DEPLOY_DIR/share/proj/
3478

35-
cd $DEPLOY_DIR
36-
zip --symlinks -9 -ruq ../$PACKAGE_NAME ./
37-
rm -rf $DEPLOY_DIR
38-
echo "writing deploy dir $DEPLOY_DIR"
79+
cd $PDAL_DEPLOY_DIR
80+
zip --symlinks -9 -ruq ../$PDAL_PACKAGE_NAME ./
81+
rm -rf $PDAL_DEPLOY_DIR
82+
echo "writing deploy dir $PDAL_DEPLOY_DIR"
3983

84+
cd $SK_DEPLOY_DIR
85+
zip --symlinks -9 -ruq ../$SK_PACKAGE_NAME ./
86+
rm -rf $SK_DEPLOY_DIR
87+
echo "writing deploy dir $SK_DEPLOY_DIR"
4088

4189

4290

0 commit comments

Comments
 (0)