Files
pycapnp/capnp/templates/setup.py.tmpl
Jason Paryani 64e80e06bf Get code generator plugin to a decently working state.
Still a few outstanding performance issues, and imports inside .capnp
files may not be working
2014-10-19 20:06:00 -07:00

34 lines
973 B
Python

#!/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++")
)