-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.sh
executable file
·41 lines (33 loc) · 1.12 KB
/
build.sh
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
#!/bin/zsh
NAME="loopdown"
BUILD_DIR=./dist/zipapp/usr/local/bin
VERSION=$(/usr/bin/awk -F ' ' '/_version: / {print $NF}' ./src/ldilib/__init__.py | /usr/bin/sed 's/"//g')
ARCHIVE_V=${BUILD_DIR}/${NAME}-${VERSION}
BUILD_OUT=./${NAME}
LOCAL_PYTHON=$(echo "/usr/bin/env python3")
INTERPRETER=$1
if [[ -z ${INTERPRETER} ]]; then
INTERPRETER="/usr/bin/env python3"
fi
if [[ ! -d ${BUILD_DIR} ]]; then
mkdir -p ${BUILD_DIR}
fi
if [[ ! ${INTERPRETER} == "/usr/bin/env python3" ]]; then
mkdir -p ${BUILD_DIR}/custom
ARCHIVE_V=${BUILD_DIR}/custom/${NAME}-${VERSION}
fi
if [[ ! -d ./src/packaging ]]; then
python3 -m pip install -r requirements.txt --target ./src
fi
BUILD_CMD=$(echo "${LOCAL_PYTHON}" -m zipapp src --compress --output ${ARCHIVE_V} --python=\"${INTERPRETER}\")
echo ${BUILD_CMD}
eval ${BUILD_CMD}
if [[ $? == 0 ]] && [[ -f ${ARCHIVE_V} ]]; then
if [[ ${INTERPRETER} == "/usr/bin/env python3" ]]; then
/bin/cp ${ARCHIVE_V} ${BUILD_OUT}
/bin/echo Built ${BUILD_OUT}
else
/bin/cp ${ARCHIVE_V} ${BUILD_DIR}/custom/${NAME}
/bin/echo Built ${BUILD_DIR}/custom/${NAME}
fi
fi