diff options
author | Melody Horn <melody@boringcactus.com> | 2021-02-27 17:14:38 -0700 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2021-02-27 17:14:38 -0700 |
commit | 1cf5e68c25c0505194f23d4018e29767d3b519dd (patch) | |
tree | 63ec483c12e57ccbdea5e94ab82448cbff7b8753 /ctec/__init__.py | |
parent | bcb2b78eed508834192557e93f158f171f51f02d (diff) | |
download | ctec-1cf5e68c25c0505194f23d4018e29767d3b519dd.tar.gz ctec-1cf5e68c25c0505194f23d4018e29767d3b519dd.zip |
fetch inboxes
Diffstat (limited to 'ctec/__init__.py')
-rw-r--r-- | ctec/__init__.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/ctec/__init__.py b/ctec/__init__.py index 9f109cb..4b91645 100644 --- a/ctec/__init__.py +++ b/ctec/__init__.py @@ -1 +1,18 @@ +import importlib +import subprocess +import sys + VERSION = (1,0,0) + +def import_or_install(name, pypi_name=None): + if pypi_name is None: + pypi_name = name + try: + return importlib.import_module(name) + except ImportError: + try: + subprocess.check_call([sys.executable, '-m', 'pip', 'install', '--upgrade', pypi_name]) + except subprocess.CalledProcessError: + subprocess.check_call([sys.executable, '-m', 'ensurepip']) + subprocess.check_call([sys.executable, '-m', 'pip', 'install', '--upgrade', pypi_name]) + return importlib.import_module(name) |