Skip to content

Commit 585b9a7

Browse files
Joe Hammanshoyer
Joe Hamman
authored andcommitted
Versioneer (pydata#2163)
* add versioneer to simplify/standardize package versioning * reorg __init__.py for version import * fix for docs * what is new
1 parent c346d3b commit 585b9a7

10 files changed

+2380
-108
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# reduce the number of merge conflicts
22
doc/whats-new.rst merge=union
3+
xarray/_version.py export-subst

HOW_TO_RELEASE

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,20 @@ Time required: about an hour.
77
2. Look over whats-new.rst and the docs. Make sure "What's New" is complete
88
(check the date!) and add a brief summary note describing the release at the
99
top.
10-
3. Update the version in setup.py and switch to `ISRELEASED = True`.
11-
4. If you have any doubts, run the full test suite one final time!
10+
3. If you have any doubts, run the full test suite one final time!
1211
py.test
13-
5. On the master branch, commit the release in git:
12+
4. On the master branch, commit the release in git:
1413
git commit -a -m 'Release v0.X.Y'
15-
6. Tag the release:
14+
5. Tag the release:
1615
git tag -a v0.X.Y -m 'v0.X.Y'
17-
7. Build source and binary wheels for pypi:
16+
6. Build source and binary wheels for pypi:
1817
python setup.py bdist_wheel sdist
19-
8. Use twine to register and upload the release on pypi. Be careful, you can't
18+
7. Use twine to register and upload the release on pypi. Be careful, you can't
2019
take this back!
2120
twine upload dist/xarray-0.X.Y*
2221
You will need to be listed as a package owner at
2322
https://pypi.python.org/pypi/xarray for this to work.
24-
9. Push your changes to master:
23+
8. Push your changes to master:
2524
git push upstream master
2625
git push upstream --tags
2726
9. Update the stable branch (used by ReadTheDocs) and switch back to master:
@@ -32,25 +31,22 @@ Time required: about an hour.
3231
It's OK to force push to 'stable' if necessary.
3332
We also update the stable branch with `git cherrypick` for documentation
3433
only fixes that apply the current released version.
35-
10. Revert ISRELEASED in setup.py back to False. Don't change the version
36-
number: in normal development, we keep the version number in setup.py as the
37-
last released version.
38-
11. Add a section for the next release (v.X.(Y+1)) to doc/whats-new.rst.
39-
12. Commit your changes and push to master again:
34+
10. Add a section for the next release (v.X.(Y+1)) to doc/whats-new.rst.
35+
11. Commit your changes and push to master again:
4036
git commit -a -m 'Revert to dev version'
4137
git push upstream master
4238
You're done pushing to master!
43-
13. Issue the release on GitHub. Click on "Draft a new release" at
39+
12. Issue the release on GitHub. Click on "Draft a new release" at
4440
https://github.com/pydata/xarray/releases and paste in the latest from
4541
whats-new.rst.
46-
14. Update the docs. Login to https://readthedocs.org/projects/xray/versions/
42+
13. Update the docs. Login to https://readthedocs.org/projects/xray/versions/
4743
and switch your new release tag (at the bottom) from "Inactive" to "Active".
4844
It should now build automatically.
49-
15. Update conda-forge. Clone https://github.com/conda-forge/xarray-feedstock
45+
14. Update conda-forge. Clone https://github.com/conda-forge/xarray-feedstock
5046
and update the version number and sha256 in meta.yaml. (On OS X, you can
5147
calculate sha256 with `shasum -a 256 xarray-0.X.Y.tar.gz`). Submit a pull
5248
request (and merge it, once CI passes).
53-
16. Issue the release announcement! For bug fix releases, I usually only email
49+
15. Issue the release announcement! For bug fix releases, I usually only email
5450
[email protected]. For major/feature releases, I will email a broader
5551
list (no more than once every 3-6 months):
5652

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ recursive-include doc *
44
prune doc/_build
55
prune doc/generated
66
global-exclude .DS_Store
7+
include versioneer.py
8+
include xarray/_version.py

doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
# built documents.
103103
#
104104
# The short X.Y version.
105-
version = xarray.version.short_version
105+
version = xarray.__version__.split('+')[0]
106106
# The full version, including alpha/beta/rc tags.
107107
release = xarray.__version__
108108

doc/whats-new.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ Enhancements
4242
behavior when dimensions are not specified (previously this raised an error).
4343
By `Stephan Hoyer <https://github.com/shoyer>`_
4444

45+
- Xarray now uses `Versioneer <https://github.com/warner/python-versioneer>`__
46+
to manage its version strings. (:issue:`1300`).
47+
By `Joe Hamman <https://github.com/jhamman>`_.
48+
4549
Bug fixes
4650
~~~~~~~~~
4751

setup.cfg

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,14 @@ exclude=
1515
default_section=THIRDPARTY
1616
known_first_party=xarray
1717
multi_line_output=4
18+
19+
[versioneer]
20+
VCS = git
21+
style = pep440
22+
versionfile_source = xarray/_version.py
23+
versionfile_build = xarray/_version.py
24+
tag_prefix =
25+
parentdir_prefix = xarray-
26+
27+
[aliases]
28+
test = pytest

setup.py

Lines changed: 3 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
#!/usr/bin/env python
2-
import os
3-
import re
42
import sys
5-
import warnings
63

74
from setuptools import find_packages, setup
85

9-
MAJOR = 0
10-
MINOR = 10
11-
MICRO = 4
12-
ISRELEASED = False
13-
VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
14-
QUALIFIER = ''
6+
import versioneer
157

168

179
DISTNAME = 'xarray'
@@ -65,83 +57,10 @@
6557
- SciPy2015 talk: https://www.youtube.com/watch?v=X0pAhJgySxk
6658
""" # noqa
6759

68-
# Code to extract and write the version copied from pandas.
69-
# Used under the terms of pandas's license, see licenses/PANDAS_LICENSE.
70-
FULLVERSION = VERSION
71-
write_version = True
72-
73-
if not ISRELEASED:
74-
import subprocess
75-
FULLVERSION += '.dev'
76-
77-
pipe = None
78-
for cmd in ['git', 'git.cmd']:
79-
try:
80-
pipe = subprocess.Popen(
81-
[cmd, "describe", "--always", "--match", "v[0-9]*"],
82-
stdout=subprocess.PIPE)
83-
(so, serr) = pipe.communicate()
84-
if pipe.returncode == 0:
85-
break
86-
except BaseException:
87-
pass
88-
89-
if pipe is None or pipe.returncode != 0:
90-
# no git, or not in git dir
91-
if os.path.exists('xarray/version.py'):
92-
warnings.warn(
93-
"WARNING: Couldn't get git revision,"
94-
" using existing xarray/version.py")
95-
write_version = False
96-
else:
97-
warnings.warn(
98-
"WARNING: Couldn't get git revision,"
99-
" using generic version string")
100-
else:
101-
# have git, in git dir, but may have used a shallow clone (travis does
102-
# this)
103-
rev = so.strip()
104-
# makes distutils blow up on Python 2.7
105-
if sys.version_info[0] >= 3:
106-
rev = rev.decode('ascii')
107-
108-
if not rev.startswith('v') and re.match("[a-zA-Z0-9]{7,9}", rev):
109-
# partial clone, manually construct version string
110-
# this is the format before we started using git-describe
111-
# to get an ordering on dev version strings.
112-
rev = "v%s+dev.%s" % (VERSION, rev)
113-
114-
# Strip leading v from tags format "vx.y.z" to get th version string
115-
FULLVERSION = rev.lstrip('v')
116-
117-
# make sure we respect PEP 440
118-
FULLVERSION = FULLVERSION.replace("-", "+dev", 1).replace("-", ".")
119-
120-
else:
121-
FULLVERSION += QUALIFIER
122-
123-
124-
def write_version_py(filename=None):
125-
cnt = """\
126-
version = '%s'
127-
short_version = '%s'
128-
"""
129-
if not filename:
130-
filename = os.path.join(
131-
os.path.dirname(__file__), 'xarray', 'version.py')
132-
133-
a = open(filename, 'w')
134-
try:
135-
a.write(cnt % (FULLVERSION, VERSION))
136-
finally:
137-
a.close()
138-
139-
140-
if write_version:
141-
write_version_py()
14260

14361
setup(name=DISTNAME,
144-
version=FULLVERSION,
62+
version=versioneer.get_version(),
63+
cmdclass=versioneer.get_cmdclass(),
14564
license=LICENSE,
14665
author=AUTHOR,
14766
author_email=AUTHOR_EMAIL,

0 commit comments

Comments
 (0)