Repository: wright-group/WrightTools

Issue:
simplify distribution
- single source for version number
- single source for package description (?)
- script for uploading to PyPI


Discussion:
Consider using hooks (perhaps with keywords) to automate these things, see #57

some ideas to consider: https://packaging.python.org/guides/single-sourcing-package-version/
See also: [Numpy sphinx conf.py](https://github.com/numpy/numpy/blob/master/doc/source/conf.py#L41)

Resolving patch:
diff --git a/WrightTools/__init__.py b/WrightTools/__init__.py
--- a/WrightTools/__init__.py
+++ b/WrightTools/__init__.py
@@ -13,7 +13,9 @@
 # --- temp directory ------------------------------------------------------------------------------
 
 
-_temp_dir = _os.path.join(_os.path.dirname(__file__), 'temp')
+_here = _os.path.abspath(_os.path.dirname(__file__))
+
+_temp_dir = _os.path.join(_here, 'temp')
 if not _os.path.isdir(_temp_dir):
     _os.mkdir(_temp_dir)
 
@@ -35,9 +37,9 @@
 # --- version -------------------------------------------------------------------------------------
 
 
-# MAJOR.MINOR.PATCH (semantic versioning)
-# major version changes may break backwards compatibility
-__version__ = '2.13.4'
+# read from VERSION file
+with open(_os.path.join(_os.path.dirname(_here), 'VERSION')) as _version_file:
+    __version__ = _version_file.read().strip()
 
 # add git branch, if appropriate
 _directory = _os.path.dirname(_os.path.dirname(__file__))
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -13,19 +13,35 @@
 # All configuration values have a default; values that are commented out
 # serve to show the default.
 
-# 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
-# documentation root, use os.path.abspath to make it absolute, like shown here.
-#
+
+# --- import -------------------------------------------------------------------------------------
+
+
 import os
 import sys
 import sphinx_gallery
 import math
 
+
+# --- define -------------------------------------------------------------------------------------
+
+
+here = os.path.abspath(os.path.dirname(__file__))
+
+with open(os.path.join(os.path.dirname(here), 'VERSION')) as version_file:
+    version = version_file.read().strip()
+
+
+# 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
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+
 sys.path.insert(0, os.path.abspath('.'))
 sys.path.insert(0, os.path.abspath('../WrightTools'))
 
-# -- General configuration ------------------------------------------------
+
+# --- general configuration ----------------------------------------------------------------------
+
 
 # If your documentation needs a minimal Sphinx version, state it here.
 #
@@ -69,9 +85,9 @@
 # built documents.
 #
 # The short X.Y version.
-version = '2.13.4'
+version = version
 # The full version, including alpha/beta/rc tags.
-release = '2.13.4'
+release = version
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
@@ -92,7 +108,8 @@
 todo_include_todos = True
 
 
-# -- Options for HTML output ----------------------------------------------
+# -- Options for HTML output ---------------------------------------------------------------------
+
 
 # The theme to use for HTML and HTML Help pages.  See the documentation for
 # a list of builtin themes.
@@ -135,13 +152,15 @@
 }
 
 
-# -- Options for HTMLHelp output ------------------------------------------
+# --- Options for HTMLHelp output ----------------------------------------------------------------
+
 
 # Output file base name for HTML help builder.
 htmlhelp_basename = 'WrightToolsdoc'
 
 
-# -- Options for LaTeX output ---------------------------------------------
+# --- Options for LaTeX output -------------------------------------------------------------------
+
 
 latex_elements = {
     # The paper size ('letterpaper' or 'a4paper').
@@ -170,7 +189,7 @@
 ]
 
 
-# -- Options for manual page output ---------------------------------------
+# --- Options for manual page output -------------------------------------------------------------
 
 # One entry per manual page. List of tuples
 # (source start file, name, description, authors, manual section).
@@ -180,7 +199,8 @@
 ]
 
 
-# -- Options for Texinfo output -------------------------------------------
+# --- Options for Texinfo output -----------------------------------------------------------------
+
 
 # Grouping the document tree into Texinfo files. List of tuples
 # (source start file, target name, title, author,
@@ -192,7 +212,7 @@
 ]
 
 
-# -- gallery --------------------------------------------------------------
+# --- gallery ------------------------------------------------------------------------------------
 
 
 sphinx_gallery_conf = {
@@ -202,13 +222,14 @@
     'download_section_examples': False,
     'backreferences_dir': os.path.join('gen_modules', 'backreferences')}
 
-# -----------------------------------------------------------------------------
-# Plots
-# -----------------------------------------------------------------------------
+# --- plots --------------------------------------------------------------------------------------
+
+
 plot_pre_code = """
 import numpy as np
 np.random.seed(0)
 """
+
 plot_include_source = True
 plot_formats = [('png', 100), 'pdf']
 
@@ -231,12 +252,13 @@
 }
 
 
-# -----------------------------------------------------------------------------
-# Intersphinx configuration
-# -----------------------------------------------------------------------------
+# --- intersphinx configuration ------------------------------------------------------------------
+
+
 intersphinx_mapping = {
     'python': ('https://docs.python.org/3', None),
     'scipy': ('https://docs.scipy.org/doc/scipy/reference', None),
     'matplotlib': ('http://matplotlib.org', None),
     'numpy': ('https://docs.scipy.org/doc/numpy/', None)
 }
+
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -10,7 +10,16 @@ def package_files(directory):
             paths.append(os.path.join('..', path, filename))
     return paths
 
-extra_files = package_files('WrightTools/datasets')
+here = os.path.abspath(os.path.dirname(__file__))
+
+extra_files = package_files(os.path.join(here, 'WrightTools', 'datasets'))
+extra_files.append(os.path.join(here, 'CONTRIBUTORS'))
+extra_files.append(os.path.join(here, 'LICENSE'))
+extra_files.append(os.path.join(here, 'README.rst'))
+extra_files.append(os.path.join(here, 'VERSION'))
+
+with open('VERSION') as version_file:
+    version = version_file.read().strip()
 
 setup(
     name='WrightTools',
@@ -19,13 +28,12 @@ def package_files(directory):
     setup_requires=['pytest-runner'],
     tests_require=['pytest'],
     install_requires=['h5py', 'matplotlib', 'numpy', 'python-dateutil', 'pytz', 'scipy'],
-    version='2.13.4',
+    version=version,
     description='Tools for loading, processing, and plotting multidimensional spectroscopy data.',
     author='Blaise Thompson',
-    license='MIT',
     author_email='blaise@untzag.com',
+    license='MIT',
     url='http://wright.tools',
-    download_url='https://github.com/wright-group/WrightTools/archive/2.13.0.tar.gz',
     keywords='spectroscopy science multidimensional visualization',
     classifiers=['Development Status :: 5 - Production/Stable',
                  'Intended Audience :: Science/Research',


Test patch: