|
3 | 3 | import os
|
4 | 4 | import sys
|
5 | 5 | import re
|
6 |
| -import shutil |
7 | 6 | import platform
|
8 | 7 | import sysconfig
|
9 | 8 | from distutils import ccompiler
|
@@ -78,12 +77,20 @@ def generate_extensions(fftwlibs):
|
78 | 77 | if d == 'double':
|
79 | 78 | continue
|
80 | 79 | p = 'fftw'+prec_map[d]+'_'
|
81 |
| - for fl in ('fftw_planxfftn.h', 'fftw_planxfftn.c', 'fftw_xfftn.pyx', 'fftw_xfftn.pxd'): |
82 |
| - fp = fl.replace('fftw_', p) |
83 |
| - shutil.copy(os.path.join(fftwdir, fl), os.path.join(fftwdir, fp)) |
84 |
| - sedcmd = "sed -i ''" if sys.platform == 'darwin' else "sed -i''" |
85 |
| - os.system(sedcmd + " 's/fftw_/{0}/g' {1}".format(p, os.path.join(fftwdir, fp))) |
86 |
| - os.system(sedcmd + " 's/double/{0}/g' {1}".format(d, os.path.join(fftwdir, fp))) |
| 80 | + for fname in ( |
| 81 | + 'fftw_planxfftn.h', |
| 82 | + 'fftw_planxfftn.c', |
| 83 | + 'fftw_xfftn.pyx', |
| 84 | + 'fftw_xfftn.pxd', |
| 85 | + ): |
| 86 | + src = os.path.join(fftwdir, fname) |
| 87 | + dst = os.path.join(fftwdir, fname.replace('fftw_', p)) |
| 88 | + with open(src, 'r') as fin: |
| 89 | + code = fin.read() |
| 90 | + code = re.sub('fftw_', p, code) |
| 91 | + code = re.sub('double', d, code) |
| 92 | + with open(dst, 'w') as fout: |
| 93 | + fout.write(code) |
87 | 94 |
|
88 | 95 | def get_extensions(fftwlibs):
|
89 | 96 | """Return list of extension modules"""
|
|
0 commit comments