diff --git a/check50.py b/check50.py index 19397fca..0ba79cd0 100755 --- a/check50.py +++ b/check50.py @@ -14,6 +14,7 @@ import requests import shutil import signal +import site import subprocess import sys import tempfile @@ -41,6 +42,12 @@ except ImportError: from pipes import quote + +try: + from importlib import reload +except (ImportError, AttributeError): + from imp import reload + import config __all__ = ["App", "check", "Checks", "Child", "EOF", "Error", "File", "Mismatch", "valgrind"] @@ -300,7 +307,7 @@ def import_checks(identifier): for dir in [checks_root, os.path.dirname(config.check_dir)]: requirements = os.path.join(dir, "requirements.txt") if os.path.exists(requirements): - args = ["install", "-r", requirements] + args = ["install", "--upgrade", "-r", requirements] # If we are not in a virtualenv, we need --user if not hasattr(sys, "real_prefix"): args.append("--user") @@ -314,6 +321,10 @@ def import_checks(identifier): raise InternalError("failed to install dependencies in ({})".format( requirements[len(config.args.checkdir) + 1:])) + # Refresh sys.path to look for newly installed dependencies + reload(site) + + try: # Import module from file path directly. module = imp.load_source(slug, os.path.join(config.check_dir, "__init__.py")) diff --git a/setup.py b/setup.py index 41ee9be9..92fd27a9 100644 --- a/setup.py +++ b/setup.py @@ -59,5 +59,5 @@ class CustomInstall(install): "console_scripts": ["check50=check50:main"] }, url="https://github.com/cs50/check50", - version="2.2.6" + version="2.2.7" )