Last active
May 9, 2017 17:30
-
-
Save odra/90ba12ad1e5ff2b55857003a4ba419a5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python | |
import importlib | |
import importlib.util | |
import pip | |
def install(name, version=None): | |
args = [ | |
'install', | |
name | |
] | |
if version: | |
args[1] = '%s==%s' % (args[1], version) | |
pip.main(args) | |
def load(name, version=None, url=None): | |
mod = importlib.util.find_spec(name) | |
if mod: | |
return importlib.import_module(name) | |
if url is None: | |
install(name, version) | |
else: | |
install(url) | |
return importlib.import_module(name) | |
req = load('requests', version='2.14.0') | |
#req = load('requests', url='https://github.com/kennethreitz/requests/archive/master.zip') | |
#req = load('requests', url='git+https://github.com/kennethreitz/requests.git') | |
#req = load('requests', url='git+ssh://[email protected]/kennethreitz/requests.git') | |
print(req) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment