-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathpackage_python.sh
69 lines (60 loc) · 1.87 KB
/
package_python.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
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
#!/bin/bash
set -e
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
# guess versions
if [ -z "$1" ]; then
DICT_VERSION=$("$SCRIPT_DIR/gradlew" -q showVersion)
VERSION=${DICT_VERSION}
else
DICT_VERSION=$1
if [ -z "$2" ]; then
VERSION=${DICT_VERSION}
else
VERSION=$2
fi
fi
echo "VERSION=$VERSION, DICT_VERSION=$DICT_VERSION"
PACKAGES_ROOT="$SCRIPT_DIR/build/python"
BINARY_DIC_ROOT="$SCRIPT_DIR/build/dict/bin/$DICT_VERSION"
if [ -z "$NO_WHEELS" ] && [ ! -d "$BINARY_DIC_ROOT" ]; then
echo "binary dictionaries are not present in $BINARY_DIC_ROOT"
echo "run ./gradlew build to compile binary dictionaries"
exit 1
fi
set +e
rm -rf "$PACKAGES_ROOT/$VERSION"
if [ -z "$NO_WHEELS" ]; then
mkdir -p "$PACKAGES_ROOT/wheels"
fi
mkdir -p "$PACKAGES_ROOT/sdist"
set -e
home=$SCRIPT_DIR
for dict_type in small core full
do
temp="$PACKAGES_ROOT/$VERSION/$dict_type"
pkg="${temp}/sudachidict_${dict_type}"
mkdir -p ${pkg}
# prepare package directory
mkdir "${pkg}/resources"
touch "${pkg}/__init__.py"
cp python/README.md "${temp}"
cp LEGAL ${temp}
cp LICENSE-2.0.txt "${temp}"
cp python/MANIFEST.in "${temp}"
cp python/setup.py "${temp}"
cat python/INFO.json | sed "s/%%VERSION%%/${VERSION}/g" | sed "s/%%DICT_VERSION%%/${DICT_VERSION}/g" | sed "s/%%DICT_TYPE%%/${dict_type}/g" > ${temp}/INFO.json
if [ -z "$NO_WHEELS" ]; then
# build a wheel with binary dictionaries included
cp "$BINARY_DIC_ROOT/system_${dict_type}.dic" "${pkg}/resources/system.dic"
python3 -m build \
--outdir "$PACKAGES_ROOT/wheels" \
--no-isolation --wheel \
"${temp}"
fi
# build sdist with binary dictionary not included
rm -rf "${pkg}/resources"
python3 -m build \
--outdir "$PACKAGES_ROOT/sdist" \
--no-isolation --sdist \
"${temp}"
done