1{ lib
2, fetchPypi
3, fetchpatch
4, buildPythonPackage
5, pythonOlder
6
7# build time
8, astropy-extension-helpers
9, cython
10, jinja2
11, oldest-supported-numpy
12, setuptools-scm
13, wheel
14# testing
15, pytestCheckHook
16, pytest-xdist
17, pytest-astropy
18, python
19
20# runtime
21, numpy
22, packaging
23, pyerfa
24, pyyaml
25}:
26
27buildPythonPackage rec {
28 pname = "astropy";
29 version = "5.3.4";
30 format = "pyproject";
31
32 disabled = pythonOlder "3.8"; # according to setup.cfg
33
34 src = fetchPypi {
35 inherit pname version;
36 hash = "sha256-1JD34vqsLMwBySRCAtYpFUJZr4qXkQTO2J3ErOTm8dg=";
37 };
38 # Relax cython dependency to allow this to build, upstream only doesn't
39 # support cython 3 as of writing. See:
40 # https://github.com/astropy/astropy/issues/15315
41 postPatch = ''
42 substituteInPlace pyproject.toml \
43 --replace 'cython==' 'cython>='
44 '';
45
46 nativeBuildInputs = [
47 astropy-extension-helpers
48 cython
49 jinja2
50 oldest-supported-numpy
51 setuptools-scm
52 wheel
53 ];
54
55 propagatedBuildInputs = [
56 numpy
57 packaging
58 pyerfa
59 pyyaml
60 ];
61
62 nativeCheckInputs = [
63 pytestCheckHook
64 pytest-xdist
65 pytest-astropy
66 ];
67
68 # Not running it inside the build directory. See:
69 # https://github.com/astropy/astropy/issues/15316#issuecomment-1722190547
70 preCheck = ''
71 cd "$out"
72 export HOME="$(mktemp -d)"
73 export OMP_NUM_THREADS=$(( $NIX_BUILD_CORES / 4 ))
74 '';
75 pythonImportsCheck = [
76 "astropy"
77 ];
78 disabledTests = [
79 # May fail due to parallelism, see:
80 # https://github.com/astropy/astropy/issues/15441
81 "TestUnifiedOutputRegistry"
82 ];
83
84 meta = {
85 description = "Astronomy/Astrophysics library for Python";
86 homepage = "https://www.astropy.org";
87 license = lib.licenses.bsd3;
88 platforms = lib.platforms.all;
89 maintainers = with lib.maintainers; [ kentjames doronbehar ];
90 };
91}