README.rst 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. Incremental
  2. ===========
  3. |gha|
  4. |pypi|
  5. |coverage|
  6. Incremental is a small library that versions your Python projects.
  7. API documentation can be found `here <https://twisted.github.io/incremental/docs/>`_.
  8. Quick Start
  9. -----------
  10. Add this to your ``setup.py``\ 's ``setup()`` call, removing any other versioning arguments:
  11. .. code::
  12. setup(
  13. use_incremental=True,
  14. setup_requires=['incremental'],
  15. install_requires=['incremental'], # along with any other install dependencies
  16. ...
  17. }
  18. Install Incremental to your local environment with ``pip install incremental[scripts]``.
  19. Then run ``python -m incremental.update <projectname> --create``.
  20. It will create a file in your package named ``_version.py`` and look like this:
  21. .. code::
  22. from incremental import Version
  23. __version__ = Version("widgetbox", 17, 1, 0)
  24. __all__ = ["__version__"]
  25. Then, so users of your project can find your version, in your root package's ``__init__.py`` add:
  26. .. code::
  27. from ._version import __version__
  28. Subsequent installations of your project will then use Incremental for versioning.
  29. Incremental Versions
  30. --------------------
  31. ``incremental.Version`` is a class that represents a version of a given project.
  32. It is made up of the following elements (which are given during instantiation):
  33. - ``package`` (required), the name of the package this ``Version`` represents.
  34. - ``major``, ``minor``, ``micro`` (all required), the X.Y.Z of your project's ``Version``.
  35. - ``release_candidate`` (optional), set to 0 or higher to mark this ``Version`` being of a release candidate (also sometimes called a "prerelease").
  36. - ``post`` (optional), set to 0 or higher to mark this ``Version`` as a postrelease.
  37. - ``dev`` (optional), set to 0 or higher to mark this ``Version`` as a development release.
  38. You can extract a PEP-440 compatible version string by using the ``.public()`` method, which returns a ``str`` containing the full version. This is the version you should provide to users, or publicly use. An example output would be ``"13.2.0"``, ``"17.1.2dev1"``, or ``"18.8.0rc2"``.
  39. Calling ``repr()`` with a ``Version`` will give a Python-source-code representation of it, and calling ``str()`` with a ``Version`` will provide a string similar to ``'[Incremental, version 16.10.1]'``.
  40. Updating
  41. --------
  42. Incremental includes a tool to automate updating your Incremental-using project's version called ``incremental.update``.
  43. It updates the ``_version.py`` file and automatically updates some uses of Incremental versions from an indeterminate version to the current one.
  44. It requires ``click`` from PyPI.
  45. ``python -m incremental.update <projectname>`` will perform updates on that package.
  46. The commands that can be given after that will determine what the next version is.
  47. - ``--newversion=<version>``, to set the project version to a fully-specified version (like 1.2.3, or 17.1.0dev1).
  48. - ``--rc``, to set the project version to ``<year-2000>.<month>.0rc1`` if the current version is not a release candidate, or bump the release candidate number by 1 if it is.
  49. - ``--dev``, to set the project development release number to 0 if it is not a development release, or bump the development release number by 1 if it is.
  50. - ``--patch``, to increment the patch number of the release. This will also reset the release candidate number, pass ``--rc`` at the same time to increment the patch number and make it a release candidate.
  51. - ``--post``, to set the project postrelease number to 0 if it is not a postrelease, or bump the postrelease number by 1 if it is. This will also reset the release candidate and development release numbers.
  52. If you give no arguments, it will strip the release candidate number, making it a "full release".
  53. Incremental supports "indeterminate" versions, as a stand-in for the next "full" version. This can be used when the version which will be displayed to the end-user is unknown (for example "introduced in" or "deprecated in"). Incremental supports the following indeterminate versions:
  54. - ``Version("<projectname>", "NEXT", 0, 0)``
  55. - ``<projectname> NEXT``
  56. When you run ``python -m incremental.update <projectname> --rc``, these will be updated to real versions (assuming the target final version is 17.1.0):
  57. - ``Version("<projectname>", 17, 1, 0, release_candidate=1)``
  58. - ``<projectname> 17.1.0rc1``
  59. Once the final version is made, it will become:
  60. - ``Version("<projectname>", 17, 1, 0)``
  61. - ``<projectname> 17.1.0``
  62. .. |coverage| image:: https://codecov.io/gh/twisted/incremental/branch/master/graph/badge.svg?token=K2ieeL887X
  63. .. _coverage: https://codecov.io/gh/twisted/incremental
  64. .. |gha| image:: https://github.com/twisted/incremental/actions/workflows/tests.yaml/badge.svg
  65. .. _gha: https://github.com/twisted/incremental/actions/workflows/tests.yaml
  66. .. |pypi| image:: http://img.shields.io/pypi/v/incremental.svg
  67. .. _pypi: https://pypi.python.org/pypi/incremental