#!/bin/sh

set -e

VERSION=$(dpkg-query --show --showformat='${Version}' sentencepiece | cut -d- -f1)
cat <<EOS > test_module.py
import sentencepiece as spm

print('VERSION={}'.format(spm.__version__))
EOS

PYVERSION=$(python3 test_module.py)
if [ "VERSION=$VERSION" = "$PYVERSION" ]; then
   echo "run python module"
else
   echo "Failed to get module version: <${PYVERSION}>"
   exit 1
fi
rm -f test_module.py
