summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/sunpy/default.nix
blob: 32c14b3dcc0144c20ee94e1159fa0001f1bcac53 (plain)
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
{
  lib,
  asdf,
  asdf-astropy,
  astropy,
  beautifulsoup4,
  buildPythonPackage,
  contourpy,
  dask,
  drms,
  extension-helpers,
  fetchFromGitHub,
  fsspec,
  glymur,
  h5netcdf,
  h5py,
  hypothesis,
  lxml,
  matplotlib,
  numpy,
  opencv-python,
  packaging,
  pandas,
  parfive,
  pyerfa,
  pytest-astropy,
  pytestCheckHook,
  pytest-mock,
  python-dateutil,
  pythonOlder,
  reproject,
  requests,
  scikit-image,
  scipy,
  setuptools,
  setuptools-scm,
  tqdm,
  writableTmpDirAsHomeHook,
  zeep,
}:

buildPythonPackage rec {
  pname = "sunpy";
  version = "7.0.2";
  pyproject = true;

  disabled = pythonOlder "3.11";

  src = fetchFromGitHub {
    owner = "sunpy";
    repo = "sunpy";
    tag = "v${version}";
    hash = "sha256-1LT6Dr9OZYIZkOICSYD8lt5v3Gn1gZGN4GWeJL6IH5w=";
  };

  # As of 2025-10-15, this requires numpy >=1.25.0,<2.3.
  # (The >=1.25.0 constraint is in dependencies, the <2.3 in build-system)
  # We can't use 1.x because it's not supported on Python 3.13+.
  # And since numpy 2.x is at 2.3.2, it's not supported.
  # However, the upper bound is "for matching the numpy deprecation policy",
  # so relaxing it should be OK. (It silently was overridden previously,
  # due to the use of `format = "setuptools"` instead of `pyproject = true`)
  postPatch = ''
    substituteInPlace pyproject.toml --replace-fail "numpy>=2.0.0rc1,<2.3" "numpy"
  '';

  build-system = [
    extension-helpers
    setuptools
    setuptools-scm # Technically needs setuptools-scm[toml], but that's our default.
    numpy
  ];

  dependencies = [
    astropy
    fsspec
    numpy
    packaging
    parfive
    pyerfa
    requests
  ]
  ++ parfive.optional-dependencies.ftp;

  optional-dependencies = {
    asdf = [
      asdf
      asdf-astropy
    ];
    dask = [ dask ] ++ dask.optional-dependencies.array;
    image = [ scipy ];
    jpeg2000 = [
      glymur
      lxml
    ];
    map = [
      contourpy
      matplotlib
      # mpl-animators
      reproject
      scipy
    ];
    net = [
      beautifulsoup4
      drms
      python-dateutil
      tqdm
      zeep
    ];
    opencv = [ opencv-python ];
    scikit-image = [ scikit-image ];
    # spice = [ spiceypy ];
    timeseries = [
      # cdflib
      h5netcdf
      h5py
      matplotlib
      pandas
    ];
    visualization = [
      matplotlib
      # mpl-animators
    ];

    # We can't use `with` here because "map" would still be the builtin, and
    # we can't below because scikit-image would still be this package's argument.
    core = lib.concatLists [
      optional-dependencies.image
      optional-dependencies.map
      optional-dependencies.net
      optional-dependencies.timeseries
      optional-dependencies.visualization
    ];
    all = lib.concatLists [
      optional-dependencies.core
      optional-dependencies.asdf
      optional-dependencies.jpeg2000
      optional-dependencies.opencv
      # optional-dependencies.spice
      optional-dependencies.scikit-image
    ];
  };

  nativeCheckInputs = [
    hypothesis
    pytest-astropy
    pytestCheckHook
    pytest-mock
    writableTmpDirAsHomeHook
  ]
  ++ optional-dependencies.all;

  disabledTests = [
    "rst" # Docs
    "test_print_params" # Needs to be online
    "test_find_dependencies" # Needs cdflib
    # Needs mpl-animators
    "sunpy.coordinates.utils.GreatArc"
    "test_expand_list_generator_map"
    "test_great_arc_different_observer"
    "test_great_arc_points_differentiates"
    "test_great_arc_wrongly_formatted_points"
    "test_main_exclude_remote_data"
    "test_main_include_remote_data"
    "test_main_nonexisting_module"
    "test_main_only_remote_data"
    "test_main_stdlib_module"
    "test_main_submodule_map"
    "test_tai_seconds"
    "test_utime"
  ];

  disabledTestPaths = [
    # Tests are very slow
    "sunpy/net/tests/test_fido.py"
    "sunpy/net/tests/test_scraper.py"
    # asdf.extensions plugin issue
    "sunpy/io/special/asdf/resources/manifests/*.yaml"
    "sunpy/io/special/asdf/resources/schemas/"
    # Requires mpl-animators
    "sunpy/coordinates/tests/test_wcs_utils.py"
    "sunpy/image/tests/test_resample.py"
    "sunpy/image/tests/test_transform.py"
    "sunpy/io/special/asdf/tests/test_genericmap.py"
    "sunpy/map"
    "sunpy/net/jsoc/tests/test_jsoc.py"
    "sunpy/physics/differential_rotation.py"
    "sunpy/physics/tests/test_differential_rotation.py"
    "sunpy/visualization"
    # Requires cdflib
    "sunpy/io/tests/test_cdf.py"
    "sunpy/timeseries"
    # Requires jplephem
    "sunpy/io/special/asdf/tests/test_coordinate_frames.py"
    # Requires spiceypy
    "sunpy/coordinates/tests/test_spice.py"
  ];

  pytestFlags = [ "-Wignore::DeprecationWarning" ];

  pythonImportsCheck = [ "sunpy" ];

  meta = {
    description = "Python for Solar Physics";
    homepage = "https://sunpy.org";
    license = lib.licenses.bsd2;
    maintainers = [ ];
  };
}