From 37974186e82dfe1adee4fed679313aaa6d927fdf Mon Sep 17 00:00:00 2001 From: Leonard Lausen Date: Thu, 12 Dec 2019 06:38:43 +0000 Subject: [PATCH] Update CMake on CI --- ci/build_windows.py | 5 +++++ ci/docker/install/ubuntu_arm.sh | 9 +++++++++ ci/docker/install/ubuntu_core.sh | 2 +- ci/util.py | 33 +++++++++++++++++++++++++++++++- 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/ci/build_windows.py b/ci/build_windows.py index 526abc9c8cd4..53d435cebee9 100755 --- a/ci/build_windows.py +++ b/ci/build_windows.py @@ -28,6 +28,7 @@ import platform import shutil import sys +import tempfile import time from distutils.dir_util import copy_tree from enum import Enum @@ -143,6 +144,10 @@ def windows_build(args): mxnet_root = get_mxnet_root() logging.info("Found MXNet root: {}".format(mxnet_root)) + with tempfile.TemporaryDirectory() as tmpdir: + cmake_file_path = download_file('https://cmake.org/files/v3.15/cmake-3.15.5-win64-x64.msi', tmpdir) + run_command("msiexec /i {} /quiet /norestart ADD_CMAKE_TO_PATH=System".format(cmake_file_path)) + with remember_cwd(): os.chdir(path) cmd = "\"{}\" && cmake -G \"NMake Makefiles JOM\" {} {}".format(args.vcvars, diff --git a/ci/docker/install/ubuntu_arm.sh b/ci/docker/install/ubuntu_arm.sh index 1e4f371fbe6f..534ffff625a4 100755 --- a/ci/docker/install/ubuntu_arm.sh +++ b/ci/docker/install/ubuntu_arm.sh @@ -22,3 +22,12 @@ set -ex apt update || true apt install -y \ unzip + +# CMake 3.13.2+ is required +mkdir /opt/cmake && cd /opt/cmake +wget -nv https://cmake.org/files/v3.13/cmake-3.13.5-Linux-x86_64.sh +sh cmake-3.13.5-Linux-x86_64.sh --prefix=/opt/cmake --skip-license +rm /usr/local/bin/cmake # dockcross comes with cmake at /usr/local/bin/cmake +ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake +rm cmake-3.13.5-Linux-x86_64.sh +cmake --version diff --git a/ci/docker/install/ubuntu_core.sh b/ci/docker/install/ubuntu_core.sh index e7ae7e0859d7..70bc285d163b 100755 --- a/ci/docker/install/ubuntu_core.sh +++ b/ci/docker/install/ubuntu_core.sh @@ -57,7 +57,7 @@ apt-get install -y \ ln -s /usr/lib/x86_64-linux-gnu/libturbojpeg.so.0.1.0 /usr/lib/x86_64-linux-gnu/libturbojpeg.so -# CMake 3.13.3+ is required for Cuda builds +# CMake 3.13.2+ is required mkdir /opt/cmake && cd /opt/cmake wget -nv https://cmake.org/files/v3.13/cmake-3.13.5-Linux-x86_64.sh sh cmake-3.13.5-Linux-x86_64.sh --prefix=/opt/cmake --skip-license diff --git a/ci/util.py b/ci/util.py index 4b3a399184f9..cd5665d04df8 100644 --- a/ci/util.py +++ b/ci/util.py @@ -15,12 +15,15 @@ # specific language governing permissions and limitations # under the License. -import os import contextlib import logging import logging.config +import os +import subprocess import sys +import requests + def get_mxnet_root() -> str: curpath = os.path.abspath(os.path.dirname(__file__)) @@ -130,3 +133,31 @@ def config_logging(): # or sensitive information logging.getLogger("botocore").setLevel(logging.WARNING) logging.getLogger("requests").setLevel(logging.WARNING) + + +# Takes url and downloads it to the dest_path directory on Windows. +def download_file(url, dest_path): + file_name = url.split('/')[-1] + full_path = "{}\\{}".format(dest_path, file_name) + logging.info("Downloading: {}".format(full_path)) + r = requests.get(url, stream=True) + if r.status_code == 404: + return r.status_code + elif r.status_code != 200: + logging.error("{} returned status code {}".format(url, r.status_code)) + with open(full_path, 'wb') as f: + for chunk in r.iter_content(chunk_size=1024): + if chunk: # filter out keep-alive new chunks + f.write(chunk) + return full_path + + +# Takes arguments and runs command on host. Shell is disabled by default. +def run_command(args, shell=False): + try: + logging.info("Issuing command: {}".format(args)) + res = subprocess.check_output(args, shell=shell, timeout=1800).decode("utf-8").replace("\r\n", "") + logging.info("Output: {}".format(res)) + except subprocess.CalledProcessError as e: + raise RuntimeError("command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output)) + return res