forked from radiocosmology/caput
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
96 lines (79 loc) · 2.66 KB
/
setup.py
File metadata and controls
96 lines (79 loc) · 2.66 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
# === Start Python 2/3 compatibility
from __future__ import absolute_import, division, print_function, unicode_literals
from future.builtins import * # noqa pylint: disable=W0401, W0614
from future.builtins.disabled import * # noqa pylint: disable=W0401, W0614
# === End Python 2/3 compatibility
from future.utils import bytes_to_native_str
import os
import re
import sysconfig
import numpy
from Cython.Build import cythonize
from setuptools import setup, find_packages
from setuptools.extension import Extension
from caput import __version__
REQUIRES = ["numpy>=1.16", "h5py", "PyYAML", "cython", "future"]
# Don't install requirements if on ReadTheDocs build system.
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
if on_rtd:
requires = []
else:
requires = REQUIRES
# Try and install Skyfield data
try:
from caput import time as ctime
# Force download of data
sf = ctime.SkyfieldWrapper(ephemeris="http://e-mode.phas.ubc.ca/~jrs65/de421.bsp")
sf.reload()
# Set package data to be installed alongside skyfield
skyfield_data = {
# TODO: Py3 remove this hack needed to work around a setuptools bug
bytes_to_native_str(b"caput"): [
"data/Leap_Second.dat",
"data/de421.bsp",
"data/deltat.data",
"data/deltat.preds",
]
}
print("Successfully cached skyfield data.")
except Exception as e:
import warnings
warnings.warn("Could not install additional Skyfield data: %s" % str(e))
skyfield_data = {}
# Cython
# Decide whether to use OpenMP or not
if ("CAPUT_NO_OPENMP" in os.environ) or (
re.search("gcc", sysconfig.get_config_var("CC")) is None
):
print("Not using OpenMP")
omp_args = []
else:
omp_args = ["-fopenmp"]
extensions = [
Extension(
name=bytes_to_native_str(b"caput.weighted_median"),
sources=[bytes_to_native_str(b"caput/weighted_median.pyx")],
include_dirs=[numpy.get_include()],
language="c++",
extra_compile_args=(omp_args + ["-std=c++11", "-g0", "-O3"]),
extra_link_args=(omp_args + ["-std=c++11"]),
)
]
setup(
name="caput",
version=__version__,
packages=find_packages(),
scripts=["scripts/caput-pipeline"],
install_requires=requires,
extras_require={"mpi": ["mpi4py>=1.3"]},
setup_requires=["cython"],
package_data=skyfield_data,
# metadata for upload to PyPI
author="Kiyo Masui, J. Richard Shaw",
author_email="kiyo@physics.ubc.ca",
description="Cluster Astronomical Python Utilities.",
license="GPL v3.0",
url="http://github.com/radiocosmology/caput",
ext_modules=cythonize(extensions),
include_dirs=[numpy.get_include()],
)