Mercurial > hg > config
annotate python/dependencies.py @ 394:ff13c22effdf
doesnt work but lets pretend its worth keeping
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 29 Jul 2013 22:10:56 -0700 |
parents | af52700d1ce0 |
children |
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 |
261 | 3 """ |
4 illustrate overriding ``setuptools.setup`` to read package data | |
5 """ | |
6 | |
258
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
7 import imp |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
8 import os |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
9 import pprint |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
10 import sys |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
11 |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
12 current_module = None |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
13 info = {} |
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 setup(**kwargs): |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
16 assert current_module |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
17 info[current_module] = kwargs |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
18 |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
19 def main(args=sys.argv[1:]): |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
20 |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
21 global current_module |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
22 current_module = None |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
23 |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
24 setuptools = sys.modules.get('setuptools') |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
25 sys.modules['setuptools'] = sys.modules[__name__] |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
26 |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
27 try: |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
28 for setup_py in args: |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
29 current_module = setup_py |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
30 assert os.path.exists(setup_py) |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
31 module = imp.load_source('setup', setup_py) |
262 | 32 finally: |
258
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
33 sys.modules.pop('setuptools') |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
34 if setuptools: |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
35 sys.modules['setuptools'] = setuptoools |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
36 |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
37 pprint.pprint(info) |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
38 |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
39 if __name__ == '__main__': |
2862f4453296
add a hack to override setuptools
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
40 main() |