1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # build-system
8 setuptools-scm,
9
10 # dependencies
11 astropy,
12 casa-formats-io,
13 dask,
14 joblib,
15 numpy,
16 packaging,
17 radio-beam,
18 tqdm,
19
20 # tests
21 aplpy,
22 pytest-astropy,
23 pytestCheckHook,
24}:
25
26buildPythonPackage rec {
27 pname = "spectral-cube";
28 version = "0.6.6-unstable-2025-06-11";
29 pyproject = true;
30
31 src = fetchFromGitHub {
32 owner = "radio-astro-tools";
33 repo = "spectral-cube";
34 # tag = "v${version}";
35 # Unreleased PR with several build and test fixes: https://github.com/radio-astro-tools/spectral-cube/pull/951
36 rev = "f95ba1ca1823758d340ce0bfd3181ae3bc041b93";
37 hash = "sha256-LUWdxA7gfZI2MDpKuk+DiEJtXyWeS8co+3tZt97Uh3w=";
38 };
39
40 # remove after update to 0.6.7
41 env.SETUPTOOLS_SCM_PRETEND_VERSION = "0.6.6";
42
43 build-system = [ setuptools-scm ];
44
45 dependencies = [
46 astropy
47 casa-formats-io
48 dask
49 joblib
50 numpy
51 packaging
52 radio-beam
53 tqdm
54 ]
55 ++ dask.optional-dependencies.array;
56
57 nativeCheckInputs = [
58 aplpy
59 pytest-astropy
60 pytestCheckHook
61 ];
62
63 # Tests must be run in the build directory.
64 preCheck = ''
65 cd build/lib
66 '';
67
68 disabledTests = lib.optionals stdenv.hostPlatform.isDarwin [
69 # Flaky: AssertionError: assert diffvals.max()*u.B <= 1*u.MB
70 "test_reproject_3D_memory"
71 ];
72
73 disabledTestPaths = lib.optionals stdenv.hostPlatform.isDarwin [
74 # On x86_darwin, this test fails with "Fatal Python error: Aborted"
75 # when sandbox = true.
76 "spectral_cube/tests/test_visualization.py"
77 ];
78
79 pythonImportsCheck = [ "spectral_cube" ];
80
81 meta = {
82 description = "Library for reading and analyzing astrophysical spectral data cubes";
83 homepage = "https://spectral-cube.readthedocs.io";
84 changelog = "https://github.com/radio-astro-tools/spectral-cube/releases/tag/v${version}";
85 license = lib.licenses.bsd3;
86 maintainers = with lib.maintainers; [ smaret ];
87 };
88}