diff --git a/doc/conf.py b/doc/conf.py index 90ee937..5d7674c 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -27,7 +27,7 @@ print('python exec:', sys.executable) print('sys.path:', sys.path) -print('xbatcher.version:', xbatcher.version) +print('xbatcher.version:', xbatcher.__version__) # -- General configuration ------------------------------------------------ @@ -50,6 +50,7 @@ 'IPython.sphinxext.ipython_directive', 'IPython.sphinxext.ipython_console_highlighting', 'sphinx_autosummary_accessors', + 'sphinx_copybutton', ] # never execute notebooks: avoids lots of expensive imports on rtd @@ -98,9 +99,9 @@ def setup(app): # built documents. # # The short X.Y version. -version = '0.1' +version = xbatcher.__version__ # The full version, including alpha/beta/rc tags. -release = '0.1' +release = xbatcher.__version__ # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/doc/environment.yml b/doc/environment.yml index 9912708..73115d1 100644 --- a/doc/environment.yml +++ b/doc/environment.yml @@ -1,4 +1,7 @@ name: xbatcher +channels: + - conda-forge + - nodefaults dependencies: - python=3.7 - dask @@ -11,4 +14,6 @@ dependencies: - pytest - sphinx - sphinx-autosummary-accessors + - sphinx-copybutton - xarray + - pip diff --git a/doc/index.rst b/doc/index.rst index 4cb67fc..ffe8365 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -10,10 +10,17 @@ such as Keras_. Installation ------------ -No package yet. Install from git: +Xbatcher can be installed from PyPI as:: - pip install git+https://github.com/rabernat/xbatcher.git + pip install xbatcher +Or via Conda as:: + + conda install -c conda-forge xbatcher + +Or from source as:: + + pip install git+https://github.com/pangeo-data/xbatcher.git Basic Usage ----------- diff --git a/setup.cfg b/setup.cfg index 28fbeb3..959a2fb 100644 --- a/setup.cfg +++ b/setup.cfg @@ -7,7 +7,7 @@ select = B,C,E,F,W,T4,B9 [isort] known_first_party=xbatcher -known_third_party=numpy,pytest,setuptools,sphinx_autosummary_accessors,xarray +known_third_party=numpy,pkg_resources,pytest,setuptools,sphinx_autosummary_accessors,xarray multi_line_output=3 include_trailing_comma=True force_grid_wrap=0 diff --git a/setup.py b/setup.py index bb88194..685f7b9 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,6 @@ from setuptools import find_packages, setup -VERSION = '0.1.0' DISTNAME = 'xbatcher' LICENSE = 'Apache' AUTHOR = 'xbatcher Developers' @@ -39,7 +38,6 @@ setup( name=DISTNAME, - version=VERSION, license=LICENSE, author=AUTHOR, author_email=AUTHOR_EMAIL, @@ -50,4 +48,9 @@ install_requires=install_requires, url=URL, packages=find_packages(), + use_scm_version={ + 'version_scheme': 'post-release', + 'local_scheme': 'dirty-tag', + }, + setup_requires=['setuptools_scm', 'setuptools>=30.3.0'], ) diff --git a/xbatcher/__init__.py b/xbatcher/__init__.py index 69e3948..957e078 100644 --- a/xbatcher/__init__.py +++ b/xbatcher/__init__.py @@ -1,2 +1,10 @@ +from pkg_resources import DistributionNotFound, get_distribution + from .accessors import BatchAccessor # noqa: F401 from .generators import BatchGenerator # noqa: F401 + +try: + __version__ = get_distribution(__name__).version +except DistributionNotFound: # noqa: F401; pragma: no cover + # package is not installed + pass