1{
2 lib,
3 fetchPypi,
4 buildPythonPackage,
5 pythonOlder,
6
7 # build time
8 astropy-extension-helpers,
9 cython,
10 setuptools,
11 setuptools-scm,
12
13 # testing
14 pytestCheckHook,
15 stdenv,
16 pytest-xdist,
17 pytest-astropy,
18
19 # runtime
20 astropy-iers-data,
21 numpy,
22 packaging,
23 pyerfa,
24 pyyaml,
25}:
26
27buildPythonPackage rec {
28 pname = "astropy";
29 version = "6.1.4";
30 pyproject = true;
31
32 disabled = pythonOlder "3.10";
33
34 src = fetchPypi {
35 inherit pname version;
36 hash = "sha256-NhVY4rCTqZvr5p8f1H+shqGSYHpMFu05ugqACyq2DDQ=";
37 };
38
39 postPatch = ''
40 substituteInPlace pyproject.toml \
41 --replace-fail "numpy>=2.0.0" "numpy"
42 '';
43
44 build-system = [
45 astropy-extension-helpers
46 cython
47 setuptools
48 setuptools-scm
49 ];
50
51 dependencies = [
52 astropy-iers-data
53 numpy
54 packaging
55 pyerfa
56 pyyaml
57 ];
58
59 nativeCheckInputs = [
60 pytestCheckHook
61 pytest-xdist
62 pytest-astropy
63 ];
64
65 # Not running it inside the build directory. See:
66 # https://github.com/astropy/astropy/issues/15316#issuecomment-1722190547
67 preCheck = ''
68 cd "$out"
69 export HOME="$(mktemp -d)"
70 export OMP_NUM_THREADS=$(( $NIX_BUILD_CORES / 4 ))
71 '';
72 pythonImportsCheck = [ "astropy" ];
73 disabledTests = [
74 # May fail due to parallelism, see:
75 # https://github.com/astropy/astropy/issues/15441
76 "TestUnifiedOutputRegistry"
77
78 # flaky
79 "test_timedelta_conversion"
80 # More flaky tests, see: https://github.com/NixOS/nixpkgs/issues/294392
81 "test_sidereal_lon_independent"
82 "test_timedelta_full_precision_arithmetic"
83 "test_datetime_to_timedelta"
84
85 "test_datetime_difference_agrees_with_timedelta_no_hypothesis"
86
87 # SAMPProxyError 1: 'Timeout expired!'
88 "TestStandardProfile.test_main"
89 ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ "test_sidereal_lat_independent" ];
90
91 meta = {
92 description = "Astronomy/Astrophysics library for Python";
93 homepage = "https://www.astropy.org";
94 license = lib.licenses.bsd3;
95 platforms = lib.platforms.all;
96 maintainers = with lib.maintainers; [
97 kentjames
98 doronbehar
99 ];
100 };
101}