mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Merge pull request #58 from minrk/fix-conda-check
bootstrap: allow conda to be upgraded
This commit is contained in:
@@ -11,6 +11,7 @@ Constraints:
|
|||||||
- Be compatible with Python 3.4 (since we support Ubuntu 16.04)
|
- Be compatible with Python 3.4 (since we support Ubuntu 16.04)
|
||||||
- Use stdlib modules only
|
- Use stdlib modules only
|
||||||
"""
|
"""
|
||||||
|
from distutils.version import LooseVersion as V
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import urllib.request
|
import urllib.request
|
||||||
@@ -38,13 +39,15 @@ def check_miniconda_version(prefix, version):
|
|||||||
Return true if a miniconda install with version exists at prefix
|
Return true if a miniconda install with version exists at prefix
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return subprocess.check_output([
|
installed_version = subprocess.check_output([
|
||||||
os.path.join(prefix, 'bin', 'conda'),
|
os.path.join(prefix, 'bin', 'conda'),
|
||||||
'-V'
|
'-V'
|
||||||
]).decode().strip() == 'conda {}'.format(version)
|
]).decode().strip().split()[1]
|
||||||
except (subprocess.CalledProcessError, FileNotFoundError):
|
except (subprocess.CalledProcessError, FileNotFoundError):
|
||||||
# Conda doesn't exist, or wrong version
|
# Conda doesn't exist, or wrong version
|
||||||
return False
|
return False
|
||||||
|
else:
|
||||||
|
return V(installed_version) >= V(version)
|
||||||
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
|
|||||||
Reference in New Issue
Block a user