sentencepiece/python/make_py_wheel.sh

74 lines
1.7 KiB
Bash
Raw Normal View History

2018-06-26 08:59:55 +03:00
#!/bin/bash
# Copyright 2018 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.!
set -e # exit immediately on error
set -x # display all commands
2018-07-24 09:22:49 +03:00
CMAKE_VERSION=3.12.0
2018-06-26 08:59:55 +03:00
run_docker() {
2018-06-26 08:59:55 +03:00
cd `dirname $0`
docker pull $1
docker run --rm -ti --name py_sentencepiece \
-v `pwd`/../:/sentencepiece -w /sentencepiece/python \
-td $1 /bin/bash
2018-06-26 20:42:24 +03:00
docker exec py_sentencepiece bash -c "./make_py_wheel.sh native $2"
2018-06-26 08:59:55 +03:00
docker stop py_sentencepiece
}
2018-06-26 08:59:55 +03:00
build() {
2018-06-26 20:42:24 +03:00
TRG=$1
2018-07-24 09:22:49 +03:00
rm -fr build
mkdir -p build
cd build
2018-06-26 08:59:55 +03:00
# Install sentencepiece
2018-07-24 09:22:49 +03:00
cmake ../.. -DSPM_ENABLE_SHARED=OFF
make -j4
make install
2018-06-26 08:59:55 +03:00
cd ..
for i in /opt/python/*
do
2020-12-28 13:28:18 +03:00
export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib
2021-06-16 13:04:14 +03:00
$i/bin/python setup.py clean
$i/bin/python setup.py bdist
2020-10-22 03:49:33 +03:00
strip build/*/*/*.so
$i/bin/python setup.py bdist_wheel
$i/bin/python setup.py test
rm -fr build
rm -fr *.so
done
cd dist
for i in *${TRG}.whl
do
auditwheel repair $i
done
2018-06-26 08:59:55 +03:00
mv -f wheelhouse/*${TRG}.whl .
2018-07-24 09:22:49 +03:00
cd ..
rm -fr build
}
2018-06-26 08:59:55 +03:00
if [ "$1" = "native" ]; then
2018-06-26 20:42:24 +03:00
build $2
2018-06-16 12:32:16 +03:00
elif [ "$#" -eq 1 ]; then
run_docker quay.io/pypa/manylinux2014_${1} ${1}
else
2020-10-12 20:36:35 +03:00
run_docker quay.io/pypa/manylinux2014_i686 i686
run_docker quay.io/pypa/manylinux2014_x86_64 x86_64
fi