Skip to content

Commit 300d68b

Browse files
authored
Merge pull request pytorch#241 from pjh5/circle
Adding script to setup env before run_tests
2 parents 1fc173d + 82c3e6c commit 300d68b

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

setup_and_test.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
set -ex
2+
3+
SOURCE_DIR=$(cd $(dirname $0) && pwd)
4+
5+
# Written for circleci binary builds, to manage setting up the python env
6+
# before calling run_tests.sh
7+
8+
# Parameters
9+
#############################################################################
10+
if [[ -z "$PACKAGE_TYPE" || -z "$DESIRED_PYTHON" || -z "$PYVER_SHORT" || -z "$CUMAJMIN" || -z "$PYTORCH_FINAL_PACKAGE_DIR" ]]; then
11+
echo "The env variable PACKAGE_TYPE must be set to 'conda' or 'manywheel' or 'libtorch'"
12+
echo "The env variable DESIRED_PYTHON must be set like 'cp27-cp27mu'"
13+
echo "The env variable PYVER_SHORT must be set like '2.7'"
14+
echo "The env variable CUMAJMIN must be set like 'cpu' or 'cu80' etc"
15+
echo "The env variable PYTORCH_FINAL_PACKAGE_DIR must be set to a directory"
16+
exit 1
17+
fi
18+
py_nodot="$(echo $PYVER_SHORT | tr -d '.')"
19+
20+
# Create Python env for testing
21+
#############################################################################
22+
if [[ "$PACKAGE_TYPE" == manywheel ]]; then
23+
export PATH="/opt/python/$DESIRED_PYTHON/bin:$PATH"
24+
elif [[ "$PACKAGE_TYPE" == conda ]]; then
25+
source deactivate || true
26+
conda create -yn "setuptest$py_nodot" python=$py_nodot
27+
source activate "setuptest$py_nodot"
28+
else
29+
echo "This script does not handle $PACKAGE_TYPE packages"
30+
exit 1
31+
fi
32+
33+
# Install package
34+
#############################################################################
35+
package="$(ls $PYTORCH_FINAL_PACKAGE_DIR)"
36+
if [[ "$PACKAGE_TYPE" == manywheel ]]; then
37+
pip install $package
38+
else
39+
conda install -y $package
40+
fi
41+
42+
# Test the package
43+
#############################################################################
44+
"$SOURCE_DIR/run_tests.sh" "$PACKAGE_TYPE" "$PYVER_SHORT" "$CUMAJMIN"

0 commit comments

Comments
 (0)