|
1 | 1 |
|
2 | | -# Version: 0.8+ |
| 2 | +# Version: 0.9 |
3 | 3 |
|
4 | 4 | """ |
5 | 5 | The Versioneer |
|
22 | 22 |
|
23 | 23 | ## Quick Install |
24 | 24 |
|
25 | | -* `pip install versioneer` somewhere to your $PATH |
26 | | -* run `versioneerer` in your source tree: installs `versioneer.py` |
27 | | -* follow the instructions below |
| 25 | +* `pip install versioneer` to somewhere to your $PATH |
| 26 | +* run `versioneer-installer` in your source tree: this installs `versioneer.py` |
| 27 | +* follow the instructions below (also in the `versioneer.py` docstring) |
28 | 28 |
|
29 | 29 | ## Version Identifiers |
30 | 30 |
|
31 | 31 | Source trees come from a variety of places: |
32 | 32 |
|
33 | | -* a version-control system checkout (mostly used by developers or eager |
34 | | - followers) |
| 33 | +* a version-control system checkout (mostly used by developers) |
35 | 34 | * a nightly tarball, produced by build automation |
36 | | -* a snapshot tarball, produced by a web-based VCS browser, like hgweb or |
37 | | - github's "tarball from tag" feature |
38 | | -* a release tarball, produced by "setup.py sdist", and perhaps distributed |
39 | | - through PyPI |
| 35 | +* a snapshot tarball, produced by a web-based VCS browser, like github's |
| 36 | + "tarball from tag" feature |
| 37 | +* a release tarball, produced by "setup.py sdist", distributed through PyPI |
40 | 38 |
|
41 | 39 | Within each source tree, the version identifier (either a string or a number, |
42 | 40 | this tool is format-agnostic) can come from a variety of places: |
|
68 | 66 | ## Theory of Operation |
69 | 67 |
|
70 | 68 | Versioneer works by adding a special `_version.py` file into your source |
71 | | -tree, where your `__init__.py` can import it. This _version.py knows how to |
| 69 | +tree, where your `__init__.py` can import it. This `_version.py` knows how to |
72 | 70 | dynamically ask the VCS tool for version information at import time. However, |
73 | 71 | when you use "setup.py build" or "setup.py sdist", `_version.py` in the new |
74 | 72 | copy is replaced by a small static file that contains just the generated |
75 | 73 | version data. |
76 | 74 |
|
77 | 75 | `_version.py` also contains `$Revision$` markers, and the installation |
78 | | -process marks _version.py to have this marker rewritten with a tag name |
| 76 | +process marks `_version.py` to have this marker rewritten with a tag name |
79 | 77 | during the "git archive" command. As a result, generated tarballs will |
80 | 78 | contain enough information to get the proper version. |
81 | 79 |
|
82 | 80 |
|
83 | 81 | ## Installation |
84 | 82 |
|
85 | | -You will need to provide versioneer with a few configuration variables: |
| 83 | +First, decide on values for the following configuration variables: |
86 | 84 |
|
87 | 85 | * `versionfile_source`: |
88 | 86 |
|
89 | 87 | A project-relative pathname into which the generated version strings should |
90 | | - be written. This is usually a _version.py next to your project's main |
| 88 | + be written. This is usually a `_version.py` next to your project's main |
91 | 89 | `__init__.py` file. If your project uses `src/myproject/__init__.py`, this |
92 | 90 | should be `src/myproject/_version.py`. This file should be checked in to |
93 | 91 | your VCS as usual: the copy created below by 'setup.py update_files' will |
|
116 | 114 | all unpacked tarball filenames. If your tarball unpacks into |
117 | 115 | 'myproject-1.2.0', this should be 'myproject-'. |
118 | 116 |
|
119 | | -This tool provides one script, named `versioneer.py`. |
| 117 | +This tool provides one script, named `versioneer-installer`. That script does |
| 118 | +one thing: write a copy of `versioneer.py` into the current directory. |
120 | 119 |
|
121 | 120 | To versioneer-enable your project: |
122 | 121 |
|
123 | | -* 1: copy `versioneer.py` into the top of your source tree |
| 122 | +* 1: Run `versioneer-installer` to copy `versioneer.py` into the top of your |
| 123 | + source tree. |
124 | 124 |
|
125 | | -* 2: add the following lines to the top of your `setup.py`, with suitable |
126 | | - values for each configuration setting: |
| 125 | +* 2: add the following lines to the top of your `setup.py`, with the |
| 126 | + configuration values you decided earlier: |
127 | 127 |
|
128 | | - import versioneer |
129 | | - versioneer.versionfile_source = 'src/myproject/_version.py' |
130 | | - versioneer.versionfile_build = 'myproject/_version.py' |
131 | | - versioneer.tag_prefix = '' # tags are like 1.2.0 |
132 | | - versioneer.parentdir_prefix = 'myproject-' # dirname like 'myproject-1.2.0' |
| 128 | + import versioneer |
| 129 | + versioneer.versionfile_source = 'src/myproject/_version.py' |
| 130 | + versioneer.versionfile_build = 'myproject/_version.py' |
| 131 | + versioneer.tag_prefix = '' # tags are like 1.2.0 |
| 132 | + versioneer.parentdir_prefix = 'myproject-' # dirname like 'myproject-1.2.0' |
133 | 133 |
|
134 | 134 | * 3: add the following arguments to the setup() call in your setup.py: |
135 | 135 |
|
136 | | - version=versioneer.get_version(), |
137 | | - cmdclass=versioneer.get_cmdclass(), |
| 136 | + version=versioneer.get_version(), |
| 137 | + cmdclass=versioneer.get_cmdclass(), |
138 | 138 |
|
139 | | -* 4: run `setup.py update_files`, which will create `_version.py`, and will |
140 | | - modify your `__init__.py` to define `__version__` (by calling a function |
141 | | - from `_version.py`) |
| 139 | +* 4: now run `setup.py update_files`, which will create `_version.py`, and |
| 140 | + will modify your `__init__.py` to define `__version__` (by calling a |
| 141 | + function from `_version.py`) |
142 | 142 |
|
143 | 143 | * 5: modify your MANIFEST.in to include `versioneer.py` in sdist tarballs |
144 | 144 |
|
145 | 145 | * 6: commit these changes to your VCS. `update_files` will mark both |
146 | | - `versioneer.py` and the generated `_version.py` for addition. |
| 146 | + `versioneer.py` and the generated `_version.py` for addition. |
147 | 147 |
|
148 | 148 | ## Post-Installation Usage |
149 | 149 |
|
|
167 | 167 | report "unknown" until your tree has at least one tag in its history. This |
168 | 168 | restriction will be fixed eventually (see issue #12). |
169 | 169 |
|
| 170 | +## Version-String Flavors |
| 171 | +
|
| 172 | +Code which uses Versioneer can learn about its version string at runtime by |
| 173 | +importing `_version` from your main `__init__.py` file and running the |
| 174 | +`get_versions()` function. From the "outside" (e.g. in `setup.py`), you can |
| 175 | +import the top-level `versioneer.py` and run `get_versions()`. |
| 176 | +
|
| 177 | +Both functions return a dictionary with different keys for different flavors |
| 178 | +of the version string: |
| 179 | +
|
| 180 | +* `['version']`: condensed tag+distance+shortid+dirty identifier. For git, |
| 181 | + this uses the output of `git describe --tags --dirty --always` but strips |
| 182 | + the tag_prefix. For example "0.11-2-g1076c97-dirty" indicates that the tree |
| 183 | + is like the "1076c97" commit but has uncommitted changes ("-dirty"), and |
| 184 | + that this commit is two revisions ("-2-") beyond the "0.11" tag. For |
| 185 | + released software (exactly equal to a known tag), the identifier will only |
| 186 | + contain the stripped tag, e.g. "0.11". |
| 187 | +
|
| 188 | +* `['full']`: detailed revision identifier. For Git, this is the full SHA1 |
| 189 | + commit id, followed by "-dirty" if the tree contains uncommitted changes, |
| 190 | + e.g. "1076c978a8d3cfc70f408fe5974aa6c092c949ac-dirty". |
| 191 | +
|
| 192 | +Some variants are more useful than others. Including `full` in a bug report |
| 193 | +should allow developers to reconstruct the exact code being tested (or |
| 194 | +indicate the presence of local changes that should be shared with the |
| 195 | +developers). `version` is suitable for display in an "about" box or a CLI |
| 196 | +`--version` output: it can be easily compared against release notes and lists |
| 197 | +of bugs fixed in various releases. |
| 198 | +
|
| 199 | +In the future, this will also include a |
| 200 | +[PEP-0440](http://legacy.python.org/dev/peps/pep-0440/) -compatible flavor |
| 201 | +(e.g. `1.2.post0.dev123`). This loses a lot of information (and has no room |
| 202 | +for a hash-based revision id), but is safe to use in a `setup.py` |
| 203 | +"`version=`" argument. It also enables tools like *pip* to compare version |
| 204 | +strings and evaluate compatibility constraint declarations. |
| 205 | +
|
| 206 | +The `setup.py update_files` command adds the following text to your |
| 207 | +`__init__.py` to place a basic version in `YOURPROJECT.__version__`: |
| 208 | +
|
| 209 | + from ._version import get_versions |
| 210 | + __version = get_versions()['version'] |
| 211 | + del get_versions |
170 | 212 |
|
171 | 213 | ## Future Directions |
172 | 214 |
|
|
185 | 227 | ## License |
186 | 228 |
|
187 | 229 | To make Versioneer easier to embed, all its code is hereby released into the |
188 | | -public domain. The `_version.py` that it creates is also in the public domain. |
| 230 | +public domain. The `_version.py` that it creates is also in the public |
| 231 | +domain. |
189 | 232 |
|
190 | 233 | """ |
191 | 234 |
|
|
210 | 253 | # that just contains the computed version number. |
211 | 254 |
|
212 | 255 | # This file is released into the public domain. Generated by |
213 | | -# versioneer-0.8+ (https://github.com/warner/python-versioneer) |
| 256 | +# versioneer-0.9 (https://github.com/warner/python-versioneer) |
214 | 257 |
|
215 | 258 | # these strings will be replaced by git during git-archive |
216 | 259 | git_refnames = "%(DOLLAR)sFormat:%%d%(DOLLAR)s" |
@@ -588,7 +631,7 @@ def do_vcs_install(versionfile_source, ipy): |
588 | 631 | run_command(GITS, ["add", "--"] + files) |
589 | 632 |
|
590 | 633 | SHORT_VERSION_PY = """ |
591 | | -# This file was generated by 'versioneer.py' (0.8+) from |
| 634 | +# This file was generated by 'versioneer.py' (0.9) from |
592 | 635 | # revision-control system data, or from the parent directory name of an |
593 | 636 | # unpacked source archive. Distribution tarballs contain a pre-generated copy |
594 | 637 | # of this file. |
|
0 commit comments