1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
"""Various utilities common to IPython release and maintenance tools.
"""
# Library imports
import os
import sys
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]))
stat = os.system('python %s/lib/python%s/compileall.py .' %
(sys.prefix,vstr))
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)
|