Mercurial > hg > MakeItSo
changeset 204:388b4bb3516c
add hot install template
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Tue, 28 Oct 2014 13:47:43 -0700 |
parents | 84be91d59996 |
children | 0a991b8fe839 |
files | examples/hotinstall.py |
diffstat | 1 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/hotinstall.py Tue Oct 28 13:47:43 2014 -0700 @@ -0,0 +1,13 @@ +# python requirements +# (key, value) = (module, PyPI name) +requirements = [('boto', 'boto'), + ('tempita', 'tempita')] +for module, package in requirements: + try: + globals()[module] = __import__(module) + except ImportError: + # install requirement and try again + import subprocess + subprocess.check_call(['pip', 'install', package]) + args = [sys.executable] + sys.argv + os.execl(sys.executable, *args)