version.py 1.2 KB

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