Skip to content
Snippets Groups Projects
Commit 3b98cdf5 authored by Gregory Ashton's avatar Gregory Ashton
Browse files

Merge branch 'version' into 'master'

Add __version__ module-level attribute

See merge request Monash/bilby!237
parents d4c24a07 4e3bb176
No related branches found
No related tags found
No related merge requests found
...@@ -23,3 +23,5 @@ from . import core, gw, hyper ...@@ -23,3 +23,5 @@ from . import core, gw, hyper
from .core import utils, likelihood, prior, result, sampler from .core import utils, likelihood, prior, result, sampler
from .core.sampler import run_sampler from .core.sampler import run_sampler
from .core.likelihood import Likelihood from .core.likelihood import Likelihood
__version__ = utils.get_version_information()
...@@ -348,15 +348,21 @@ def setup_logger(outdir=None, label=None, log_level='INFO', print_version=False) ...@@ -348,15 +348,21 @@ def setup_logger(outdir=None, label=None, log_level='INFO', print_version=False)
for handler in logger.handlers: for handler in logger.handlers:
handler.setLevel(level) handler.setLevel(level)
version_file = os.path.join(
os.path.dirname(os.path.dirname(__file__)), '.version')
with open(version_file, 'r') as f:
version = f.readline().rstrip()
if print_version: if print_version:
version = get_version_information()
logger.info('Running bilby version: {}'.format(version)) logger.info('Running bilby version: {}'.format(version))
def get_version_information():
version_file = os.path.join(
os.path.dirname(os.path.dirname(__file__)), '.version')
try:
with open(version_file, 'r') as f:
return f.readline().rstrip()
except EnvironmentError:
print("No version information file '.version' found")
def get_progress_bar(module='tqdm'): def get_progress_bar(module='tqdm'):
""" """
TODO: Write proper docstring TODO: Write proper docstring
......
...@@ -18,9 +18,9 @@ ...@@ -18,9 +18,9 @@
# #
import os import os
import sys import sys
import bilby
sys.path.insert(0, os.path.abspath('../bilby/')) sys.path.insert(0, os.path.abspath('../bilby/'))
# -- General configuration ------------------------------------------------ # -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here. # If your documentation needs a minimal Sphinx version, state it here.
...@@ -54,10 +54,13 @@ author = u'Paul Lasky' ...@@ -54,10 +54,13 @@ author = u'Paul Lasky'
# |version| and |release|, also used in various other places throughout the # |version| and |release|, also used in various other places throughout the
# built documents. # built documents.
# #
fullversion = bilby.__version__.split(':')[0]
# The short X.Y version. # The short X.Y version.
version = u'0.2' version = '.'.join(fullversion.split('.')[:2])
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = u'0.2' release = fullversion
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
from setuptools import setup from setuptools import setup
import subprocess import subprocess
from os import path import os
def write_version_file(version): def write_version_file(version):
...@@ -35,7 +35,7 @@ def write_version_file(version): ...@@ -35,7 +35,7 @@ def write_version_file(version):
git_status = '' git_status = ''
version_file = '.version' version_file = '.version'
if path.isfile(version_file) is False: if os.path.isfile(version_file) is False:
with open('bilby/' + version_file, 'w+') as f: with open('bilby/' + version_file, 'w+') as f:
f.write('{}: {}'.format(version, git_status)) f.write('{}: {}'.format(version, git_status))
...@@ -44,14 +44,21 @@ def write_version_file(version): ...@@ -44,14 +44,21 @@ def write_version_file(version):
def get_long_description(): def get_long_description():
""" Finds the README and reads in the description """ """ Finds the README and reads in the description """
here = path.abspath(path.dirname(__file__)) here = os.path.abspath(os.path.dirname(__file__))
with open(path.join(here, 'README.rst')) as f: with open(os.path.join(here, 'README.rst')) as f:
long_description = f.read() long_description = f.read()
return long_description return long_description
version = '0.3.1' # get version info from __init__.py
version_file = write_version_file(version) def readfile(filename):
with open(filename) as fp:
filecontents = fp.read()
return filecontents
VERSION = '0.3.1'
version_file = write_version_file(VERSION)
long_description = get_long_description() long_description = get_long_description()
setup(name='bilby', setup(name='bilby',
...@@ -61,7 +68,7 @@ setup(name='bilby', ...@@ -61,7 +68,7 @@ setup(name='bilby',
author='Greg Ashton, Moritz Huebner, Paul Lasky, Colm Talbot', author='Greg Ashton, Moritz Huebner, Paul Lasky, Colm Talbot',
author_email='paul.lasky@monash.edu', author_email='paul.lasky@monash.edu',
license="MIT", license="MIT",
version=version, version=VERSION,
packages=['bilby', 'bilby.core', 'bilby.core.sampler', packages=['bilby', 'bilby.core', 'bilby.core.sampler',
'bilby.gw', 'bilby.hyper', 'cli_bilby'], 'bilby.gw', 'bilby.hyper', 'cli_bilby'],
package_dir={'bilby': 'bilby'}, package_dir={'bilby': 'bilby'},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment