[python-dtcwt] 437/497: move version to one place only

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Tue Jul 21 18:06:36 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch debian/sid
in repository python-dtcwt.

commit 72127d9eea62e40a49b5e94bff3fc4104f0399b9
Author: Rich Wareham <rjw57 at cam.ac.uk>
Date:   Fri Mar 28 16:26:37 2014 +0000

    move version to one place only
    
    Previously the version was a) specified in two places and b) not
    retrievable from the dtcwt module at runtime. Move the version string to
    a single source of truth to fix both of these.
---
 docs/conf.py      |  6 ++++--
 dtcwt/__init__.py | 12 ++++++++----
 dtcwt/_version.py |  2 ++
 setup.cfg         |  2 --
 setup.py          |  8 +++++++-
 5 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/docs/conf.py b/docs/conf.py
index c8bf786..37f71cb 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -21,8 +21,10 @@ setup_cfg.read(os.path.join(os.path.dirname(__file__), '..', 'setup.cfg'))
 
 # Load some data from setup.cfg
 project = setup_cfg.get('metadata', 'name')
-version = setup_cfg.get('metadata', 'version')
-release = setup_cfg.get('metadata', 'version')
+
+# Get the version straight from dtcwt
+import dtcwt
+version = release = dtcwt.__version__
 
 # 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
diff --git a/dtcwt/__init__.py b/dtcwt/__init__.py
index c70c694..ccbd63d 100644
--- a/dtcwt/__init__.py
+++ b/dtcwt/__init__.py
@@ -1,10 +1,9 @@
 import os
 import sys
 
-import dtcwt.numpy
-import dtcwt.opencl
-
 __all__ = [
+    '__version__',
+
     'Transform1d',
     'Transform2d',
     'Transform3d',
@@ -16,6 +15,11 @@ __all__ = [
     'preserve_backend_stack',
 ]
 
+from dtcwt._version import __version__
+
+import dtcwt.numpy
+import dtcwt.opencl
+
 # An array of dictionaries. Each dictionary stores the top-level module
 # variables for that backend.
 _BACKEND_STACK = []
@@ -55,7 +59,7 @@ class _BackendGuard(object):
         # passed to throw(), because __exit__() must not raise
         # an exception unless __exit__() itself failed.  But
         # throw() has to raise the exception to signal
-        # propagation, so this fixes the impedance mismatch 
+        # propagation, so this fixes the impedance mismatch
         # between the throw() protocol and the __exit__()
         # protocol.
         #
diff --git a/dtcwt/_version.py b/dtcwt/_version.py
new file mode 100644
index 0000000..a9a5971
--- /dev/null
+++ b/dtcwt/_version.py
@@ -0,0 +1,2 @@
+# IMPORTANT: before release, remove the 'devN' tag from the release name
+__version__ = '0.10.0dev1'
diff --git a/setup.cfg b/setup.cfg
index 4638f41..0f9e138 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,7 +1,5 @@
 [metadata]
 name = dtcwt
-# IMPORTANT: before release, remove the 'devN' tag from the release name
-version = 0.10.0dev1
 
 [build_sphinx]
 source-dir = docs/
diff --git a/setup.py b/setup.py
index 6342ee5..58c69f4 100644
--- a/setup.py
+++ b/setup.py
@@ -1,4 +1,6 @@
 import os
+import re
+
 from setuptools import setup, find_packages
 
 # Utility function to read the README file.
@@ -8,9 +10,13 @@ from setuptools import setup, find_packages
 def read(fname):
     return open(os.path.join(os.path.dirname(__file__), fname)).read()
 
+# Read metadata from version file
+metadata_file = open(os.path.join(os.path.dirname(__file__), 'dtcwt', '_version.py')).read()
+metadata = dict(re.findall("__([a-z]+)__ = '([^']+)'", metadata_file))
+
 setup(
     name = 'dtcwt',
-    version = '0.10.0dev1',
+    version = metadata['version'],
     author = "Rich Wareham",
     author_email = "rich.dtcwt at richwareham.com",
     description = ("A port of the Dual-Tree Complex Wavelet Transform MATLAB toolbox."),

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-dtcwt.git



More information about the debian-science-commits mailing list