forked from apple/coremltools
-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure
executable file
·107 lines (91 loc) · 2.64 KB
/
configure
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
# Exit immediately on failure of a subcommand
set -e
##=============================================================================
## Main configuration processing
COREMLTOOLS_HOME=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
BUILD_DIR="${COREMLTOOLS_HOME}/build"
# TODO(Keith-Wyss): Allow configuring BUILD_DIR. This doesn't have to be the
# same as CMAKE's build directory, but scripts/python_env.sh relies on it.
COREMLTOOLS_ENV=coremltools-dev
# command flag options
cleanup_option=0
PYTHON=$(which python)
function print_help {
echo "Configures the build with the specified toolchain. "
echo
echo "If configure has already been run before, running configure "
echo "will simply reconfigure the build with no changes. "
echo
echo "Usage: ./configure <options>"
echo
echo " --cleanup Clean up everything."
echo " --python=* Python to use for configuration."
echo
echo "Example: ./configure"
echo
echo "Cleanup all build directories"
echo "Example: ./configure --cleanup"
echo
exit 1
} # end of print help
function unknown_option {
echo "Unrecognized option: $1"
echo "To get help, run ./configure --help"
exit 1
} # end of unknown option
function run_cleanup {
echo "cleaning up";
rm -rf $BUILD_DIR
}
function run_cleanup_prompt {
#!/bin/bash
echo "This script completely erases all build folders including dependencies!"
if [[ $default_yes == 1 ]]; then
yesorno="yes"
else
echo "Are you sure you want to continue? (yes or no)"
read yesorno;
fi
if [ "$yesorno" == "yes" ]; then
run_cleanup
else
echo "Doing nothing!";
fi
}
###############################################################################
#
# Parse command line configure flags ------------------------------------------
#
while [ $# -gt 0 ]
do case $1 in
--python=*) PYTHON=${1##--python=} ;;
--cleanup) cleanup_option=1;;
--help) print_help ;;
*) unknown_option $1 ;;
esac
shift
done
if [[ $cleanup_option == 1 ]]; then
run_cleanup_prompt
exit 0
fi
mkdir -p $BUILD_DIR
cd $BUILD_DIR
# Setup a new virtual env using the existing python
echo "Creating a new virtual environment in $BUILD_DIR/env"
$PYTHON -m pip install virtualenv
$PYTHON -m virtualenv $BUILD_DIR/$COREMLTOOLS_ENV
# Activate and install packages in the environment
source $BUILD_DIR/$COREMLTOOLS_ENV/bin/activate
pip install -r $COREMLTOOLS_HOME/requirements.pip
deactivate
echo
echo
echo
echo "Python env for coremltools development setup."
echo
echo "Run the following command to to activate it."
echo
echo " source ./scripts/python_env.sh"
echo