@@ -35,6 +35,7 @@ operates on the Cython .pyx files.
35
35
"""
36
36
37
37
import os
38
+ from os .path import join as pjoin , abspath
38
39
import sys
39
40
import hashlib
40
41
import pickle
@@ -51,6 +52,8 @@ HAVE_CYTHON_0p14 = LooseVersion(cython_version) >= LooseVersion('0.14')
51
52
52
53
HASH_FILE = 'cythonize.dat'
53
54
DEFAULT_ROOT = 'nipy'
55
+ EXTRA_FLAGS = '-I {}' .format (
56
+ abspath (pjoin ('lib' , 'fff_python_wrapper' )))
54
57
55
58
#
56
59
# Rules
@@ -60,12 +63,13 @@ def process_pyx(fromfile, tofile):
60
63
opt_str = '--fast-fail'
61
64
else :
62
65
opt_str = ''
63
- if os .system ('cython %s -o "%s" "%s"' % (opt_str , tofile , fromfile )) != 0 :
66
+ if os .system ('cython %s %s -o "%s" "%s"' % (
67
+ opt_str , EXTRA_FLAGS , tofile , fromfile )) != 0 :
64
68
raise Exception ('Cython failed' )
65
69
66
70
def process_tempita_pyx (fromfile , tofile ):
67
71
import tempita
68
- with open (fromfile ) as f :
72
+ with open (fromfile , 'rt' ) as f :
69
73
tmpl = f .read ()
70
74
pyxcontent = tempita .sub (tmpl )
71
75
assert fromfile .endswith ('.pyx.in' )
@@ -85,21 +89,22 @@ rules = {
85
89
def load_hashes (filename ):
86
90
# Return { filename : (sha1 of input, sha1 of output) }
87
91
if os .path .isfile (filename ):
88
- with open (filename ) as f :
92
+ with open (filename , 'rb' ) as f :
89
93
hashes = pickle .load (f )
90
94
else :
91
95
hashes = {}
92
96
return hashes
93
97
94
98
def save_hashes (hash_db , filename ):
95
- with open (filename , 'w ' ) as f :
99
+ with open (filename , 'wb ' ) as f :
96
100
pickle .dump (hash_db , f )
97
101
102
+
98
103
def sha1_of_file (filename ):
99
104
h = hashlib .sha1 ()
100
- with open (filename ) as f :
105
+ with open (filename , 'rb' ) as f :
101
106
h .update (f .read ())
102
- return h .hexdigest ()
107
+ return h .hexdigest ()
103
108
104
109
#
105
110
# interface with git
@@ -189,6 +194,7 @@ def find_process_files(root_dir):
189
194
process (cur_dir , fromfile , tofile , function , hash_db )
190
195
save_hashes (hash_db , HASH_FILE )
191
196
197
+
192
198
def main ():
193
199
try :
194
200
root_dir = sys .argv [1 ]
0 commit comments