# HG changeset patch # User Jeff Hammel # Date 1395694464 25200 # Node ID 9cb40c01c10aa0ee212b729b14b51350f90929d8 # Parent fbfc02ea7d8eb787c78b78590396c0fc2138e178 illustrate downloading a package and rerunning via exec diff -r fbfc02ea7d8e -r 9cb40c01c10a python/example/install_and_exec.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/python/example/install_and_exec.py Mon Mar 24 13:54:24 2014 -0700 @@ -0,0 +1,21 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +illustrates installation and execution following installation +""" + +import os +import subprocess +import sys + +here = os.path.dirname(os.path.realpath(__file__)) + +try: + import gnupg + print ("gnupg installed") +except ImportError: + print ("gnupg not installed") + subprocess.check_call(['pip', 'install', 'gnupg']) + args = [sys.executable] + sys.argv + os.execl(sys.executable, *args)