MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / doCythonCompile

Function doCythonCompile

src/pyOpenMS/create_cpp_extension.py:37–67  ·  view source on GitHub ↗

Perform the Cython compilation step for each module

(arg)

Source from the content-addressed store, hash-verified

35 return autowrap_include_dirs
36
37def doCythonCompile(arg):
38 """
39 Perform the Cython compilation step for each module
40 """
41
42 modname, autowrap_include_dirs = arg
43 m_filename = "pyopenms/%s.pyx" % modname
44 print ("Cython compile", m_filename)
45 # By omitting "compiler_directives": {"language_level": 3} as extra_opt, autowrap will choose the language_level of the used python executable
46 autowrap.Main.run_cython(inc_dirs=autowrap_include_dirs, extra_opts={}, out=m_filename, warn_level=2)
47
48 if False:
49 #
50 # Fix two bugs in the cpp code generated by Cython to allow error-free
51 # compilation (see OpenMS issues on github #527 and #745).
52 #
53 import re
54 f = open(m_filename)
55 fout = open(m_filename + "tmp", "w")
56 expr_fix = re.compile(r"(.*).std::vector<(.*)>::iterator::~iterator\(\)")
57 for line in f:
58 # Fix for Issue #527
59 res = expr_fix.sub('typedef std::vector<\\2>::iterator _it;\n\\1.~_it()', line)
60 # Fix for Issue #745
61 res = res.replace("__Pyx_PyUnicode_FromString(char", "__Pyx_PyUnicode_FromString(const char")
62 fout.write(res)
63
64 fout.close()
65 f.close()
66 shutil.copy(m_filename + "tmp", m_filename)
67 os.remove(m_filename + "tmp")
68
69if __name__ == '__main__':
70

Callers

nothing calls this directly

Calls 5

replaceMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45
copyMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected