METADATA 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. Metadata-Version: 2.1
  2. Name: incremental
  3. Version: 24.7.2
  4. Summary: A small library that versions your Python projects.
  5. Maintainer-email: Amber Brown <hawkowl@twistedmatrix.com>
  6. Project-URL: Homepage, https://github.com/twisted/incremental
  7. Project-URL: Documentation, https://twisted.org/incremental/docs/
  8. Project-URL: Issues, https://github.com/twisted/incremental/issues
  9. Project-URL: Changelog, https://github.com/twisted/incremental/blob/trunk/NEWS.rst
  10. Classifier: Intended Audience :: Developers
  11. Classifier: License :: OSI Approved :: MIT License
  12. Classifier: Framework :: Hatch
  13. Classifier: Framework :: Setuptools Plugin
  14. Classifier: Programming Language :: Python :: 3
  15. Classifier: Programming Language :: Python :: 3.8
  16. Classifier: Programming Language :: Python :: 3.9
  17. Classifier: Programming Language :: Python :: 3.10
  18. Classifier: Programming Language :: Python :: 3.11
  19. Classifier: Programming Language :: Python :: 3.12
  20. Requires-Python: >=3.8
  21. Description-Content-Type: text/x-rst
  22. License-File: LICENSE
  23. Requires-Dist: setuptools >=61.0
  24. Requires-Dist: tomli ; python_version < "3.11"
  25. Provides-Extra: scripts
  26. Requires-Dist: click >=6.0 ; extra == 'scripts'
  27. Incremental
  28. ===========
  29. |gha|
  30. |pypi|
  31. |coverage|
  32. Incremental is a small library that versions your Python projects.
  33. API documentation can be found `here <https://twisted.org/incremental/docs/>`_.
  34. .. contents::
  35. Quick Start
  36. -----------
  37. Using setuptools
  38. ~~~~~~~~~~~~~~~~
  39. Add Incremental to your ``pyproject.toml``:
  40. .. code-block:: toml
  41. [build-system]
  42. requires = [
  43. "setuptools",
  44. "incremental>=24.7.2", # ← Add incremental as a build dependency
  45. ]
  46. build-backend = "setuptools.build_meta"
  47. [project]
  48. name = "<projectname>"
  49. dynamic = ["version"] # ← Mark the version dynamic
  50. dependencies = [
  51. "incremental>=24.7.2", # ← Depend on incremental at runtime
  52. ]
  53. # ...
  54. [tool.incremental] # ← Activate Incremental's setuptools plugin
  55. It's fine if the ``[tool.incremental]`` table is empty, but it must be present.
  56. Remove any ``[project] version =`` entry and any ``[tool.setuptools.dynamic] version =`` entry.
  57. Next, `initialize the project`_.
  58. Using Hatchling
  59. ~~~~~~~~~~~~~~~
  60. If you're using `Hatchling <https://hatch.pypa.io/>`_ to package your project,
  61. activate Incremental's Hatchling plugin by altering your ``pyproject.toml``:
  62. .. code:: toml
  63. [build-system]
  64. requires = [
  65. "hatchling",
  66. "incremental>=24.7.2", # ← Add incremental as a build dependency
  67. ]
  68. build-backend = "hatchling.build"
  69. [project]
  70. name = "<projectname>"
  71. dynamic = ["version"] # ← Mark the version dynamic
  72. dependencies = [
  73. "incremental>=24.7.2", # ← Depend on incremental at runtime
  74. ]
  75. # ...
  76. [tool.hatch.version]
  77. source = "incremental" # ← Activate Incremental's Hatchling plugin
  78. Incremental can be configured as usual in an optional ``[tool.incremental]`` table.
  79. The ``hatch version`` command will report the Incremental-managed version.
  80. Use the ``python -m incremental.update`` command to change the version (setting it with ``hatch version`` is not supported).
  81. Next, `initialize the project`_.
  82. Using ``setup.py``
  83. ~~~~~~~~~~~~~~~~~~
  84. Incremental may be used from ``setup.py`` instead of ``pyproject.toml``.
  85. Add this to your ``setup()`` call, removing any other versioning arguments:
  86. .. code:: python
  87. setup(
  88. use_incremental=True,
  89. setup_requires=['incremental'],
  90. install_requires=['incremental'], # along with any other install dependencies
  91. ...
  92. }
  93. Then `initialize the project`_.
  94. Initialize the project
  95. ~~~~~~~~~~~~~~~~~~~~~~
  96. Install Incremental to your local environment with ``pip install incremental[scripts]``.
  97. Then run ``python -m incremental.update <projectname> --create``.
  98. It will create a file in your package named ``_version.py`` like this:
  99. .. code:: python
  100. from incremental import Version
  101. __version__ = Version("<projectname>", 24, 1, 0)
  102. __all__ = ["__version__"]
  103. Then, so users of your project can find your version, in your root package's ``__init__.py`` add:
  104. .. code:: python
  105. from ._version import __version__
  106. Subsequent installations of your project will then use Incremental for versioning.
  107. Incremental Versions
  108. --------------------
  109. ``incremental.Version`` is a class that represents a version of a given project.
  110. It is made up of the following elements (which are given during instantiation):
  111. - ``package`` (required), the name of the package this ``Version`` represents.
  112. - ``major``, ``minor``, ``micro`` (all required), the X.Y.Z of your project's ``Version``.
  113. - ``release_candidate`` (optional), set to 0 or higher to mark this ``Version`` being of a release candidate (also sometimes called a "prerelease").
  114. - ``post`` (optional), set to 0 or higher to mark this ``Version`` as a postrelease.
  115. - ``dev`` (optional), set to 0 or higher to mark this ``Version`` as a development release.
  116. 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"``.
  117. Calling ``repr()`` with a ``Version`` will give a Python-source-code representation of it, and calling ``str()`` on a ``Version`` produces a string like ``'[Incremental, version 16.10.1]'``.
  118. Updating
  119. --------
  120. Incremental includes a tool to automate updating your Incremental-using project's version called ``incremental.update``.
  121. It updates the ``_version.py`` file and automatically updates some uses of Incremental versions from an indeterminate version to the current one.
  122. It requires ``click`` from PyPI.
  123. ``python -m incremental.update <projectname>`` will perform updates on that package.
  124. The commands that can be given after that will determine what the next version is.
  125. - ``--newversion=<version>``, to set the project version to a fully-specified version (like 1.2.3, or 17.1.0dev1).
  126. - ``--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.
  127. - ``--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.
  128. - ``--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.
  129. - ``--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.
  130. If you give no arguments, it will strip the release candidate number, making it a "full release".
  131. 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:
  132. - ``Version("<projectname>", "NEXT", 0, 0)``
  133. - ``<projectname> NEXT``
  134. 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):
  135. - ``Version("<projectname>", 17, 1, 0, release_candidate=1)``
  136. - ``<projectname> 17.1.0rc1``
  137. Once the final version is made, it will become:
  138. - ``Version("<projectname>", 17, 1, 0)``
  139. - ``<projectname> 17.1.0``
  140. .. |coverage| image:: https://codecov.io/gh/twisted/incremental/branch/master/graph/badge.svg?token=K2ieeL887X
  141. .. _coverage: https://codecov.io/gh/twisted/incremental
  142. .. |gha| image:: https://github.com/twisted/incremental/actions/workflows/tests.yaml/badge.svg
  143. .. _gha: https://github.com/twisted/incremental/actions/workflows/tests.yaml
  144. .. |pypi| image:: http://img.shields.io/pypi/v/incremental.svg
  145. .. _pypi: https://pypi.python.org/pypi/incremental