setup.py 2.99 KB
Newer Older
Colm Talbot's avatar
Colm Talbot committed
1 2
#!/usr/bin/env python

3
from setuptools import setup
4
import subprocess
5
import os
6

Gregory Ashton's avatar
Gregory Ashton committed
7

8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
def write_version_file(version):
    """ Writes a file with version information to be used at run time

    Parameters
    ----------
    version: str
        A string containing the current version information

    Returns
    -------
    version_file: str
        A path to the version file

    """
    try:
        git_log = subprocess.check_output(
            ['git', 'log', '-1', '--pretty=%h %ai']).decode('utf-8')
Gregory Ashton's avatar
Gregory Ashton committed
25 26
        git_diff = (subprocess.check_output(['git', 'diff', '.']) +
                    subprocess.check_output(
27 28
                        ['git', 'diff', '--cached', '.'])).decode('utf-8')
        if git_diff == '':
Gregory Ashton's avatar
Gregory Ashton committed
29
            git_status = '(CLEAN) ' + git_log
30
        else:
Gregory Ashton's avatar
Gregory Ashton committed
31 32 33 34 35
            git_status = '(UNCLEAN) ' + git_log
    except Exception as e:
        print("Unable to obtain git version information, exception: {}"
              .format(e))
        git_status = ''
36 37

    version_file = '.version'
38
    if os.path.isfile(version_file) is False:
Colm Talbot's avatar
Colm Talbot committed
39
        with open('bilby/' + version_file, 'w+') as f:
Gregory Ashton's avatar
Gregory Ashton committed
40
            f.write('{}: {}'.format(version, git_status))
41 42 43 44 45 46

    return version_file


def get_long_description():
    """ Finds the README and reads in the description """
47 48
    here = os.path.abspath(os.path.dirname(__file__))
    with open(os.path.join(here, 'README.rst')) as f:
Gregory Ashton's avatar
Gregory Ashton committed
49
        long_description = f.read()
50 51 52
    return long_description


53 54 55 56 57 58 59
# get version info from __init__.py
def readfile(filename):
    with open(filename) as fp:
        filecontents = fp.read()
    return filecontents


Gregory Ashton's avatar
Gregory Ashton committed
60
VERSION = '0.5.2'
61
version_file = write_version_file(VERSION)
62
long_description = get_long_description()
Gregory Ashton's avatar
Gregory Ashton committed
63

Colm Talbot's avatar
Colm Talbot committed
64
setup(name='bilby',
65
      description='A user-friendly Bayesian inference library',
Gregory Ashton's avatar
Gregory Ashton committed
66
      long_description=long_description,
67
      url='https://git.ligo.org/lscsoft/bilby',
68
      author='Greg Ashton, Moritz Huebner, Paul Lasky, Colm Talbot',
Gregory Ashton's avatar
Gregory Ashton committed
69 70
      author_email='paul.lasky@monash.edu',
      license="MIT",
71
      version=VERSION,
Colm Talbot's avatar
Colm Talbot committed
72
      packages=['bilby', 'bilby.core', 'bilby.core.sampler',
73 74
                'bilby.gw', 'bilby.gw.detector', 'bilby.gw.sampler',
                'bilby.hyper', 'cli_bilby'],
Colm Talbot's avatar
Colm Talbot committed
75
      package_dir={'bilby': 'bilby'},
76 77
      package_data={'bilby.gw': ['prior_files/*'],
                    'bilby.gw.detector': ['noise_curves/*.txt', 'detectors/*'],
Colm Talbot's avatar
Colm Talbot committed
78
                    'bilby': [version_file]},
79 80
      install_requires=[
          'future',
Gregory Ashton's avatar
Gregory Ashton committed
81
          'dynesty>=0.9.7',
82
          'corner',
83
          'dill',
84 85
          'numpy>=1.9',
          'matplotlib>=2.0',
86
          'pandas',
87
          'scipy'],
88
      entry_points={'console_scripts':
89 90
                    ['bilby_plot=cli_bilby.plot_multiple_posteriors:main',
                     'bilby_result=cli_bilby.bilby_result:main']
91 92 93 94 95 96
                    },
      classifiers=[
          "Programming Language :: Python :: 2.7",
          "Programming Language :: Python :: 3.7",
          "License :: OSI Approved :: MIT License",
          "Operating System :: OS Independent"])