#!/bin/sh
# autopkgtest check: Python module successfully imported and executed
# Requires that AUTOPKGTEST_TMP and PYINTERPRETER are set
set -e

# python3.Y at build time, python3 at CI time
PYINTERPRETER=${PYINTERPRETER:-python3}

# Presence of $AUTOPKGTEST_TMP implies that someone will handle cleanup for us
if [ -z "$AUTOPKGTEST_TMP" ]
then
	echo "Required envvar AUTOPKGTEST is not set" >&2
	exit 1
fi

# Copy the simple example and the training data to $AUTOPKGTEST, and execute it
mkdir -p "$AUTOPKGTEST_TMP/$PYINTERPRETER"
cp examples/simple_train.py "$AUTOPKGTEST_TMP/$PYINTERPRETER"
cp examples/xor.data "$AUTOPKGTEST_TMP/$PYINTERPRETER"
cd "$AUTOPKGTEST_TMP/$PYINTERPRETER"

$PYINTERPRETER simple_train.py
echo "run: OK"
