Commits

rkruppe committed 5a7bb3d

Further mkenv.py improvements

  • Participants
  • Parent commits a8c0c23

Comments (0)

Files changed (1)

 import sysconfig
 import os
 import re
-from subprocess import call
+from subprocess import Popen, STDOUT
 from os.path import join, abspath
 from urllib.request import urlopen
 from tempfile import NamedTemporaryFile
 
 
 def step(msg, func, *args, **kwds):
-    print("[ttgx]", msg)
+    print(msg)
     func(*args, **kwds)
 
 
-def invoke(msg, *cmd_parts, **kwds):
-    print("[ttgx]", msg)
-    try:
-        ret = call(cmd_parts, **kwds)
-    except Exception as e:
-        ret = e
-    if ret:
-        pretty_parts = [
-            part if re.search(r'^[a-zA-Z./\\-]+$', part)
-            else repr(part)
-            for part in cmd_parts
-        ]
-        print("[ERROR]", ' '.join(pretty_parts), '=>', ret)
+def invoke(msg, *cmd_parts):
+    print(msg)
+    with open('mkenv.log', 'a') as log:
+        proc = Popen(cmd_parts, stdout=log, stderr=STDOUT)
+        e = proc.wait()
+    if e:
+        print("Error occurred, see ttgx-mkenv.log for details")
 
 
 def download(url, f):
     invoke("Installing required python libraries",
            pip, 'install', '-U',
            '-r', join(engine_root, 'requirements.txt'))
-    invoke("Sanity check: Trying to load game code",
-           python, '-c', 'import ttgx; print("[ttgx] import succeeded")',
-           env={'PYTHONPATH': engine_root})
+    #XXX I suspect that supplying env is responsible for some of the weirdness
+    # we see on Windows, see note in Popen() docs.
+    #invoke("Sanity check: Trying to load game code",
+    #       python, '-c', 'import ttgx; print("[ttgx] import succeeded")',
+    #       env={'PYTHONPATH': engine_root})
     invoke("Sanity check: Running unit tests",
            join(ctx.bin_path, 'py.test'), '-q', engine_root)
     invoke("Building default gameset assets",
            python, join(env_dir, 'gamesets', 'default', 'make.py'), 'build')
-    print("[ttgx]", "Tutagx environment set up in", env_dir)
+    print("Tutagx environment set up in", env_dir)
 
 
-def main(argv):
+def main(dest):
     builder = venv.EnvBuilder()
     builder.post_setup = after_install
-    builder.create(argv[1])
+    builder.create(dest)
 
 if __name__ == '__main__':
-    main(sys.argv)
+    main(sys.argv[1])