annotate examples/hotinstall.py @ 250:3840a2c5bc4f

go tox
author Jeff Hammel <k0scist@gmail.com>
date Fri, 31 Mar 2017 18:12:09 -0700
parents 388b4bb3516c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
204
388b4bb3516c add hot install template
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
1 # python requirements
388b4bb3516c add hot install template
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
2 # (key, value) = (module, PyPI name)
388b4bb3516c add hot install template
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
3 requirements = [('boto', 'boto'),
388b4bb3516c add hot install template
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
4 ('tempita', 'tempita')]
388b4bb3516c add hot install template
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
5 for module, package in requirements:
388b4bb3516c add hot install template
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
6 try:
388b4bb3516c add hot install template
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
7 globals()[module] = __import__(module)
388b4bb3516c add hot install template
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
8 except ImportError:
388b4bb3516c add hot install template
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
9 # install requirement and try again
388b4bb3516c add hot install template
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
10 import subprocess
388b4bb3516c add hot install template
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
11 subprocess.check_call(['pip', 'install', package])
388b4bb3516c add hot install template
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
12 args = [sys.executable] + sys.argv
388b4bb3516c add hot install template
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
13 os.execl(sys.executable, *args)