Skip to content

Commit

Permalink
Merge 55cbf64 into 090adf9
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Miles committed May 2, 2019
2 parents 090adf9 + 55cbf64 commit ec033be
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
3 changes: 1 addition & 2 deletions pymcmcstat/__init__.py
@@ -1,2 +1 @@
from .__version__ import __version__
print('pymcmcstat version: {}'.format(__version__))
__version__ = "1.7.1"
1 change: 0 additions & 1 deletion pymcmcstat/__version__.py

This file was deleted.

20 changes: 14 additions & 6 deletions setup.py
@@ -1,5 +1,7 @@
from setuptools import setup, find_packages
import codecs
import os
import re

def read(fname):
with codecs.open(fname, 'r', 'latin') as f:
Expand All @@ -11,15 +13,21 @@ def read(fname):
with codecs.open(path.join(this_directory, 'README.rst'), encoding='utf-8') as f:
long_description = f.read()

# read in version number
version_dummy = {}
exec(read('pymcmcstat/__version__.py'), version_dummy)
__version__ = version_dummy['__version__']
del version_dummy

def get_version():
VERSIONFILE = os.path.join('pymcmcstat', '__init__.py')
with open(VERSIONFILE, 'rt') as f:
lines = f.readlines()
vgx = '^__version__ = \"\d+\.\d+\.\d.*\"'
for line in lines:
mo = re.search(vgx, line, re.M)
if mo:
return mo.group().split('"')[1]
raise RuntimeError('Unable to find version in %s.' % (VERSIONFILE,))

setup(
name='pymcmcstat',
version=__version__,
version=get_version(),
description=('A library to perform MCMC simulations using DRAM'),
long_description=long_description,
url='https://github.com/prmiles/pymcmcstat',
Expand Down
14 changes: 14 additions & 0 deletions test/test_init.py
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-

import unittest
import pymcmcstat


class ImportPymcmcstat(unittest.TestCase):

def test_version_attribute(self):
version = pymcmcstat.__version__
self.assertTrue(isinstance(version, str),
msg='Expect string output')
self.assertEqual(len(version.split('.')), 3,
msg='Expect #.#.# format')

0 comments on commit ec033be

Please sign in to comment.