add mac osx version checking
@@ -6,12 +6,24 @@ working with packages.
from __future__ import print_function, absolute_import
import sys, subprocess
+def check_macos_ver():
+ import sys,platform
+ if sys.platform == 'darwin':
+ vstr, _, _ = platform.mac_ver()
+ from distutils.version import LooseVersion
+ import warnings
+ v = LooseVersion(vstr)
+ oldest_str = '10.9.0'
+ if v < LooseVersion(oldest_str):
+ warnings.warn('Your OS version is older than the oldest supported version ({} < {}). The operation may fail.'.format(vstr,oldest_str))
+
def searchPackage(name):
""" Search pip package for package name.
:param name: package name
:return:
"""
+ check_macos_ver()
subprocess.check_call([sys.executable, '-m', 'pip', 'search', name])
@@ -25,6 +37,7 @@ def installPackage(name):
:param name: package name
:return:
"""
+ check_macos_ver()
subprocess.check_call([sys.executable, '-m', 'pip', 'install', name])
@@ -34,6 +47,7 @@ def upgradePackage(name):
:param name: package name
:return:
"""
+ check_macos_ver()
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '--upgrade', name])
@@ -43,4 +57,5 @@ def uninstallPackage(name):
:param name: package name
:return:
"""
+ check_macos_ver()
subprocess.check_call([sys.executable, '-m', 'pip', 'uninstall', '-y', name])
