39 lines
1.0 KiB
Python
39 lines
1.0 KiB
Python
#!/usr/bin/env python
|
|
from distutils.core import setup
|
|
from Cython.Build import cythonize
|
|
from shutil import copyfile
|
|
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 = 0
|
|
try:
|
|
cpp_mod = os.path.getmtime(cpp_file)
|
|
except:
|
|
pass
|
|
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.")
|
|
copyfile(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++")
|
|
)
|