From b0900657877d29294860183657fb44b08b280205 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Fri, 3 Jul 2009 23:49:16 +0200 Subject: [PATCH] only regenerate Cython's own C sources when the .py files were updated --- setup.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 5860edc2..fe69cdb2 100644 --- a/setup.py +++ b/setup.py @@ -60,6 +60,7 @@ except ValueError: except StandardError: print("Compilation of '%s' failed" % ext.sources[0]) from Cython.Compiler.Main import compile + from Cython import Utils source_root = os.path.dirname(__file__) compiled_modules = ["Cython.Plex.Scanners", "Cython.Compiler.Scanning", @@ -70,14 +71,19 @@ except ValueError: for module in compiled_modules: source_file = os.path.join(source_root, *module.split('.')) if os.path.exists(source_file + ".py"): - source_file = source_file + ".py" + pyx_source_file = source_file + ".py" else: - source_file = source_file + ".pyx" - print("Compiling module %s ..." % module) - result = compile(source_file) - if result.c_file: + pyx_source_file = source_file + ".pyx" + c_source_file = source_file + ".c" + if not os.path.exists(c_source_file) or \ + Utils.file_newer_than(pyx_source_file, + Utils.modification_time(c_source_file)): + print("Compiling module %s ..." % module) + result = compile(pyx_source_file) + c_source_file = result.c_file + if c_source_file: extensions.append( - Extension(module, sources = [result.c_file]) + Extension(module, sources = [c_source_file]) ) else: print("Compilation failed") -- 2.26.2