README.rst 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. Semver |latest-version|
  2. =======================
  3. |build-status| |python-support| |downloads| |license|
  4. A Python module for `semantic versioning`_. Simplifies comparing versions.
  5. .. |latest-version| image:: https://img.shields.io/pypi/v/semver.svg
  6. :alt: Latest version on PyPI
  7. :target: https://pypi.python.org/pypi/semver
  8. .. |build-status| image:: https://travis-ci.org/k-bx/python-semver.svg?branch=master
  9. :alt: Build status
  10. :target: https://travis-ci.org/k-bx/python-semver
  11. .. |python-support| image:: https://img.shields.io/pypi/pyversions/semver.svg
  12. :target: https://pypi.python.org/pypi/semver
  13. :alt: Python versions
  14. .. |downloads| image:: https://img.shields.io/pypi/dm/semver.svg
  15. :alt: Monthly downloads from PyPI
  16. :target: https://pypi.python.org/pypi/semver
  17. .. |license| image:: https://img.shields.io/pypi/l/semver.svg
  18. :alt: Software license
  19. :target: https://github.com/k-bx/python-semver/blob/master/LICENSE.txt
  20. .. _semantic versioning: http://semver.org/
  21. Usage
  22. -----
  23. This module provides just couple of functions, main of which are:
  24. .. code-block:: python
  25. >>> import semver
  26. >>> semver.compare("1.0.0", "2.0.0")
  27. -1
  28. >>> semver.compare("2.0.0", "1.0.0")
  29. 1
  30. >>> semver.compare("2.0.0", "2.0.0")
  31. 0
  32. >>> semver.match("2.0.0", ">=1.0.0")
  33. True
  34. >>> semver.match("1.0.0", ">1.0.0")
  35. False
  36. >>> semver.format_version(3, 4, 5, 'pre.2', 'build.4')
  37. '3.4.5-pre.2+build.4'
  38. >>> semver.bump_major("3.4.5")
  39. '4.0.0'
  40. >>> semver.bump_minor("3.4.5")
  41. '3.5.0'
  42. >>> semver.bump_patch("3.4.5")
  43. '3.4.6'
  44. >>> semver.max_ver("1.0.0", "2.0.0")
  45. '2.0.0'
  46. >>> semver.min_ver("1.0.0", "2.0.0")
  47. '1.0.0'
  48. Installation
  49. ------------
  50. For Python 2:
  51. .. code-block:: bash
  52. pip install semver
  53. For Python 3:
  54. .. code-block:: bash
  55. pip3 install semver
  56. How to Contribute
  57. -----------------
  58. When you make changes to the code please run the tests before pushing your
  59. code to your fork and opening a `pull request`_:
  60. .. code-block:: bash
  61. python setup.py test
  62. We use `py.test`_ and `tox`_ to run tests against all supported Python
  63. versions. All test dependencies are resolved automatically, apart from
  64. virtualenv, which for the moment you still may have to install manually:
  65. .. code-block:: bash
  66. pip install "virtualenv<14.0.0" # <14.0.0 needed for Python 3.2 only
  67. You can use the ``clean`` command to remove build and test files and folders:
  68. .. code-block:: bash
  69. python setup.py clean
  70. .. _pull request: https://github.com/k-bx/python-semver/pulls
  71. .. _py.test: http://pytest.org/
  72. .. _tox: http://tox.testrun.org/