Created
March 2, 2018 06:22
-
-
Save blip2/c4b0c81b91c042f08c90fd83a4f3c0f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import pip | |
import ctypes, sys | |
def is_admin(): | |
try: | |
return ctypes.windll.shell32.IsUserAnAdmin() | |
except: | |
return False | |
os.chdir(os.path.dirname(os.path.realpath(__file__))) | |
def install(package): | |
pip.main(['install', package]) | |
if __name__ == '__main__': | |
if is_admin(): | |
fh = open('requirements.txt') | |
for line in fh: | |
install(line) | |
fh.close() | |
else: | |
ctypes.windll.shell32.ShellExecuteW( | |
None, "runas", sys.executable, | |
os.path.realpath(__file__), None, 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment