forked from mattharley/pythonwa
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·76 lines (65 loc) · 2.35 KB
/
build.sh
File metadata and controls
executable file
·76 lines (65 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
echo "********************"
echo "PWD:$(pwd)"
BASE_PWD=$(pwd)
echo "********************"
# A list of every directory to build.
LAYERS="default_layer markdown_layer"
build_layer_from_requirements () {
###
# Function to build a zip file from a given requirements.txt file
# give the directory with the requirements.txt and it will build a zip
# with the same name as the directory
###
PY_VERSION=3.13
DOCKER_BUILD_IMAGE="public.ecr.aws/sam/build-python3.13:latest-x86_64"
LAMBDA_LAYERS_DIR="."
LAYER_NAME=$1
#poetry export --only=main --without-hashes -f requirements.txt --output $(LAMBDA_LAYERS_DIR)/requirements.txt
echo "Processing ${LAYER_NAME}/requirements.txt"
# pushd ..
# popd
echo building
rm -Rv "${LAYER_NAME}.zip"
rm -Rv ./python
echo "** ** ** ** ** ** ** ** ** **"
echo "LS BASE_PWD"
ls -lah "${BASE_PWD}"
echo "** ** ** ** ** ** ** ** ** **"
echo "LS LAYER_NAME"
ls -lah "./${LAYER_NAME}"
echo "** ** ** ** ** ** ** ** ** **"
echo "* * * * * * * * * * * * * * *"
docker run \
-v "$HOME/.netrc":/root/.netrc:ro \
-v "${BASE_PWD}":/var/task \
"${DOCKER_BUILD_IMAGE}" \
/bin/sh -c "pwd ; echo '/var/task' ; ls -lah /var/task ; echo 'LAMBDA_LAYERS_DIR' ; ls -lah ${LAMBDA_LAYERS_DIR} ; echo '********' ; echo 'LAMBDA_LAYERS_DIR/LAYER_NAME' ; ls -lah ${LAMBDA_LAYERS_DIR}/${LAYER_NAME} ; echo '********' ; pip3 install -U pip && pip3 install -t ${LAMBDA_LAYERS_DIR}/python/lib/python${PY_VERSION}/site-packages/ -r ${LAMBDA_LAYERS_DIR}/${LAYER_NAME}/requirements.txt && exit"
cd "${LAMBDA_LAYERS_DIR}" && ls -lah && zip -r --exclude="*.swp" --exclude="**__pycache__**" --exclude="**/site-packages/boto3*" --exclude="**/site-packages/botocore*" --exclude="**/venv*" "${LAYER_NAME}.zip" ./python
echo "* * * * * * * * * * * * * * *"
echo "Clean UP"
rm -Rv ./python
}
create_requirements_from_poetry () {
LAYER_NAME=$1
pushd "$LAYER_NAME" || exit
uv lock --project pyproject.toml
uv export --project pyproject.toml --no-emit-project > requirements.txt
popd || exit
}
# build the list above
for DIR_NAME in $LAYERS
do
create_requirements_from_poetry "${DIR_NAME}"
build_layer_from_requirements "${DIR_NAME}"
done
#
## build the common libraries
#rm -v common.zip
#cd common || exit 1
#zip -r --exclude="*.swp" --exclude="**__pycache__**" --exclude="**/venv*" ../common.zip ./python
#cd ..
#
#ls -lah
#echo "build complete"
#exit 0