Perform the Cython compilation step for each module
(arg)
| 35 | return autowrap_include_dirs |
| 36 | |
| 37 | def 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 | |
| 69 | if __name__ == '__main__': |
| 70 |