html_filename = os.path.splitext(target_filename)[0] + ".html"
f = codecs.open(html_filename, "w", encoding="UTF-8")
+ f.write(u'<!-- Generated by Cython %s on %s -->\n' % (Version.version, time.asctime()))
f.write(u'<html>\n')
f.write(u"""
<head>
# Cython Top Level
#
-import os, sys, re
+import os, sys, re, codecs
if sys.version_info[:2] < (2, 3):
sys.stderr.write("Sorry, Cython requires Python 2.3 or later\n")
sys.exit(1)
# Set up result object
result = create_default_resultobj(source, options)
+ if options.annotate is None:
+ # By default, decide based on whether an html file already exists.
+ html_filename = os.path.splitext(result.c_file)[0] + ".html"
+ if os.path.exists(html_filename):
+ line = codecs.open(html_filename, "r", encoding="UTF-8").readline()
+ if line.startswith(u'<!-- Generated by Cython'):
+ options.annotate = True
+
# Get pipeline
if source_ext.lower() == '.py':
pipeline = context.create_py_pipeline(options, result)
errors_to_stderr = 1,
cplus = 0,
output_file = None,
- annotate = False,
+ annotate = None,
generate_pxi = 0,
working_path = "",
recursive = 0,