Commit 8e1b9e17 by Clinton Blackburn Committed by Clinton Blackburn

Added support for disabling removal of old Python libraries

The NO_PYTHON_UNINSTALL environment variable can now be used to disable the task that removes older versions of Python libraries. This task is not necessary for Docker images/containers since we always create a fresh virtualenv when we create the image.
parent 85d05558
...@@ -17,6 +17,7 @@ from .utils.timer import timed ...@@ -17,6 +17,7 @@ from .utils.timer import timed
PREREQS_STATE_DIR = os.getenv('PREREQ_CACHE_DIR', Env.REPO_ROOT / '.prereqs_cache') PREREQS_STATE_DIR = os.getenv('PREREQ_CACHE_DIR', Env.REPO_ROOT / '.prereqs_cache')
NPM_REGISTRY = "https://registry.npmjs.org/" NPM_REGISTRY = "https://registry.npmjs.org/"
NO_PREREQ_MESSAGE = "NO_PREREQ_INSTALL is set, not installing prereqs" NO_PREREQ_MESSAGE = "NO_PREREQ_INSTALL is set, not installing prereqs"
NO_PYTHON_UNINSTALL_MESSAGE = 'NO_PYTHON_UNINSTALL is set. No attempts will be made to uninstall old Python libs.'
COVERAGE_REQ_FILE = 'requirements/edx/coverage.txt' COVERAGE_REQ_FILE = 'requirements/edx/coverage.txt'
# If you make any changes to this list you also need to make # If you make any changes to this list you also need to make
...@@ -38,23 +39,21 @@ if os.path.exists(PRIVATE_REQS): ...@@ -38,23 +39,21 @@ if os.path.exists(PRIVATE_REQS):
PYTHON_REQ_FILES.append(PRIVATE_REQS) PYTHON_REQ_FILES.append(PRIVATE_REQS)
def str2bool(s):
s = str(s)
return s.lower() in ('yes', 'true', 't', '1')
def no_prereq_install(): def no_prereq_install():
""" """
Determine if NO_PREREQ_INSTALL should be truthy or falsy. Determine if NO_PREREQ_INSTALL should be truthy or falsy.
""" """
vals = { return str2bool(os.environ.get('NO_PREREQ_INSTALL', 'False'))
'0': False,
'1': True,
'true': True,
'false': False,
}
val = os.environ.get("NO_PREREQ_INSTALL", 'False').lower()
try: def no_python_uninstall():
return vals[val] """ Determine if we should run the uninstall_python_packages task. """
except KeyError: return str2bool(os.environ.get('NO_PYTHON_UNINSTALL', 'False'))
return False
def create_prereqs_cache_dir(): def create_prereqs_cache_dir():
...@@ -199,8 +198,12 @@ def uninstall_python_packages(): ...@@ -199,8 +198,12 @@ def uninstall_python_packages():
uninstalled, notably, South. Some other packages were once installed in uninstalled, notably, South. Some other packages were once installed in
ways that were resistant to being upgraded, like edxval. Also uninstall ways that were resistant to being upgraded, like edxval. Also uninstall
them. them.
""" """
if no_python_uninstall():
print(NO_PYTHON_UNINSTALL_MESSAGE)
return
# So that we don't constantly uninstall things, use a hash of the packages # So that we don't constantly uninstall things, use a hash of the packages
# to be uninstalled. Check it, and skip this if we're up to date. # to be uninstalled. Check it, and skip this if we're up to date.
hasher = hashlib.sha1() hasher = hashlib.sha1()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment