about summary refs log tree commit diff
path: root/pkgs/development/python-modules/pyerfa/default.nix
blob: 68e5f7d97496e2dd6cf85443dbfaa533b01aae3c (plain) (blame)
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
{
  lib,
  buildPythonPackage,
  fetchPypi,
  jinja2,
  setuptools,
  setuptools-scm,
  liberfa,
  packaging,
  numpy,
  pytestCheckHook,
  pytest-doctestplus,
}:

buildPythonPackage rec {
  pname = "pyerfa";
  version = "2.0.1.4";
  pyproject = true;

  src = fetchPypi {
    inherit pname version;
    hash = "sha256-rLimcTIy6jXAS8bkCsTkYd/MgX05XvKjyAUcGjMkndM=";
  };

  postPatch = ''
    substituteInPlace pyproject.toml \
      --replace-fail "numpy>=2.0.0rc1" "numpy"
  '';

  build-system = [
    jinja2
    packaging
    setuptools
    setuptools-scm
  ];

  dependencies = [ numpy ];
  buildInputs = [ liberfa ];

  preBuild = ''
    export PYERFA_USE_SYSTEM_LIBERFA=1
  '';

  # See https://github.com/liberfa/pyerfa/issues/112#issuecomment-1721197483
  NIX_CFLAGS_COMPILE = "-O2";
  nativeCheckInputs = [
    pytestCheckHook
    pytest-doctestplus
  ];
  # Getting circular import errors without this, not clear yet why. This was mentioned to
  # upstream at: https://github.com/liberfa/pyerfa/issues/112 and downstream at
  # https://github.com/NixOS/nixpkgs/issues/255262
  preCheck = ''
    cd $out
  '';
  pythonImportsCheck = [ "erfa" ];

  meta = with lib; {
    description = "Python bindings for ERFA routines";
    longDescription = ''
      PyERFA is the Python wrapper for the ERFA library (Essential Routines
      for Fundamental Astronomy), a C library containing key algorithms for
      astronomy, which is based on the SOFA library published by the
      International Astronomical Union (IAU). All C routines are wrapped as
      Numpy universal functions, so that they can be called with scalar or
      array inputs.
    '';
    homepage = "https://github.com/liberfa/pyerfa";
    license = licenses.bsd3;
    maintainers = [ maintainers.rmcgibbo ];
  };
}