From 7ee7b487b018a7092c9e15389e6b231e7c0574c4 Mon Sep 17 00:00:00 2001 From: Christoph Groth <christoph.groth@cea.fr> Date: Mon, 2 Sep 2013 17:19:06 +0200 Subject: [PATCH] setup.py: only create empty build.conf when actually building --- setup.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 709ca705..8d3964a6 100755 --- a/setup.py +++ b/setup.py @@ -55,6 +55,14 @@ kwant_dir = os.path.dirname(os.path.abspath(__file__)) class kwant_build_ext(build_ext): def run(self): + if not config_file_present: + # Create an empty config file if none is present so that the + # extensions will not be rebuilt each time. Only depending on the + # config file if it is present would make it impossible to detect a + # necessary rebuild due to a deleted config file. + with open(CONFIG_FILE, 'w') as f: + f.write('# Created by setup.py - feel free to modify.\n') + try: build_ext.run(self) except (DistutilsError, CCompilerError): @@ -283,7 +291,7 @@ def extensions(): Extension. possibly after replacing ".pyx" with ".c" if Cython is not to be used.""" - global build_summary + global build_summary, config_file_present build_summary = [] #### Add components of Kwant without external compile-time dependencies. @@ -313,8 +321,9 @@ def extensions(): with open(CONFIG_FILE) as f: config.readfp(f) except IOError: - with open(CONFIG_FILE, 'w') as f: - f.write('# Created by setup.py - feel free to modify.\n') + config_file_present = False + else: + config_file_present = True kwrds_by_section = {} for section in config.sections(): -- GitLab