setup.py 3.82 KB
Newer Older
Gregory Ashton's avatar
Gregory Ashton committed
1 2
#!/usr/bin/env python

Gregory Ashton's avatar
Gregory Ashton committed
3
import os
4
import subprocess
Gregory Ashton's avatar
Gregory Ashton committed
5
import sys
6 7
from pathlib import Path

Gregory Ashton's avatar
Gregory Ashton committed
8
from setuptools import setup
9 10 11

# check that python version is 3.5 or above
python_version = sys.version_info
Gregory Ashton's avatar
Gregory Ashton committed
12
print("Running Python version %s.%s.%s" % python_version[:3])
Isobel Romero-Shaw's avatar
Isobel Romero-Shaw committed
13
if python_version < (3, 5):
Gregory Ashton's avatar
Gregory Ashton committed
14
    sys.exit("Python < 3.5 is not supported, aborting setup")
15
print("Confirmed Python version 3.5.0 or above")
Gregory Ashton's avatar
Gregory Ashton committed
16 17 18 19 20 21 22 23 24 25 26 27 28


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
29 30
        A path to the version file (relative to the bilby_pipe
        package directory)
Gregory Ashton's avatar
Gregory Ashton committed
31
    """
32 33
    version_file = Path("bilby_pipe") / ".version"

Gregory Ashton's avatar
Gregory Ashton committed
34 35
    try:
        git_log = subprocess.check_output(
Gregory Ashton's avatar
Gregory Ashton committed
36 37 38 39 40 41
            ["git", "log", "-1", "--pretty=%h %ai"]
        ).decode("utf-8")
        git_diff = (
            subprocess.check_output(["git", "diff", "."])
            + subprocess.check_output(["git", "diff", "--cached", "."])
        ).decode("utf-8")
42 43 44 45 46 47 48 49 50 51 52 53
    except subprocess.CalledProcessError as exc:  # git calls failed
        # we already have a version file, let's use it
        if version_file.is_file():
            return version_file.name
        # otherwise error out
        exc.args = (
            "unable to obtain git version information, and {} doesn't "
            "exist, cannot continue ({})".format(version_file, str(exc)),
        )
        raise
    else:
        git_version = "{}: ({}) {}".format(
Gregory Ashton's avatar
Gregory Ashton committed
54
            version, "UNCLEAN" if git_diff else "CLEAN", git_log.rstrip()
55 56
        )
        print("parsed git version info as: {!r}".format(git_version))
Gregory Ashton's avatar
Gregory Ashton committed
57

58 59 60
    with open(version_file, "w") as f:
        print(git_version, file=f)
        print("created {}".format(version_file))
Gregory Ashton's avatar
Gregory Ashton committed
61

62
    return version_file.name
Gregory Ashton's avatar
Gregory Ashton committed
63 64 65 66


def get_long_description():
    """ Finds the README and reads in the description """
Gregory Ashton's avatar
Gregory Ashton committed
67
    here = os.path.abspath(os.path.dirname(__file__))
Gregory Ashton's avatar
Gregory Ashton committed
68 69
    with open(os.path.join(here, "README.rst")) as f:
        long_description = f.read()
Gregory Ashton's avatar
Gregory Ashton committed
70 71 72
    return long_description


Gregory Ashton's avatar
Gregory Ashton committed
73
VERSION = "0.2.4"
Gregory Ashton's avatar
Gregory Ashton committed
74
version_file = write_version_file(VERSION)
Gregory Ashton's avatar
Gregory Ashton committed
75 76
long_description = get_long_description()

Gregory Ashton's avatar
Gregory Ashton committed
77 78 79 80 81
setup(
    name="bilby_pipe",
    description="Automating the running of bilby for gravitational wave signals",
    long_description=long_description,
    url="https://lscsoft.docs.ligo.org/bilby_pipe/index.html",
82
    author="Gregory Ashton, Isobel Romero-Shaw, Colm Talbot, Charlie Hoy, Shanika Galaudage",
Gregory Ashton's avatar
Gregory Ashton committed
83 84
    author_email="gregory.ashton@ligo.org",
    license="MIT",
Gregory Ashton's avatar
Gregory Ashton committed
85
    version=VERSION,
Gregory Ashton's avatar
Gregory Ashton committed
86
    package_data={"bilby_pipe": [version_file, "data_files/*"]},
Gregory Ashton's avatar
Gregory Ashton committed
87 88 89 90 91 92
    packages=["bilby_pipe"],
    install_requires=[
        "future",
        "pycondor>=0.5",
        "configargparse",
        "ligo-gracedb",
Gregory Ashton's avatar
Gregory Ashton committed
93
        "bilby>=0.5.4",
94
        "scipy>=1.2.0",
95
        "gwpy",
96 97 98
        "matplotlib",
        "numpy",
        "tqdm",
99
        "corner",
Gregory Ashton's avatar
Gregory Ashton committed
100 101
        "dynesty>=0.9.7",
        "pesummary",
Gregory Ashton's avatar
Gregory Ashton committed
102 103 104 105 106 107 108
    ],
    entry_points={
        "console_scripts": [
            "bilby_pipe=bilby_pipe.main:main",
            "bilby_pipe_generation=bilby_pipe.data_generation:main",
            "bilby_pipe_analysis=bilby_pipe.data_analysis:main",
            "bilby_pipe_create_injection_file=bilby_pipe.create_injections:main",
109
            "bilby_pipe_pp_test=bilby_pipe.pp_test:main",
Gregory Ashton's avatar
Gregory Ashton committed
110
            "bilby_pipe_review=bilby_pipe.review:main",
111
            "bilby_pipe_plot=bilby_pipe.plot:main",
Shanika Galaudage's avatar
Shanika Galaudage committed
112
            "bilby_pipe_gracedb=bilby_pipe.gracedb:main",
Gregory Ashton's avatar
Gregory Ashton committed
113 114 115 116 117 118 119 120 121 122 123
        ]
    },
    classifiers=[
        "Programming Language :: Python :: 3.5",
        "Programming Language :: Python :: 3.6",
        "Programming Language :: Python :: 3.7",
        "License :: OSI Approved :: MIT License",
        "Operating System :: MacOS :: MacOS X",
        "Operating System :: POSIX",
    ],
)