annotate python/dependencies.py @ 258:2862f4453296

add a hack to override setuptools
author Jeff Hammel <jhammel@mozilla.com>
date Wed, 02 Jan 2013 15:41:11 -0800
parents
children a529f0d3c259
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
258
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 #!/usr/bin/env python
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 import imp
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4 import os
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5 import pprint
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6 import sys
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8 current_module = None
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9 info = {}
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11 def setup(**kwargs):
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
12 assert current_module
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
13 info[current_module] = kwargs
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
14
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
15 def main(args=sys.argv[1:]):
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
16
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
17 global current_module
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
18 current_module = None
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
19
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
20 setuptools = sys.modules.get('setuptools')
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
21 sys.modules['setuptools'] = sys.modules[__name__]
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
22
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
23 try:
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
24 for setup_py in args:
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
25 current_module = setup_py
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
26 assert os.path.exists(setup_py)
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
27 module = imp.load_source('setup', setup_py)
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
28 except:
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
29 sys.modules.pop('setuptools')
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
30 if setuptools:
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
31 sys.modules['setuptools'] = setuptoools
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
32
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
33 pprint.pprint(info)
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
34
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
35 if __name__ == '__main__':
2862f4453296 add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
36 main()