-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsetup.py
More file actions
135 lines (116 loc) · 4.01 KB
/
setup.py
File metadata and controls
135 lines (116 loc) · 4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env python
# Copyright (c) 2025, Prayush Kumar
# See LICENSE file for details: <https://github.com/gwnrtools/esigmapy/blob/master/LICENSE>
from __future__ import print_function
from os import environ, path
import subprocess
from pathlib import Path
NAME = "esigmapy"
VERSION = "v2025.03.07"
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 (relative to the src package directory)
"""
version_file = Path(NAME) / ".version"
try:
git_log = subprocess.check_output(
["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")
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(
version, "UNCLEAN" if git_diff else "CLEAN", git_log.rstrip()
)
print("parsed git version info as: {!r}".format(git_version))
try:
with open(version_file, "w") as f:
print(git_version, file=f)
print("created {}".format(version_file))
except:
with open(str(version_file), "w") as f:
print(git_version, file=f)
print("created {}".format(version_file))
return version_file.name
def get_long_description():
"""Finds the README and reads in the description"""
here = path.abspath(path.dirname(__file__))
with open(path.join(here, "README.md")) as f:
long_description = f.read()
return long_description
if "package_version" in environ:
version = environ["package_version"]
print("Setup.py using environment version='{0}'".format(version))
else:
print("The variable 'package_version' was not present in the environment")
try:
from subprocess import check_output
version = (
check_output(
"""git log -1 --format=%cd --date=format:'%Y.%m.%d.%H.%M.%S'""",
shell=use_shell,
)
.decode("ascii")
.rstrip()
)
print("Setup.py using git log version='{0}'".format(version))
except:
from time import strftime, gmtime
version = strftime("%Y.%m.%d.%H.%M.%S", gmtime())
print("Setup.py using strftime version='{0}'".format(version))
if __name__ == "__main__":
from setuptools import setup, find_packages
setup(
name=NAME,
version=VERSION,
description="A collection of tools for generating ESIGMA waveform multipoles and polarizations.",
long_description=get_long_description(),
license="GPL",
url="https://github.com/gwnrtools/esigmapy",
author="Prayush Kumar",
author_email="prayush.kumar@gmail.com",
packages=find_packages(),
package_dir={NAME: NAME},
entry_points={"pycbc.waveform.td": "esigma = esigmapy:pycbc_esigma"},
package_data={},
install_requires=[
# 'lalsuite>=6.63',
"lscsoft_glue>=2.0.0",
"matplotlib>=2.1",
"numpy",
"pycbc",
"scipy>=1.2.3",
],
extras_require={
"surrogate": [
"tpi-splines",
"numba",
],
"pyseobnr": ["pyseobnr"],
"all": [
"tpi-splines",
"numba",
"pyseobnr",
],
},
scripts=[],
)