1{
2 lib,
3 fetchPypi,
4 fetchpatch,
5 buildPythonPackage,
6 pythonOlder,
7
8 # build time
9 stdenv,
10 cython,
11 extension-helpers,
12 setuptools,
13 setuptools-scm,
14
15 # dependencies
16 astropy-iers-data,
17 numpy,
18 packaging,
19 pyerfa,
20 pyyaml,
21
22 # optional-dependencies
23 scipy,
24 matplotlib,
25 ipython,
26 ipywidgets,
27 ipykernel,
28 pandas,
29 certifi,
30 dask,
31 h5py,
32 pyarrow,
33 beautifulsoup4,
34 html5lib,
35 sortedcontainers,
36 pytz,
37 jplephem,
38 mpmath,
39 asdf,
40 asdf-astropy,
41 bottleneck,
42 fsspec,
43 s3fs,
44
45 # testing
46 pytestCheckHook,
47 pytest-xdist,
48 pytest-astropy-header,
49 pytest-astropy,
50 threadpoolctl,
51
52}:
53
54buildPythonPackage rec {
55 pname = "astropy";
56 version = "7.0.1";
57 pyproject = true;
58
59 disabled = pythonOlder "3.11";
60
61 src = fetchPypi {
62 inherit pname version;
63 hash = "sha256-OS/utEOyQ3zUwuBkGmXg8VunkeFI6bHl7X3n38s45GA=";
64 };
65
66 env = lib.optionalAttrs stdenv.cc.isClang {
67 NIX_CFLAGS_COMPILE = "-Wno-error=unused-command-line-argument";
68 };
69
70 build-system = [
71 cython
72 extension-helpers
73 setuptools
74 setuptools-scm
75 ];
76
77 dependencies = [
78 astropy-iers-data
79 numpy
80 packaging
81 pyerfa
82 pyyaml
83 ];
84
85 optional-dependencies = lib.fix (self: {
86 recommended = [
87 scipy
88 matplotlib
89 ];
90 ipython = [
91 ipython
92 ];
93 jupyter = [
94 ipywidgets
95 ipykernel
96 # ipydatagrid
97 pandas
98 ] ++ self.ipython;
99 all =
100 [
101 certifi
102 dask
103 h5py
104 pyarrow
105 beautifulsoup4
106 html5lib
107 sortedcontainers
108 pytz
109 jplephem
110 mpmath
111 asdf
112 asdf-astropy
113 bottleneck
114 fsspec
115 s3fs
116 ]
117 ++ self.recommended
118 ++ self.ipython
119 ++ self.jupyter
120 ++ dask.optional-dependencies.array
121 ++ fsspec.optional-dependencies.http;
122 });
123
124 nativeCheckInputs = [
125 pytestCheckHook
126 pytest-xdist
127 pytest-astropy-header
128 pytest-astropy
129 threadpoolctl
130 ] ++ optional-dependencies.recommended;
131
132 pythonImportsCheck = [ "astropy" ];
133
134 __darwinAllowLocalNetworking = true;
135
136 preCheck = ''
137 export HOME="$(mktemp -d)"
138 export OMP_NUM_THREADS=$(( $NIX_BUILD_CORES / 4 ))
139 # See https://github.com/astropy/astropy/issues/17649 and see
140 # --hypothesis-profile=ci pytest flag below.
141 cp conftest.py $out/
142 # https://github.com/NixOS/nixpkgs/issues/255262
143 cd "$out"
144 '';
145 pytestFlagsArray = [
146 "--hypothesis-profile=ci"
147 ];
148 postCheck = ''
149 rm conftest.py
150 '';
151
152 meta = {
153 description = "Astronomy/Astrophysics library for Python";
154 homepage = "https://www.astropy.org";
155 license = lib.licenses.bsd3;
156 platforms = lib.platforms.all;
157 maintainers = with lib.maintainers; [
158 kentjames
159 doronbehar
160 ];
161 };
162}