-
Notifications
You must be signed in to change notification settings - Fork 532
/
Copy pathtoollib.py
38 lines (27 loc) · 1.04 KB
/
toollib.py
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
34
35
36
37
38
# -*- coding: utf-8 -*-
"""Various utilities common to IPython release and maintenance tools.
"""
from builtins import map
# 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("%s %s/lib/python%s/compileall.py ." % (sys.executable, 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)