@@ -41,34 +41,43 @@ for easier development, testing and pre-release deployment?!
4141
4242Search no more!
4343
44- As long as you mark your releases using git tags, instead of hardcoding:
44+ As long as you use git and you mark your releases using git tags, version-query will do the rest.
4545
46- .. code :: python
46+ It's 21st century, stop hardcoding version numbers!
4747
48- __version__ = ' 1.5.0.dev2'
48+ .. contents ::
49+ :backlinks: none
4950
50- You can do:
5151
52- .. code :: python
52+ Overview
53+ ========
5354
54- from version_query import predict_version_str
55+ There are two main ways of using version-query - at runtime or at build time.
5556
56- __version__ = predict_version_str()
57+ Using at runtime
58+ ----------------
5759
58- It's 21st century, stop hardcoding version numbers!
60+ When using this way, version-query is needed as a runtime dependency of your package.
5961
60- This will set the version to release version when you really release a new version,
61- and it will automatically generate a suitable development version at development/pre-release phase.
62+ If, for example, you have a constant storing the version of your package in some Python module:
6263
64+ .. code :: python
6365
64- .. contents ::
65- :backlinks: none
66+ VERSION = ' 1.5.0.dev2'
6667
68+ You can do the following instead of hardcoding it:
6769
68- Overview
69- ========
70+ .. code :: python
71+
72+ from version_query import predict_version_str
7073
71- At development time, the current version number is automatically generated based on:
74+ VERSION = predict_version_str()
75+
76+ This will set the version to release version when you really release a new version,
77+ and it will automatically generate a suitable development version at development/pre-release phase.
78+
79+ When your package is imported while running from inside the repository, such as during development,
80+ the current version number is automatically generated based on:
7281
7382* tags
7483* current commit SHA
@@ -81,9 +90,43 @@ or at runtime) then the script relies on metadata generated at packaging time.
8190That's why, regardless if package is installed from PyPI (from source or wheel distribution)
8291or cloned from GitHub, the version query will work.
8392
84- Additionally, version numbers in version-query are mutable objects and they can be conveniently
85- incremented, compared with each other, as well as converted to/from other popular
86- versioning formats.
93+ Using at build time
94+ -------------------
95+
96+ This is the way to go if you want to use version-query only as a dependency when building
97+ the package, in such case it's not necessary to to add it to runtime dependencies.
98+
99+ There are many build systems avialable for Python, and version-query may not be compatible
100+ with all of them. Below are some examples.
101+
102+ setuptools with ``setup.py `` script
103+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
104+
105+ This is a legacy way of building Python packages, but it is still widely used.
106+
107+ In such setup, you just need to add the following to your ``setup.py `` file:
108+
109+ .. code :: python
110+
111+ from version_query import predict_version_str
112+
113+ setup(
114+ ... ,
115+ version = predict_version_str()
116+ )
117+
118+ If you are already using version-query at runtime in your package to set a constant
119+ (for example ``my_package.VERSION ``, please see "Using at runtime" section above for details),
120+ you may instead reuse the same constant in your ``setup.py `` file:
121+
122+ .. code :: python
123+
124+ from my_package import VERSION
125+
126+ setup(
127+ ... ,
128+ version = VERSION
129+ )
87130
88131 Versioning scheme
89132=================
0 commit comments