Skip to content

Commit

Permalink
setup.py: Build system improvements
Browse files Browse the repository at this point in the history
Friendlier error messages when missing a command or a command fails.
Fix accidental tuple printing
  • Loading branch information
dmcc committed Jul 23, 2015
1 parent ce551c0 commit 031e98d
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,21 @@
# these dependencies.

def run(args):
print("Running %r" % ' '.join(map(str, args)))
subprocess.check_call(args)
cmd = ' '.join(map(str, args))
print("Running %r" % cmd)
message = None
try:
assert subprocess.check_call(args) == 0
except OSError, exc:
if exc.errno == 2:
message = "Command %r not found." % args[0]
else:
message = "OSError: %r" % exc
except AssertionError, exc:
message = "Bad exit code from %r" % cmd
if message:
raise SystemExit("Error while running command: %s\nBuild failed!" % \
message)

parser_base = 'first-stage/PARSE/'
parser_wrapper = 'swig/wrapper.C'
Expand All @@ -35,7 +48,7 @@ def maybe_run_swig(wrapper_filename, module_name, base_directory,
if not newer:
return

print('Generating', module_name, 'SWIG wrapper files')
print('Generating ' + module_name + ' SWIG wrapper files')
run(['swig', '-python', '-c++', '-module',
module_name, '-I' + base_directory,
'-Wall', '-classic', '-outdir', 'python/bllipparser',
Expand Down

0 comments on commit 031e98d

Please sign in to comment.