/
setup.py
181 lines (160 loc) · 5.53 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# -*- mode: python; coding: utf-8 -*-
# Copyright (c) 2018 Radio Astronomy Software Group
# Licensed under the 2-clause BSD License
import glob
import io
import os
import platform
import sys
from sysconfig import get_config_var
import numpy
from Cython.Build import cythonize
from packaging.version import parse
from setuptools import Extension, find_namespace_packages, setup
# add pyuvdata to our path in order to use the branch_scheme function
sys.path.append("pyuvdata")
from branch_scheme import branch_scheme # noqa
with io.open("README.md", "r", encoding="utf-8") as readme_file:
readme = readme_file.read()
def is_platform_mac():
return sys.platform == "darwin"
def is_platform_windows():
return sys.platform == "win32"
# For mac, ensure extensions are built for macos 10.9 when compiling on a
# 10.9 system or above, overriding distuitls behaviour which is to target
# the version that python was built for. This may be overridden by setting
# MACOSX_DEPLOYMENT_TARGET before calling setup.py
# implementation based on pandas, see https://github.com/pandas-dev/pandas/issues/23424
if is_platform_mac():
if "MACOSX_DEPLOYMENT_TARGET" not in os.environ:
current_system = parse(platform.mac_ver()[0])
python_target = parse(get_config_var("MACOSX_DEPLOYMENT_TARGET"))
if python_target < parse("10.9") and current_system >= parse("10.9"):
os.environ["MACOSX_DEPLOYMENT_TARGET"] = "10.9"
# define the cython compile args, depending on platform
if is_platform_windows():
extra_compile_args = ["/Ox", "/openmp"]
extra_link_args = ["/openmp"]
elif is_platform_mac():
extra_compile_args = ["-O3"]
extra_link_args = []
else:
extra_compile_args = ["-O3", "-fopenmp"]
extra_link_args = ["-fopenmp"]
global_c_macros = [("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")]
miriad_extension = Extension(
"pyuvdata._miriad",
sources=[
"pyuvdata/uvdata/src/miriad_wrap.pyx",
"pyuvdata/uvdata/src/uvio.c",
"pyuvdata/uvdata/src/hio.c",
"pyuvdata/uvdata/src/pack.c",
"pyuvdata/uvdata/src/bug.c",
"pyuvdata/uvdata/src/dio.c",
"pyuvdata/uvdata/src/headio.c",
"pyuvdata/uvdata/src/maskio.c",
],
define_macros=global_c_macros,
include_dirs=["pyuvdata/uvdata/src/", numpy.get_include()],
)
corr_fits_extension = Extension(
"pyuvdata._corr_fits",
sources=["pyuvdata/uvdata/corr_fits.pyx"],
define_macros=global_c_macros,
include_dirs=[numpy.get_include()],
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
)
utils_extension = Extension(
"pyuvdata._utils",
sources=["pyuvdata/utils.pyx"],
define_macros=global_c_macros,
include_dirs=[numpy.get_include()],
extra_compile_args=extra_compile_args,
)
uvbeam_extension = Extension(
"pyuvdata._uvbeam",
sources=["pyuvdata/uvbeam/uvbeam.pyx"],
define_macros=global_c_macros,
include_dirs=[numpy.get_include()],
extra_compile_args=extra_compile_args,
)
extensions = [corr_fits_extension, utils_extension, uvbeam_extension]
# don't build miriad on windows
if not is_platform_windows():
extensions.append(miriad_extension)
astroquery_reqs = ["astroquery>=0.4.4"]
casa_reqs = ["python-casacore>=3.5.2"]
hdf5_compression_reqs = ["hdf5plugin>=3.2.0"]
healpix_reqs = ["astropy_healpix>=1.0.2"]
lunar_reqs = ["lunarsky>=0.2.2"]
novas_reqs = ["novas", "novas_de405"]
all_optional_reqs = (
astroquery_reqs
+ casa_reqs
+ hdf5_compression_reqs
+ healpix_reqs
+ lunar_reqs
+ novas_reqs
)
test_reqs = all_optional_reqs + [
"pytest>=6.2.5",
"pytest-xdist",
"pytest-cases>=3.8.3",
"pytest-cov",
"cython>=3.0",
"coverage",
"pre-commit",
]
doc_reqs = ["matplotlib", "sphinx", "pypandoc"]
setup_args = {
"name": "pyuvdata",
"author": "Radio Astronomy Software Group",
"url": "https://github.com/RadioAstronomySoftwareGroup/pyuvdata",
"license": "BSD",
"description": "an interface for astronomical interferometeric datasets in python",
"long_description": readme,
"long_description_content_type": "text/markdown",
"package_dir": {"pyuvdata": "pyuvdata"},
"packages": find_namespace_packages(),
"ext_modules": cythonize(extensions, language_level=3),
"scripts": [fl for fl in glob.glob("scripts/*") if not os.path.isdir(fl)],
"use_scm_version": {"local_scheme": branch_scheme},
"include_package_data": True,
"python_requires": ">=3.10",
"install_requires": [
"astropy>=6.0",
"docstring-parser>=0.15",
"h5py>=3.4",
"numpy>=1.23",
"pyerfa>=2.0.1.1",
"pyyaml>=5.4.1",
"scipy>=1.7.3",
"setuptools>=61",
"setuptools_scm!=7.0.0,!=7.0.1,!=7.0.2",
],
"extras_require": {
"astroquery": astroquery_reqs,
"casa": casa_reqs,
"hdf5_compression": hdf5_compression_reqs,
"healpix": healpix_reqs,
"lunar": lunar_reqs,
"novas": novas_reqs,
"all": all_optional_reqs,
"test": test_reqs,
"doc": doc_reqs,
"dev": test_reqs + doc_reqs,
},
"classifiers": [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering :: Astronomy",
],
"keywords": "radio astronomy interferometry",
}
if __name__ == "__main__":
setup(**setup_args)