Format: text/x-python
⬇ Download File (1.2 KB)
   1  # encoding: utf-8
   2  """
   3  Utilities for version comparison
   4  
   5  It is a bit ridiculous that we need these.
   6  """
   7  
   8  #-----------------------------------------------------------------------------
   9  #  Copyright (C) 2013  The IPython Development Team
  10  #
  11  #  Distributed under the terms of the BSD License.  The full license is in
  12  #  the file COPYING, distributed as part of this software.
  13  #-----------------------------------------------------------------------------
  14  
  15  from warnings import warn
  16  
  17  warn(
  18      "The `IPython.utils.version` module has been deprecated since IPython 8.0.",
  19      DeprecationWarning,
  20  )
  21  
  22  
  23  def check_version(v, check):
  24      """check version string v >= check
  25  
  26      If dev/prerelease tags result in TypeError for string-number comparison,
  27      it is assumed that the dependency is satisfied.
  28      Users on dev branches are responsible for keeping their own packages up to date.
  29      """
  30      warn(
  31          "`check_version` function is deprecated as of IPython 8.0"
  32          "and will be removed in future versions.",
  33          DeprecationWarning,
  34          stacklevel=2,
  35      )
  36  
  37      from distutils.version import LooseVersion
  38  
  39      try:
  40          return LooseVersion(v) >= LooseVersion(check)
  41      except TypeError:
  42          return True
  43  
  44