summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/fastjet/default.nix
blob: 08b3098d48255896e36989e6a9ceebcf9d27e624 (plain)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
{
  lib,
  fetchPypi,
  buildPythonPackage,
  pytestCheckHook,
  pkgs,
  awkward,
  numpy,
  pybind11,
  python,
  setuptools,
  setuptools-scm,
  vector,
}:

let
  fastjet =
    (pkgs.fastjet.override {
      inherit python;
      withPython = true;
    }).overrideAttrs
      (prev: {
        postInstall = (prev.postInstall or "") + ''
          mv "$out/${python.sitePackages}/"{fastjet.py,_fastjet_swig.py}
        '';
      });
  fastjet-contrib = pkgs.fastjet-contrib.override {
    inherit fastjet;
  };
in

buildPythonPackage rec {
  pname = "fastjet";
  version = "3.5.1.1";
  pyproject = true;

  src = fetchPypi {
    pname = "fastjet";
    inherit version;
    hash = "sha256-2GG9A+/2rgYpsJo1tu3BprOM7bKwYVV6/qIIMtYSr9o=";
  };

  # unvendor fastjet/fastjet-contrib
  postPatch = ''
    substituteInPlace setup.py \
      --replace-fail 'cmdclass={"build_ext": FastJetBuild, "install": FastJetInstall},' "" \
      --replace-fail 'str(OUTPUT / "include")' "" \
      --replace-fail 'str(OUTPUT / "lib")' ""
    for file in src/fastjet/*.py; do
      substituteInPlace "$file" \
        --replace-warn "fastjet._swig" "_fastjet_swig"
    done
    sed -i src/fastjet/_pyjet.py -e '1iimport _fastjet_swig'
  '';

  strictDeps = true;

  build-system = [
    setuptools
    setuptools-scm
  ];

  dependencies = [
    awkward
    fastjet
    numpy
    vector
  ];

  buildInputs = [
    pybind11
    fastjet-contrib
  ];

  nativeCheckInputs = [
    pytestCheckHook
  ];

  env.SETUPTOOLS_SCM_PRETEND_VERSION = version;

  meta = {
    description = "Jet-finding in the Scikit-HEP ecosystem";
    homepage = "https://github.com/scikit-hep/fastjet";
    changelog = "https://github.com/scikit-hep/fastjet/releases/tag/v${version}";
    license = lib.licenses.bsd3;
    maintainers = with lib.maintainers; [ veprbl ];
  };
}