Skip to content

Commit

Permalink
Switch versioning system to use autover (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlstevens authored and philippjfr committed Mar 12, 2018
1 parent 0dd7563 commit 852c2c5
Show file tree
Hide file tree
Showing 8 changed files with 535 additions and 21 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
@@ -0,0 +1,2 @@
__init__.py export-subst
setup.py export-subst
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -71,3 +71,5 @@ target/
.DS_Store
# Website
doc/_build

geoviews/.version
9 changes: 4 additions & 5 deletions conda.recipe/Readme.md → conda.recipe/README.md
Expand Up @@ -2,16 +2,15 @@

- Ensure all tests pass.

- Update version number in `conda.recipe/meta.yaml`, `geoviews/__init__.py`,
and `setup.py`. Commit.

- Tag commit and push to github
- Tag commit a PEP440 style tag (starting with the prefix 'v') and push to github

```bash
git tag -a x.x.x -m 'Version x.x.x'
git tag -a vx.x.x -m 'Version x.x.x'
git push upstream master --tags
```

Example tags might include v1.4.2 v1.5.0a1 or v1.6.5b3

- Build conda packages

The exact procedure is platform/setup specific, so I'll define a few variables
Expand Down
2 changes: 1 addition & 1 deletion conda.recipe/build.sh
Expand Up @@ -4,6 +4,6 @@ SRC_DIR=$RECIPE_DIR/..
pushd $SRC_DIR

$PYTHON setup.py --quiet install --single-version-externally-managed --record=record.txt
cp -r $SRC_DIR/doc/ $PREFIX/share/geoviews-examples/

cp -r $SRC_DIR/notebooks/ $PREFIX/share/geoviews-examples/
popd
6 changes: 4 additions & 2 deletions conda.recipe/meta.yaml
@@ -1,9 +1,11 @@
{% set sdata = load_setup_py_data() %}

package:
name: geoviews
version: 1.4.2
version: {{ sdata['version'] }}

source:
path: .
path: ..

requirements:
build:
Expand Down
12 changes: 8 additions & 4 deletions geoviews/__init__.py
Expand Up @@ -4,8 +4,6 @@
from shutil import copyfile, copytree
from zipfile import ZipFile

import param

from .element import (_Element, Feature, Tiles, # noqa (API import)
WMTS, LineContours, FilledContours, Text, Image,
Points, Path, Polygons, Shape, Dataset, RGB,
Expand All @@ -17,8 +15,14 @@
from . import feature # noqa (API import)


__version__ = param.Version(release=(1,4,2), fpath=__file__,
commit="$Format:%h$", reponame='geoviews')
try:
from version import Version
__version__ = str(Version(fpath=__file__, archive_commit="$Format:%h$",
reponame="geoviews"))
except:
import json
__version__ = json.load(open(os.path.join(os.path.split(__file__)[0],
'.version'), 'r'))['version_string']

SAMPLE_DATA_URL = 'http://assets.holoviews.org/geoviews-sample-data.zip'

Expand Down
46 changes: 37 additions & 9 deletions setup.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python

import os
import sys
try:
from setuptools import setup
except ImportError:
Expand All @@ -17,9 +16,44 @@
extras_require['notebook-dependencies'] = ['jupyter', 'pyzmq', 'jinja2', 'tornado',
'jsonschema', 'ipython', 'pygments']

def embed_version(basepath, ref='v0.2.1'):
"""
Autover is purely a build time dependency in all cases (conda and
pip) except for when you use pip's remote git support [git+url] as
1) you need a dynamically changing version and 2) the environment
starts off clean with zero dependencies installed.
This function acts as a fallback to make Version available until
PEP518 is commonly supported by pip to express build dependencies.
"""
import io, zipfile
try: from urllib.request import urlopen
except: from urllib import urlopen
response = urlopen('https://github.com/ioam/autover/archive/{ref}.zip'.format(ref=ref))
zf = zipfile.ZipFile(io.BytesIO(response.read()))
ref = ref[1:] if ref.startswith('v') else ref
embed_version = zf.read('autover-{ref}/autover/version.py'.format(ref=ref))
with open(os.path.join(basepath, 'version.py'), 'wb') as f:
f.write(embed_version)


def get_setup_version(reponame):
"""
Helper to get the current version from either git describe or the
.version file (if available).
"""
import json, importlib
basepath = os.path.split(__file__)[0]
version_file_path = os.path.join(basepath, reponame, '.version')
version = importlib.import_module("version")
if version is not None:
return version.Version.setup_version(basepath, reponame, archive_commit="$Format:%h$")
else:
print("WARNING: autover unavailable. If you are installing a package, this warning can safely be ignored. If you are creating a package or otherwise operating in a git repository, you should refer to autover's documentation to bundle autover or add it as a dependency.")
return json.load(open(version_file_path, 'r'))['version_string']

setup_args.update(dict(
name='geoviews',
version="1.4.2",
version=get_setup_version("geoviews"),
install_requires = install_requires,
extras_require = extras_require,
description='GeoViews.',
Expand All @@ -34,6 +68,7 @@
"geoviews.plotting",
"geoviews.plotting.bokeh",
"geoviews.plotting.mpl"],
package_data={'geoviews': ['.version']},
classifiers = [
"License :: OSI Approved :: BSD License",
"Development Status :: 1 - Planning Development Status",
Expand All @@ -49,11 +84,4 @@
))

if __name__=="__main__":

if 'GEOVIEWS_RELEASE' in os.environ:

if ('upload' in sys.argv) or ('sdist' in sys.argv):
import geoviews
geoviews.__version__.verify(setup_args['version'])

setup(**setup_args)

0 comments on commit 852c2c5

Please sign in to comment.