summaryrefslogtreecommitdiff
path: root/tools/toollib.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/toollib.py')
-rw-r--r--tools/toollib.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/tools/toollib.py b/tools/toollib.py
new file mode 100644
index 0000000..fe7f437
--- /dev/null
+++ b/tools/toollib.py
@@ -0,0 +1,34 @@
+"""Various utilities common to IPython release and maintenance tools.
+"""
+# Library imports
+import os
+import sys
+import compileall
+
+from subprocess import Popen, PIPE, CalledProcessError, check_call
+
+from distutils.dir_util import remove_tree
+
+# Useful shorthands
+pjoin = os.path.join
+cd = os.chdir
+
+# Utility functions
+
+#-----------------------------------------------------------------------------
+# Functions
+#-----------------------------------------------------------------------------
+def sh(cmd):
+ """Execute command in a subshell, return status code."""
+ return check_call(cmd, shell=True)
+
+
+def compile_tree():
+ """Compile all Python files below current directory."""
+ vstr = '.'.join(map(str, sys.version_info[:2]))
+ ca = compileall.__file__
+ stat = os.system('python %s .' % ca)
+ if stat:
+ msg = '*** ERROR: Some Python files in tree do NOT compile! ***\n'
+ msg += 'See messages above for the actual file that produced it.\n'
+ raise SystemExit(msg)