Mercurial > hg > config
annotate python/install.py @ 434:d4f6995812c1
more sensible defaults
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Thu, 08 Aug 2013 09:49:54 -0700 |
parents | e4746a046446 |
children |
rev | line source |
---|---|
123
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
1 def install_hg(sources): |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
2 """ |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
3 - sources : dict of hg sources to install: {'package': 'http://hg...'} |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
4 """ |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
5 try: |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
6 from subprocess import check_call as call |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
7 except: |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
8 from subprocess import call |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
9 |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
10 # see if you can find site-packages |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
11 import site |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
12 site_dir = os.path.abspath(os.path.dirname(site.__file__)) |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
13 site_packages = os.path.join(site_dir, 'site-packages') |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
14 if not (os.path.exists(site_packages) and os.path.isdir(site_packages)): |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
15 raise IOError("Cannot find site-packages directory") |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
16 |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
17 # figure out what you need to install |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
18 missing = set() |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
19 for source in sources: |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
20 try: |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
21 __import__(source) |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
22 except ImportError: |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
23 missing.add(source) |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
24 |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
25 # install it |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
26 for source in missing: |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
27 call(['hg', 'clone', sources[source], |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
28 os.path.join(site_packages, source)]) |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
29 |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
30 ### install unpackaged dependencies |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
31 if set(['install', 'develop']).intersection(sys.argv[1:]): |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
32 try: |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
33 install_hg(source) |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
34 except: |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
35 print 'Please make sure the source is installed:' |
e4746a046446
adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
36 print source |