File: generate_qhull.py

package info (click to toggle)
python-scipy 0.10.1%2Bdfsg2-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 42,232 kB
  • sloc: cpp: 224,773; ansic: 103,496; python: 85,210; fortran: 79,130; makefile: 272; sh: 43
file content (29 lines) | stat: -rwxr-xr-x 552 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python
import tempfile
import subprocess
import os
import sys
import re
import shutil

tmp_dir = tempfile.mkdtemp()
try:
    # Run Cython
    dst_fn = os.path.join(tmp_dir, 'qhull.c')
    ret = subprocess.call(['cython', '-o', dst_fn, 'qhull.pyx'])
    if ret != 0:
        sys.exit(ret)

    # Strip comments
    f = open(dst_fn, 'r')
    text = f.read()
    f.close()

    r = re.compile(r'/\*(.*?)\*/', re.S)

    text = r.sub('', text)
    f = open('qhull.c', 'w')
    f.write(text)
    f.close()
finally:
    shutil.rmtree(tmp_dir)