Skip to content
Snippets Groups Projects
Commit aa7fcf46 authored by Christoph Groth's avatar Christoph Groth
Browse files

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

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