| 1 | #!/usr/bin/env python
 | 
| 2 | from __future__ import print_function
 | 
| 3 | """
 | 
| 4 | c_module_srcs.py
 | 
| 5 | """
 | 
| 6 | 
 | 
| 7 | import sys
 | 
| 8 | 
 | 
| 9 | 
 | 
| 10 | def main(argv):
 | 
| 11 |   manifest_path = argv[1]
 | 
| 12 |   discovered = argv[2]
 | 
| 13 | 
 | 
| 14 |   manifest = {}
 | 
| 15 |   with open(manifest_path) as f:
 | 
| 16 |     for line in f:
 | 
| 17 |       line = line.strip()
 | 
| 18 |       mod_name, rel_path = line.split(None, 2)
 | 
| 19 |       manifest[mod_name] = rel_path
 | 
| 20 | 
 | 
| 21 |   #print manifest
 | 
| 22 |   with open(discovered) as f:
 | 
| 23 |     for line in f:
 | 
| 24 |       line = line.strip()
 | 
| 25 |       mod_name, _ = line.split(None, 2)
 | 
| 26 | 
 | 
| 27 |       # Hard-coded special cases for now.
 | 
| 28 | 
 | 
| 29 |       if mod_name in ('libc', 'fastlex'):  # Our own modules
 | 
| 30 |         # Relative to Python-2.7.13 dir
 | 
| 31 |         print('../native/%s.c' % mod_name)
 | 
| 32 | 
 | 
| 33 |       elif mod_name == 'math':
 | 
| 34 |         print('Modules/mathmodule.c')
 | 
| 35 |         print('Modules/_math.c')
 | 
| 36 | 
 | 
| 37 |       elif mod_name == '_io':
 | 
| 38 |         # This data is in setup.py and Modules/Setup.dist.
 | 
| 39 |         #_io -I$(srcdir)/Modules/_io _io/bufferedio.c _io/bytesio.c
 | 
| 40 |         #    _io/fileio.c _io/iobase.c _io/_iomodule.c _io/stringio.c
 | 
| 41 |         #    _io/textio.c
 | 
| 42 |         print('Modules/_io/bufferedio.c')
 | 
| 43 |         print('Modules/_io/bytesio.c')
 | 
| 44 |         print('Modules/_io/fileio.c')
 | 
| 45 |         print('Modules/_io/iobase.c')
 | 
| 46 |         print('Modules/_io/_iomodule.c')
 | 
| 47 |         print('Modules/_io/stringio.c')
 | 
| 48 |         print('Modules/_io/textio.c')
 | 
| 49 | 
 | 
| 50 |       else:
 | 
| 51 |         print(manifest[mod_name])
 | 
| 52 | 
 | 
| 53 | 
 | 
| 54 | if __name__ == '__main__':
 | 
| 55 |   try:
 | 
| 56 |     main(sys.argv)
 | 
| 57 |   except RuntimeError as e:
 | 
| 58 |     print('FATAL: %s' % e, file=sys.stderr)
 | 
| 59 |     sys.exit(1)
 |