Skip to content

Commit

Permalink
Merge pull request #163 from cs50/reload2
Browse files Browse the repository at this point in the history
Reload2
  • Loading branch information
Kareem Zidane authored Jul 11, 2019
2 parents 28e3ba5 + d994aa7 commit eb9d1bf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion check50.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import requests
import shutil
import signal
import site
import subprocess
import sys
import tempfile
Expand Down Expand Up @@ -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"]
Expand Down Expand Up @@ -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")
Expand All @@ -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"))
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

0 comments on commit eb9d1bf

Please sign in to comment.