Commit b0900657 authored by Stefan Behnel's avatar Stefan Behnel

only regenerate Cython's own C sources when the .py files were updated

parent b5f5a18d
......@@ -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"
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(source_file)
if result.c_file:
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")
......
Markdown is supported
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