11
2- # Version: 0.11
2+ # Version: 0.12
33
44"""
55The Versioneer
8888
8989 A project-relative pathname into which the generated version strings should
9090 be written. This is usually a `_version.py` next to your project's main
91- `__init__.py` file. If your project uses `src/myproject/__init__.py`, this
92- should be `src/myproject/_version.py`. This file should be checked in to
93- your VCS as usual: the copy created below by `setup.py versioneer` will
94- include code that parses expanded VCS keywords in generated tarballs. The
95- 'build' and 'sdist' commands will replace it with a copy that has just the
96- calculated version string.
91+ `__init__.py` file, so it can be imported at runtime. If your project uses
92+ `src/myproject/__init__.py`, this should be `src/myproject/_version.py`.
93+ This file should be checked in to your VCS as usual: the copy created below
94+ by `setup.py versioneer` will include code that parses expanded VCS
95+ keywords in generated tarballs. The 'build' and 'sdist' commands will
96+ replace it with a copy that has just the calculated version string.
97+
98+ This must be set even if your project does not have any modules (and will
99+ therefore never import `_version.py`), since "setup.py sdist" -based trees
100+ still need somewhere to record the pre-calculated version strings. Anywhere
101+ in the source tree should do. If there is a `__init__.py` next to your
102+ `_version.py`, the `setup.py versioneer` command (described below) will
103+ append some `__version__`-setting assignments, if they aren't already
104+ present.
97105
98106* `versionfile_build`:
99107
103111 then you will probably have `versionfile_build='myproject/_version.py'` and
104112 `versionfile_source='src/myproject/_version.py'`.
105113
114+ If this is set to None, then `setup.py build` will not attempt to rewrite
115+ any `_version.py` in the built tree. If your project does not have any
116+ libraries (e.g. if it only builds a script), then you should use
117+ `versionfile_build = None` and override `distutils.command.build_scripts`
118+ to explicitly insert a copy of `versioneer.get_version()` into your
119+ generated script.
120+
106121* `tag_prefix`:
107122
108123 a string, like 'PROJECTNAME-', which appears at the start of all VCS tags.
139154 version=versioneer.get_version(),
140155 cmdclass=versioneer.get_cmdclass(),
141156
142- * 4: now run `setup.py versioneer`, which will create `_version.py`, and
143- will modify your `__init__.py` to define `__version__` (by calling a
144- function from `_version.py`). It will also modify your `MANIFEST.in` to
145- include both `versioneer.py` and the generated `_version .py` in sdist
146- tarballs.
157+ * 4: now run `setup.py versioneer`, which will create `_version.py`, and will
158+ modify your `__init__.py` (if one exists next to `_version.py`) to define
159+ `__version__` (by calling a function from `_version.py`). It will also
160+ modify your `MANIFEST.in` to include both `versioneer .py` and the generated
161+ `_version.py` in sdist tarballs.
147162
148163* 5: commit these changes to your VCS. To make sure you won't forget,
149164 `setup.py versioneer` will mark everything it touched for addition.
210225`__init__.py` to place a basic version in `YOURPROJECT.__version__`:
211226
212227 from ._version import get_versions
213- __version = get_versions()['version']
228+ __version__ = get_versions()['version']
214229 del get_versions
215230
216231## Updating Versioneer
231246`setup.py versioneer`. This will enable the use of additional version-control
232247systems (SVN, etc) in the future.
233248
249+ ### Upgrading from 0.11 to 0.12
250+
251+ Nothing special.
252+
234253## Future Directions
235254
236255This tool is designed to make it easily extended to other version-control
@@ -308,7 +327,7 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False):
308327# that just contains the computed version number.
309328
310329# This file is released into the public domain. Generated by
311- # versioneer-0.11 (https://github.com/warner/python-versioneer)
330+ # versioneer-0.12 (https://github.com/warner/python-versioneer)
312331
313332# these strings will be replaced by git during git-archive
314333git_refnames = "%(DOLLAR)sFormat:%%d%(DOLLAR)s"
@@ -584,7 +603,9 @@ def do_vcs_install(manifest_in, versionfile_source, ipy):
584603 GITS = ["git" ]
585604 if sys .platform == "win32" :
586605 GITS = ["git.cmd" , "git.exe" ]
587- files = [manifest_in , versionfile_source , ipy ]
606+ files = [manifest_in , versionfile_source ]
607+ if ipy :
608+ files .append (ipy )
588609 try :
589610 me = __file__
590611 if me .endswith (".pyc" ) or me .endswith (".pyo" ):
@@ -602,7 +623,7 @@ def do_vcs_install(manifest_in, versionfile_source, ipy):
602623 present = True
603624 f .close ()
604625 except EnvironmentError :
605- pass
626+ pass
606627 if not present :
607628 f = open (".gitattributes" , "a+" )
608629 f .write ("%s export-subst\n " % versionfile_source )
@@ -622,7 +643,7 @@ def versions_from_parentdir(parentdir_prefix, root, verbose=False):
622643 return {"version" : dirname [len (parentdir_prefix ):], "full" : "" }
623644
624645SHORT_VERSION_PY = """
625- # This file was generated by 'versioneer.py' (0.11 ) from
646+ # This file was generated by 'versioneer.py' (0.12 ) from
626647# revision-control system data, or from the parent directory name of an
627648# unpacked source archive. Distribution tarballs contain a pre-generated copy
628649# of this file.
@@ -740,11 +761,12 @@ def run(self):
740761 _build .run (self )
741762 # now locate _version.py in the new build/ directory and replace it
742763 # with an updated value
743- target_versionfile = os .path .join (self .build_lib , versionfile_build )
744- print ("UPDATING %s" % target_versionfile )
745- os .unlink (target_versionfile )
746- with open (target_versionfile , "w" ) as f :
747- f .write (SHORT_VERSION_PY % versions )
764+ if versionfile_build :
765+ target_versionfile = os .path .join (self .build_lib , versionfile_build )
766+ print ("UPDATING %s" % target_versionfile )
767+ os .unlink (target_versionfile )
768+ with open (target_versionfile , "w" ) as f :
769+ f .write (SHORT_VERSION_PY % versions )
748770
749771if 'cx_Freeze' in sys .modules : # cx_freeze enabled?
750772 from cx_Freeze .dist import build_exe as _build_exe
@@ -813,17 +835,21 @@ def run(self):
813835 })
814836
815837 ipy = os .path .join (os .path .dirname (versionfile_source ), "__init__.py" )
816- try :
817- with open (ipy , "r" ) as f :
818- old = f .read ()
819- except EnvironmentError :
820- old = ""
821- if INIT_PY_SNIPPET not in old :
822- print (" appending to %s" % ipy )
823- with open (ipy , "a" ) as f :
824- f .write (INIT_PY_SNIPPET )
838+ if os .path .exists (ipy ):
839+ try :
840+ with open (ipy , "r" ) as f :
841+ old = f .read ()
842+ except EnvironmentError :
843+ old = ""
844+ if INIT_PY_SNIPPET not in old :
845+ print (" appending to %s" % ipy )
846+ with open (ipy , "a" ) as f :
847+ f .write (INIT_PY_SNIPPET )
848+ else :
849+ print (" %s unmodified" % ipy )
825850 else :
826- print (" %s unmodified" % ipy )
851+ print (" %s doesn't exist, ok" % ipy )
852+ ipy = None
827853
828854 # Make sure both the top-level "versioneer.py" and versionfile_source
829855 # (PKG/_version.py, used by runtime code) are in MANIFEST.in, so
0 commit comments