1{
2 lib,
3 buildPythonPackage,
4 fetchPypi,
5 jinja2,
6 setuptools,
7 setuptools-scm,
8 liberfa,
9 packaging,
10 numpy,
11 pytestCheckHook,
12 pytest-doctestplus,
13}:
14
15buildPythonPackage rec {
16 pname = "pyerfa";
17 version = "2.0.1.4";
18 pyproject = true;
19
20 src = fetchPypi {
21 inherit pname version;
22 hash = "sha256-rLimcTIy6jXAS8bkCsTkYd/MgX05XvKjyAUcGjMkndM=";
23 };
24
25 postPatch = ''
26 substituteInPlace pyproject.toml \
27 --replace-fail "numpy>=2.0.0rc1" "numpy"
28 '';
29
30 build-system = [
31 jinja2
32 packaging
33 setuptools
34 setuptools-scm
35 ];
36
37 dependencies = [ numpy ];
38 buildInputs = [ liberfa ];
39
40 preBuild = ''
41 export PYERFA_USE_SYSTEM_LIBERFA=1
42 '';
43
44 # See https://github.com/liberfa/pyerfa/issues/112#issuecomment-1721197483
45 NIX_CFLAGS_COMPILE = "-O2";
46 nativeCheckInputs = [
47 pytestCheckHook
48 pytest-doctestplus
49 ];
50 # Getting circular import errors without this, not clear yet why. This was mentioned to
51 # upstream at: https://github.com/liberfa/pyerfa/issues/112 and downstream at
52 # https://github.com/NixOS/nixpkgs/issues/255262
53 preCheck = ''
54 cd $out
55 '';
56 pythonImportsCheck = [ "erfa" ];
57
58 meta = with lib; {
59 description = "Python bindings for ERFA routines";
60 longDescription = ''
61 PyERFA is the Python wrapper for the ERFA library (Essential Routines
62 for Fundamental Astronomy), a C library containing key algorithms for
63 astronomy, which is based on the SOFA library published by the
64 International Astronomical Union (IAU). All C routines are wrapped as
65 Numpy universal functions, so that they can be called with scalar or
66 array inputs.
67 '';
68 homepage = "https://github.com/liberfa/pyerfa";
69 license = licenses.bsd3;
70 maintainers = [ maintainers.rmcgibbo ];
71 };
72}