• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

vcver/H10-Aug-2021-559433

vcver.egg-info/H03-May-2022-263181

LICENSEH A D10-Aug-20211 KiB2217

PKG-INFOH A D10-Aug-20218.4 KiB263181

README.rstH A D10-Aug-20217.7 KiB240161

setup.cfgH A D10-Aug-202138 53

setup.pyH A D10-Aug-20211.2 KiB4033

README.rst

1============
2vcver Python
3============
4
5--------------
6What is vcver?
7--------------
8
9vcver is an approach for versioning that heavily relies on the version control
10system of choice for determining version strings.
11
12There are two categories of version strings:
13
14develop versions, of the form:
15
16.. code-block::
17
18    {main_version}.dev{commit_count}+{branch}.{scm_change_id}
19
20With development branches, it is desired to not override versions published from
21a blessed subset of "released" branches. As such, if the current branch is not a release
22branch, a version of 0 is used instead of the main_version:
23
24.. code-block::
25
26    0.dev{commit_count}+{branch}.{scm_change_id}
27
28and a release version, of the form:
29
30.. code-block::
31
32    {main_version}
33
34Each part is described as follows:
35
36* main_version is retrieved from the last tagged commit with a leading v (e.g. v1.0),
37  but is converted to a 0 if the branch is not a release branch.
38* commit_count is the number of commits from main_version
39* branch is the branch that the repository was built against, removing
40  characters that are incompatible with PEP440 (anything that is not alphanumeric or a dot)
41* scm_change_id is a unique id in the form of version control, used to identify
42  the change that was used to build this version.
43
44For example, in a git repository, on a master branch with the most recent tag of
45v1.1, the dev version would look something like:
46
47.. code-block::
48
49   1.1.dev10+master.abc123
50
51On a develop branch:
52
53.. code-block::
54
55   0.dev13+develop.def456
56
57And a release version:
58
59.. code-block::
60
61   1.1
62
63These are compatible with
64`PEP440 <https://www.python.org/dev/peps/pep-0440/>`_.
65
66
67-------
68Example
69-------
70
71Add a MANIFEST.in to your package, if you do not already have one. Then add the following:
72
73.. code-block::
74
75   include VERSION
76
77It's also recommended to ignore this file in your version control.
78
79Then, follow this pattern in your setup.py:
80
81.. code-block:: python
82
83
84    # OPTIONAL, but recommended:
85    # this block is useful for specifying when a build should
86    # use the 'release' version. it allows specifying a release version
87    # with an additional argument in the setup.py:
88    # $ python setup.py upload --release
89    import sys
90    is_release = False
91    if "--release" in sys.argv:
92        sys.argv.remove("--release")
93        is_release = True
94
95    # OPTIONAL, but recommended:
96    # vcver writes a version file relative to the
97    # current working directory by default.
98    # It's recommended to provide it with your
99    # setup.py directory instead (in case someone
100    # runs your setup.py from a different directory)
101    base = os.path.dirname(os.path.abspath(__file__))
102
103    setup(name='aiohttp-transmute',
104        # add the following two lines,
105        # and do not specify a version.
106        setup_requires=["vcver"],
107        # vcver will only produce a release
108        # version if "is_release" is True.
109        vcver={
110            "is_release": is_release,
111            "path": base,
112            # OPTIONAL ARGS
113
114            # version_format overrides the standard version format
115            version_format="{main_version}.{commit_count}",
116
117            # release_version_format overrides the release version format
118            release_version_format="{commit_count}",
119
120            # scm_type: if you do not want autodetection of the SCM, you can
121            # specify it.
122            scm_type="git",
123
124            # release_branch_regex: override the default release branch
125            # (default release branch depends on the SCM used.)
126            release_branch_regex="(master|hotfix|release)",
127
128            # version_file: override the name of the version file.
129            version_file="GENERATED_VERSION"
130        },
131        ...
132    )
133
134Now your package will publish with a VC-based version!
135
136If you followed the full example, you can specify the release version by adding --release:
137
138.. code-block::
139
140    python setup.py upload --release
141
142-------------------
143FAQ / Other Details
144-------------------
145
146Why a dev and release version?
147==============================
148
149The dev and release versions have different goals:
150
151* dev: to provide as much information as possible to quickly identify
152  where the current version originated from in regard to version control.
153* release: to provide a clear version that helps the consumer understand what changed.
154
155For most consumers, the number of commits since the last release, the
156branch it was released against, or the build commit itself are
157irrelevant.  The consumer wants to know about the size of the change or type of changes,
158and that can be done by the major / minor / patch versions specified
159in the git tag, or the changelog. Adding version control information proves to be confusing with
160that regard, providing multiple numbers that are not relevant to figuring out
161the amount of change.
162
163Why zero out versions from non-release branches?
164================================================
165
166Sometimes, a non-release version can be published accidentally, or it may be desired to publish
167development versions side by side by versions published by release branches. In this situations,
168ensuring that the release versions always take precedence over non-release version is valuable, to ensure
169that development versions are not accidentally picked up by those expecting stable releases.
170
171If this behavior is not desired, custom version strings can be specified with "main_version" instead of "main_version". "main_version" is preserved regardless of the branch used.
172
173How to make sure others can consume your package
174================================================
175
176If you followed the example, you already have this.
177
178Once vcver is called, a VERSION file is created in the current working
179directory, which is typically the same directory as where the setup.py lives
180(you can make it more accurate, see the example)
181
182vcver will attempt to find a VERSION file if the working directory is
183not a version control repository. Make sure your package includes a
184VERSION file by creating/modifying the
185`MANIFEST.in <https://docs.python.org/2/distutils/sourcedist.html#the-manifest-in-template>`_:
186
187.. code-block::
188
189   include VERSION
190
191
192Customizable Version Strings
193============================
194
195Both the version format and release format is configurable, with the
196arguments version_format and release_version_format, respectively.
197
198In addition to the values above, the following values are provided:
199
200* tag_version: the raw version of main_version, which does not zero
201  out for non-release branches.
202
203
204
205Pre-PEP440 Version
206==================
207
208Some (much older) versions of setuptools are unable to consume the dev version string,
209due to the plus in the version string.
210
211If you need backwards compatibility and you would still like vc versioning, the
212following format is recommended:
213
214.. code-block::
215
216      {main_version}.dev{commit_count}.{branch}.{scm_change_id}
217
218 This can be changed by an argument into vcver:
219
220.. code-block:: python
221
222    # in the setup call of setup.py
223    vcver={"version_format": "{main_version}.dev{commit_count}.{branch}.{scm_change_id}"}
224
225Compatibility with Semantic Versioning
226======================================
227
228`Semantic versioning <http://semver.org/>`_ is a standard to provided a
229meaning to the major, minor, and patch versions of a version
230string. Compatibility with semver is possible if new major / minor
231versions are tagged according the semver spec.
232
233--------------
234Special Thanks
235--------------
236
237- `Zillow <http://www.zillow.com/jobs/>`_, where this particular approach of SCM-based versioning was developed
238- `Taylor McKay <https://github.com/tmckay>`_,  who implemented the original Python version at Zillow
239- `Mohammad Sarhan <https://github.com/sarhanm>`_, who designed and implemented the original Java version at Zillow, and has a public `gradle variant <https://github.com/sarhanm/gradle-versioner>`_
240