Commit aa7fcf46 authored by Christoph Groth's avatar Christoph Groth
Browse files

setup.py: make warning and error messages easier to recognize

parent 91a16c18
......@@ -69,18 +69,21 @@ else:
distr_root = os.path.dirname(os.path.abspath(__file__))
def header(title=''):
return title.center(79, '*')
def banner(title=''):
starred = title.center(79, '*')
return '\n' + starred if title else starred
error_msg = """{sep}
error_msg = """{header}
The compilation of Kwant has failed. Please examine the error message
above and consult the installation instructions in README.rst.
You might have to customize {{file}}.
{sep}
Build configuration was:
{{summary}}
{sep}"""
error_msg = error_msg.format(sep=header())
{sep}
"""
error_msg = error_msg.format(header=banner(' Error '), sep=banner())
class kwant_build_ext(build_ext):
def run(self):
......@@ -98,8 +101,9 @@ class kwant_build_ext(build_ext):
print(error_msg.format(file=CONFIG_FILE, summary=build_summary),
file=sys.stderr)
raise
print(header(' Build summary '))
print(banner(' Build summary '))
print(build_summary)
print(banner())
class build_tut(Command):
......@@ -151,7 +155,7 @@ class test(Command):
self.run_command('build')
major, minor = sys.version_info[:2]
lib_dir = "build/lib.{0}-{1}.{2}".format(get_platform(), major, minor)
print(header(' Tests '))
print()
if not run(argv=[__file__, '-v', lib_dir]):
raise DistutilsError('at least one of the tests failed')
......@@ -188,7 +192,7 @@ class kwant_sdist(distutils_sdist):
with open(distr_root + '/MANIFEST', 'r') as f:
line = f.read()
except IOError:
print("error: MANIFEST file is missing and Git is not"
print("Error: MANIFEST file is missing and Git is not"
" available to regenerate it.", file=sys.stderr)
exit(1)
trustworthy = not line.strip().startswith('#')
......@@ -209,15 +213,17 @@ class kwant_sdist(distutils_sdist):
distutils_sdist.run(self)
if names is None:
print(header(' Warning '),
print(banner(' Warning '),
"""Git was not available for re-generating the MANIFEST file (the list of file
names to be included in the source distribution). The old MANIFEST was used.""",
banner(),
sep='\n', file=sys.stderr)
if not trustworthy:
print(header(' Warning '),
print(banner(' Warning '),
"""The existing MANIFEST file seems to have been generated by distutils (it begins
with a comment). It may well be incomplete.""",
banner(),
sep='\n', file=sys.stderr)
# Other than the "if not use_git" clause in the beginning, this is an exact copy
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment