MCPcopy Create free account
hub / github.com/numpy/numpy / find_process_files

Function find_process_files

tools/cythonize.py:167–194  ·  view source on GitHub ↗
(root_dir)

Source from the content-addressed store, hash-verified

165
166
167def find_process_files(root_dir):
168 hash_db = load_hashes(HASH_FILE)
169 files = [x for x in os.listdir(root_dir) if not os.path.isdir(x)]
170 # .pxi or .pxi.in files are most likely dependencies for
171 # .pyx files, so we need to process them first
172 files.sort(key=lambda name: (name.endswith('.pxi') or
173 name.endswith('.pxi.in') or
174 name.endswith('.pxd.in')),
175 reverse=True)
176
177 for filename in files:
178 in_file = os.path.join(root_dir, filename + ".in")
179 for fromext, value in rules.items():
180 if filename.endswith(fromext):
181 if not value:
182 break
183 function, toext = value
184 if toext == '.c':
185 with open(os.path.join(root_dir, filename), 'rb') as f:
186 data = f.read()
187 m = re.search(br"^\s*#\s*distutils:\s*language\s*=\s*c\+\+\s*$", data, re.I|re.M)
188 if m:
189 toext = ".cxx"
190 fromfile = filename
191 tofile = filename[:-len(fromext)] + toext
192 process(root_dir, fromfile, tofile, function, hash_db)
193 save_hashes(hash_db, HASH_FILE)
194 break
195
196def main():
197 try:

Callers 1

mainFunction · 0.85

Calls 9

load_hashesFunction · 0.85
openFunction · 0.85
processFunction · 0.85
save_hashesFunction · 0.85
listdirMethod · 0.80
sortMethod · 0.80
endswithMethod · 0.80
joinMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected