Skip to content

Commit

Permalink
Extract version number from git tag (#72)
Browse files Browse the repository at this point in the history
* Extract version number from git tag

This keeps the version number in the documentation consistent with the code release. Code taken from MITgcm/MITgcm@96334be Closes #71

* Fixing style errors.

* Move import statement to conform with code linter

* Make mds_store test work with xarray >=0.10.1

As noted in #72 an upstream change in xarray broke one of the tests. This commit also modifies dependencies in setup.py to xarray >= 0.10.1
  • Loading branch information
edoddridge authored and rabernat committed Mar 5, 2018
1 parent 1812a68 commit 4b52181
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
30 changes: 26 additions & 4 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import sys
import os
import xmitgcm
from subprocess import check_output, CalledProcessError

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down Expand Up @@ -69,10 +70,31 @@
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.1'
# The full version, including alpha/beta/rc tags.
release = '0.1'


def get_version():
"""
Return the latest tag (checkpoint) and, if there have
been commits since the version was tagged, the commit hash.
To get just the release tag use:
version = version.split('-')[0]
"""

try:
version = check_output(['git', 'describe', '--tags', '--always'],
universal_newlines=True)
except CalledProcessError:
return 'unknown version'

return version.rstrip()


# "version" is used for html build
version = get_version()
# "release" is used for LaTeX build
release = version


# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
'Topic :: Scientific/Engineering',
]

INSTALL_REQUIRES = ['xarray >= 0.8.2', 'dask >= 0.12']
INSTALL_REQUIRES = ['xarray >= 0.10.1', 'dask >= 0.12']
SETUP_REQUIRES = ['pytest-runner']
TESTS_REQUIRE = ['pytest >= 2.8', 'coverage']

Expand Down
2 changes: 1 addition & 1 deletion xmitgcm/mds_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def open_mdsdataset(data_dir, grid_dir=None,
if calendar:
encoding['calendar'] = calendar
del ds.time.attrs['calendar']
ds.time.data = (xr.conventions
ds.time.data = (xr.coding.times
.decode_cf_datetime(ds.time.data, units=units,
calendar=calendar))
# this doesn't seem to have any effect, so we remove it
Expand Down

0 comments on commit 4b52181

Please sign in to comment.