@@ -26,13 +26,11 @@ system, and maybe making new tarballs.
26
26
27
27
Source trees come from a variety of places:
28
28
29
- * a version-control system checkout (mostly used by developers or eager
30
- followers)
29
+ * a version-control system checkout (mostly used by developers)
31
30
* a nightly tarball, produced by build automation
32
- * a snapshot tarball, produced by a web-based VCS browser, like hgweb or
33
- github's "tarball from tag" feature
34
- * a release tarball, produced by "setup.py sdist", and perhaps distributed
35
- through PyPI
31
+ * a snapshot tarball, produced by a web-based VCS browser, like github's
32
+ "tarball from tag" feature
33
+ * a release tarball, produced by "setup.py sdist", distributed through PyPI
36
34
37
35
Within each source tree, the version identifier (either a string or a number,
38
36
this tool is format-agnostic) can come from a variety of places:
@@ -165,6 +163,45 @@ Currently, all version strings must be based upon a tag. Versioneer will
165
163
report "unknown" until your tree has at least one tag in its history. This
166
164
restriction will be fixed eventually (see issue #12 ).
167
165
166
+ ## Version-String Flavors
167
+
168
+ Code which uses Versioneer can learn about its version string by importing
169
+ ` _version ` from your main ` __init__.py ` file and running the ` get_versions() `
170
+ method. This returns a dictionary with different keys for different flavors
171
+ of the version string:
172
+
173
+ * ` ['version'] ` : condensed tag+distance+shortid+dirty identifier. For git,
174
+ this uses the output of ` git describe --tags --dirty --always ` but strips
175
+ the tag_prefix. For example "0.11-2-g1076c97-dirty" indicates that the tree
176
+ is like the "1076c97" commit but has uncommitted changes ("-dirty"), and
177
+ that this commit is two revisions ("-2-") beyond the "0.11" tag. For
178
+ released software (exactly equal to a known tag), the identifier will only
179
+ contain the stripped tag, e.g. "0.11".
180
+
181
+ * ` ['full'] ` : detailed revision identifier. For Git, this is the full SHA1
182
+ commit id, followed by "-dirty" if the tree contains uncommitted changes,
183
+ e.g. "1076c978a8d3cfc70f408fe5974aa6c092c949ac-dirty".
184
+
185
+ Some variants are more useful than others. Including ` full ` in a bug report
186
+ should allow developers to reconstruct the exact code being tested (or
187
+ indicate the presence of local changes that should be shared with the
188
+ developers). ` version ` is suitable for display in an "about" box or a CLI
189
+ ` --version ` output: it can be easily compared against release notes and lists
190
+ of bugs fixed in various releases.
191
+
192
+ In the future, this will also include a
193
+ [ http://legacy.python.org/dev/peps/pep-0440/ ] ( PEP-440 ) -compatible flavor
194
+ (e.g. ` .post0.dev123 ` ). This loses a lot of information (and has no place for
195
+ a hash-based revision id), but is safe to use in a ` setup.py ` "` version= ` "
196
+ argument. It also enables tools like * pip* to compare version strings and
197
+ evaluate compatibility constraint declarations.
198
+
199
+ The ` setup.py update_files ` command adds the following text to your
200
+ ` __init__.py ` to place a basic version in ` YOURPROJECT.__version__ ` :
201
+
202
+ from ._version import get_versions
203
+ __version = get_versions()['version']
204
+ del get_versions
168
205
169
206
## Future Directions
170
207
0 commit comments