This repository has been archived by the owner on Feb 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathextra_functions.sh
51 lines (47 loc) · 1.59 KB
/
extra_functions.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
function setup_compiler {
# Install OpenMP support on macOS
if [ $(uname) == "Darwin" ]; then
brew install libomp
export CPPFLAGS="$CPPFLAGS -Xpreprocessor -fopenmp"
export CFLAGS="$CFLAGS -I/usr/local/opt/libomp/include"
export CXXFLAGS="$CXXFLAGS -I/usr/local/opt/libomp/include"
export LDFLAGS="$LDFLAGS -L/usr/local/opt/libomp/lib -lomp"
export DYLD_LIBRARY_PATH=/usr/local/opt/libomp/lib
fi
}
function teardown_compiler {
if [ $(uname) == "Darwin" ]; then
brew uninstall libomp
fi
}
function setup_test_venv {
# Create a new empty venv dedicated to testing for non-Linux platforms. On
# Linux the tests are run in a Docker container.
if [ $(uname) != "Linux" ]; then
deactivate || echo ""
$PYTHON_EXE -m venv test_venv
if [ $(uname) == "Darwin" ]; then
source test_venv/bin/activate
else
source test_venv/Scripts/activate
fi
# Defined python to be within this env
PYTHON_EXE=`which python`
PIP_CMD="$PYTHON_EXE -mpip"
# Note: the idiom "python -m pip install ..." is necessary to upgrade
# pip itself on Windows. Otherwise one would get a permission error on
# pip.exe.
python -m pip install --upgrade pip wheel
if [ "$TEST_DEPENDS" != "" ]; then
pip install $TEST_DEPENDS
fi
fi
}
function teardown_test_venv {
if [ $(uname) != "Linux" ]; then
deactivate || echo ""
if [ $(uname) == "Darwin" ]; then
source venv/bin/activate
fi
fi
}