You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2017/12/12 23:50:51 UTC

[GitHub] larroy commented on a change in pull request #9035: [WIP] Build improvements, for users and for Jenkins

larroy commented on a change in pull request #9035: [WIP] Build improvements, for users and for Jenkins
URL: https://github.com/apache/incubator-mxnet/pull/9035#discussion_r156529917
 
 

 ##########
 File path: build.py
 ##########
 @@ -0,0 +1,167 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""User friendly / multi platform builder script"""
+
+import contextlib
+import subprocess
+import logging
+import os
+import tempfile
+import sys
+from distutils import spawn
+import logging
+from subprocess import check_call
+import platform
+import argparse
+
+@contextlib.contextmanager
+def remember_cwd():
+    '''
+    Restore current directory when exiting context
+    '''
+    curdir = os.getcwd()
+    try: yield
+    finally: os.chdir(curdir)
+
+
+class CmdResult(object):
+    def __init__(self, cmd, std_out, std_err, status_code):
+        self.std_out = std_out
+        self.std_err = std_err
+        self.status_code = status_code if status_code is not None else 0
+        self.cmd = cmd
+
+    def __str__(self):
+        return "Command: \"{}\" status: {}\nstdout:\n{}\nstderr:\n{}".format(
+            self.cmd, self.status_code,
+            self.std_out[:50], self.std_err[:20])
+
+
+def run(cmd, fail_on_error=True):
+    logging.debug("executing shell command:\n" + cmd)
+    proc = subprocess.Popen(
+        cmd,
+        shell=True,
+        stdout=subprocess.PIPE,
+        stderr=subprocess.PIPE,
+    )
+    std_out, std_err = proc.communicate()
+    if fail_on_error:
+        if proc.returncode != 0:
+            logging.warn('Error running command: {}'.format(cmd))
+        assert proc.returncode == 0, std_err
+    res = CmdResult(cmd, std_out.decode('utf-8'), std_err.decode('utf-8'), proc.returncode)
+    return res
+
+def xmkdir(d):
+    rev_path_list = list()
+    head = d
+    while len(head) and head != os.sep:
+        rev_path_list.append(head)
+        (head, tail) = os.path.split(head)
+
+    rev_path_list.reverse()
+    for p in rev_path_list:
+        try:
+            os.mkdir(p)
+        except OSError as e:
+            if e.errno != 17:
+                raise
+
+
+
+def windows_build(args):
+    BUILD_BAT=r'''call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\vcvarsx86_amd64.bat"
 
 Review comment:
   the point is to grow it so you can just call build.py on any platform, right now building is a mess.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services