Mercurial > hg > config
annotate python/dependencies.py @ 924:fc88a12acf48 default tip
add lfs filter
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Wed, 04 Dec 2024 15:50:53 -0800 |
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() |