#!/usr/bin/env python from distutils.core import setup from Cython.Build import cythonize import os import re files = [{% for f in code.requestedFiles %}"{{f.filename}}", {% endfor %}] for f in files: cpp_file = f + '.cpp' cplus_file = f + '.c++' cpp_mod = os.path.getmtime(cpp_file) cplus_mod = 0 try: cplus_mod = os.path.getmtime(cplus_file) except: pass if not os.path.exists(cpp_file) or cpp_mod < cplus_mod: if not os.path.exists(cplus_file): raise RuntimeError("You need to run `capnp compile -oc++` in addition to `-ocython` first.") os.rename(cplus_file, cpp_file) with open(f + '.h', "r") as file: lines = file.readlines() with open(f + '.h', "w") as file: for line in lines: file.write(re.sub(r'Builder\(\)\s*=\s*delete;', 'Builder() = default;', line)) setup( name="{{code.requestedFiles[0] | replace('.', '_')}}", ext_modules=cythonize('*_capnp_cython.pyx', language="c++") )