Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6b9eb0f

Browse filesBrowse files
committed
Implement build timeouts
1 parent 3826d25 commit 6b9eb0f
Copy full SHA for 6b9eb0f

File tree

3 files changed

+56
-15
lines changed
Filter options

3 files changed

+56
-15
lines changed

‎.travis.yml

Copy file name to clipboardExpand all lines: .travis.yml
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,7 @@ install: |
934934
python setup.py sdist
935935
else
936936
build_wheel $REPO_DIR $PLAT
937+
ret_code=$?
937938
fi
938939
939940
set +x

‎travis_config.sh

Copy file name to clipboardExpand all lines: travis_config.sh
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ echo "=== Loading config.sh === "
77

88
# To see build progress
99
function build_wheel {
10-
build_bdist_wheel $@
10+
if [ -n "$IS_OSX" ]; then
11+
source travis_osx_build.sh
12+
build_bdist_osx_wheel $@ || return $?
13+
else
14+
build_bdist_wheel $@
15+
fi
1116
}
1217

1318
function bdist_wheel_cmd {
1419
# copied from multibuild's common_utils.sh
1520
# add osx deployment target so it doesnt default to 10.6
1621
local abs_wheelhouse=$1
17-
if [ -n "$IS_MACOS" ]; then
18-
source travis_osx_build.sh
19-
build_bdist_osx_wheel $@
20-
else
21-
CI_BUILD=1 pip wheel --verbose --wheel-dir="$PWD/dist" . $BDIST_PARAMS
22-
fi
22+
CI_BUILD=1 pip wheel --verbose --wheel-dir="$PWD/dist" . $BDIST_PARAMS
2323
cp dist/*.whl $abs_wheelhouse
2424
if [ -z "$IS_MACOS" ]; then
2525
TOOLS_PATH=/opt/_internal/tools

‎travis_osx_build.sh

Copy file name to clipboardExpand all lines: travis_osx_build.sh
+48-8Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,47 @@ function package_name() {
1010
wheel_name=$name
1111
}
1212

13+
# Terminate the build but ensure saving the cache
14+
function goto_exit {
15+
local EXIT_CODE=${1:-1}
16+
17+
echo "Exiting build"
18+
19+
# Can't just `exit` because that would terminate the build without saving the cache
20+
# Have to replace further actions with no-ops
21+
22+
local MESSAGE=""; if [ "$EXIT_CODE" -ne 0 ]; then
23+
MESSAGE='Building package took too long. Restart the build in Travis UI to continue from cache.'
24+
fi
25+
26+
set +e
27+
28+
eval '
29+
function install_run {'\
30+
"$(if [ -n "$MESSAGE" ]; then
31+
echo ' echo -e "\n'"$MESSAGE"'\n"'
32+
fi)"\
33+
'
34+
# Travis runs user scripts via `eval` i.e. in the same shell process.
35+
# So have to unset errexit in order to get to cache save stage
36+
set +e
37+
return '"$EXIT_CODE"'
38+
}'
39+
}
40+
1341
function pre_build_osx {
1442
local repo_dir=$(abspath ${1:-$REPO_DIR})
1543
local build_dir="$repo_dir/opencv/build"
1644
local num_cpus=$(sysctl -n hw.ncpu)
1745
num_cpus=${num_cpus:-4}
46+
local travis_start_time=$(($TRAVIS_TIMER_START_TIME/10**9))
47+
local time_limit=$((45*60))
1848

1949
cd "$repo_dir"
2050
git submodule sync
2151
git submodule update --init --recursive opencv
2252
git submodule update --init --recursive opencv_contrib
2353

24-
pip install scikit-build
25-
pip install numpy
26-
2754
if [ ! -d "$build_dir" ]; then
2855
mkdir "$build_dir"
2956
fi
@@ -127,13 +154,22 @@ function pre_build_osx {
127154
)
128155
for m in "${CV_MODULES[@]}"; do
129156
if make help | grep -w "$m"; then
157+
# Check time limit (3min should be enough for a module to built)
158+
local projected_time=$(($(date +%s) - travis_start_time + 3 * 60))
159+
if [ $projected_time -ge $time_limit ]; then
160+
if [ -n "$USE_CCACHE" ]; then ccache -s; fi
161+
goto_exit
162+
return 1
163+
fi
130164
make -j${num_cpus} "$m"
165+
local elapsed_time=$(($(date +%s) - travis_start_time))
166+
echo "Elapsed time: "$((elapsed_time/60))"m (${elapsed_time}s)"
131167
fi
132168
done
133169
make -j${num_cpus}
134170

135171
# Print ccache stats
136-
ccache -s
172+
if [ -n "$USE_CCACHE" ]; then ccache -s; fi
137173
}
138174

139175
function build_osx {
@@ -170,9 +206,13 @@ function build_osx {
170206
function build_bdist_osx_wheel {
171207
local repo_dir=$(abspath ${1:-$REPO_DIR})
172208
[ -z "$repo_dir" ] && echo "repo_dir not defined" && exit 1
173-
pre_build_osx "$repo_dir"
174-
if [ -n "$BUILD_DEPENDS" ]; then
175-
pip install $(pip_opts) $BUILD_DEPENDS
176-
fi
209+
local wheelhouse=$(abspath ${WHEEL_SDIR:-wheelhouse})
210+
start_spinner
211+
if [ -n "$(is_function "pre_build")" ]; then pre_build; fi
212+
stop_spinner
213+
pip install scikit-build
214+
pip install numpy
215+
pre_build_osx "$repo_dir" || return $?
177216
build_osx "$repo_dir"
217+
repair_wheelhouse "$wheelhouse"
178218
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.