3 This script looks for ImportModules calls in C extensions
6 The current version has harcoded the location of the source
7 tries on Ronald's machine, a future version will be able
8 to rebuild the modulegraph source file that contains
17 import_re
= re
.compile('PyImport_ImportModule\w+\("(\w+)"\);')
19 def extract_implies(root
):
20 modules_dir
= os
.path
.join(root
, "Modules")
21 for fn
in os
.listdir(modules_dir
):
22 if not fn
.endswith('.c'):
26 if module_name
.endswith('module'):
27 module_name
= module_name
[:-6]
29 with
open(os
.path
.join(modules_dir
, fn
)) as fp
:
32 imports
= list(sorted(set(import_re
.findall(data
))))
34 yield module_name
, imports
39 for version
in ('2.6', '2.7', '3.1'):
41 pprint
.pprint(list(extract_implies('/Users/ronald/Projects/python/release%s-maint'%(version
.replace('.', '')))))
43 if __name__
== "__main__":