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