# HG changeset patch # User Jeff Hammel # Date 1294946671 28800 # Node ID e4746a04644662666ef4ec5b7c65e481a09e56f8 # Parent a832980288e9c54bc06b36445203ccb962c75e97 adding install script for inclusion in setup.py diff -r a832980288e9 -r e4746a046446 python/install.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/python/install.py Thu Jan 13 11:24:31 2011 -0800 @@ -0,0 +1,36 @@ +def install_hg(sources): + """ + - sources : dict of hg sources to install: {'package': 'http://hg...'} + """ + try: + from subprocess import check_call as call + except: + from subprocess import call + + # see if you can find site-packages + import site + site_dir = os.path.abspath(os.path.dirname(site.__file__)) + site_packages = os.path.join(site_dir, 'site-packages') + if not (os.path.exists(site_packages) and os.path.isdir(site_packages)): + raise IOError("Cannot find site-packages directory") + + # figure out what you need to install + missing = set() + for source in sources: + try: + __import__(source) + except ImportError: + missing.add(source) + + # install it + for source in missing: + call(['hg', 'clone', sources[source], + os.path.join(site_packages, source)]) + +### install unpackaged dependencies +if set(['install', 'develop']).intersection(sys.argv[1:]): + try: + install_hg(source) + except: + print 'Please make sure the source is installed:' + print source