-
Notifications
You must be signed in to change notification settings - Fork 29
/
setup.py
120 lines (95 loc) · 3.55 KB
/
setup.py
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
#!/usr/bin/env python
# Future imports
from __future__ import absolute_import, division, print_function
import re
import subprocess
from setuptools import setup, find_packages, Extension
from os import path
import sys
dirpath = path.abspath(path.dirname(__file__))
eh_dir = path.join(dirpath,'cosmolopy','EH')
ext_names = ['power', 'tf_fit']
def generate_swig():
print("Swigging sources")
for d in ext_names:
filename = path.join(eh_dir, d+'.i')
p = subprocess.call(['swig', '-python', filename],
cwd=dirpath)
if p != 0:
raise RuntimeError("Running swig failed!")
# Generate swig if build is requested
for command in ['develop', 'build', 'bdist_wheel', 'build_ext', 'build_src']:
if command in sys.argv[1:]:
generate_swig()
break
# Generate dict of all data files to include
EH_files = []
if 'sdist' in sys.argv[1:]:
for name in ext_names:
EH_files.extend(['%s.c' % (name), '%s.i' % (name)])
package_data = {
'': ['*.txt', '*.rst', 'LISCENSE'],
'cosmolopy.EH': EH_files}
# Create extension modules
ext_mods = []
for name in ext_names:
mod = Extension('cosmolopy.EH._%s' % (name),
sources=[path.join(eh_dir, '%s_wrap.c' % (name)),
path.join(eh_dir, '%s.c' % (name))])
ext_mods.append(mod)
# Get the requirements list
with open(path.join(dirpath, 'requirements.txt'), 'r') as f:
requirements = f.read().splitlines()
# Read the __version__.py file
with open(path.join(dirpath, 'cosmolopy/__version__.py'), 'r') as f:
vf = f.read()
# Obtain version from read-in __version__.py file
version = re.search(r"^_*version_* = ['\"]([^'\"]*)['\"]", vf, re.M).group(1)
setup(
name = "cosmolopy",
version = version,
packages = find_packages(),
install_requires = requirements,
ext_modules = ext_mods,
tests_require = ['nose', 'matplotlib'],
test_suite = 'nose.collector',
platforms=["Windows", "Linux", "Unix"],
# metadata for upload to PyPI
author = "Roban Hultman Kramer",
author_email = "[email protected]",
description = "a cosmology package for Python.",
url = "http://roban.github.com/CosmoloPy/", # project home page
keywords = ("astronomy cosmology cosmological distance density galaxy" +
"luminosity magnitude reionization Press-Schechter Schecter"),
license = "MIT",
python_requires = ">=3.6, <4",
package_data=package_data,
long_description = \
"""CosmoloPy is a package of cosmology routines built on NumPy/SciPy.
Capabilities include
--------------------
`cosmolopy.density`
Various cosmological densities.
`cosmolopy.distance`
Various cosmological distance measures.
`cosmolopy.luminosityfunction`
Galaxy luminosity functions (Schecter functions).
`cosmolopy.magnitudes`
Conversion in and out of the AB magnitude system.
`cosmolopy.parameters`
Pre-defined sets of cosmological parameters (e.g. from WMAP).
`cosmolopy.perturbation`
Perturbation theory and the power spectrum.
`cosmolopy.reionization`
The reionization of the IGM.
""",
classifiers = ['License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Topic :: Scientific/Engineering :: Astronomy',
'Operating System :: OS Independent'
]
)