1{
2 lib,
3 fetchPypi,
4 buildPythonPackage,
5 pytestCheckHook,
6 pkgs,
7 awkward,
8 numpy,
9 pybind11,
10 python,
11 setuptools,
12 setuptools-scm,
13 vector,
14}:
15
16let
17 fastjet =
18 (pkgs.fastjet.override {
19 inherit python;
20 withPython = true;
21 }).overrideAttrs
22 (prev: {
23 postInstall =
24 (prev.postInstall or "")
25 + ''
26 mv "$out/${python.sitePackages}/"{fastjet.py,_fastjet_swig.py}
27 '';
28 });
29 fastjet-contrib = pkgs.fastjet-contrib.override {
30 inherit fastjet;
31 };
32in
33
34buildPythonPackage rec {
35 pname = "fastjet";
36 version = "3.4.3.1";
37 pyproject = true;
38
39 src = fetchPypi {
40 pname = "fastjet";
41 inherit version;
42 hash = "sha256-c9LE3axkm3tJt6RfHHIbJZsA/0s2Cl1UqxGKqKvospI=";
43 };
44
45 # unvendor fastjet/fastjet-contrib
46 postPatch = ''
47 substituteInPlace setup.py \
48 --replace-fail 'cmdclass={"build_ext": FastJetBuild, "install": FastJetInstall},' "" \
49 --replace-fail 'str(OUTPUT / "include")' "" \
50 --replace-fail 'str(OUTPUT / "lib")' ""
51 for file in src/fastjet/*.py; do
52 substituteInPlace "$file" \
53 --replace-warn "fastjet._swig" "_fastjet_swig"
54 done
55 sed -i src/fastjet/_pyjet.py -e '1iimport _fastjet_swig'
56 '';
57
58 strictDeps = true;
59
60 build-system = [
61 setuptools
62 setuptools-scm
63 ];
64
65 dependencies = [
66 awkward
67 fastjet
68 numpy
69 vector
70 ];
71
72 buildInputs = [
73 pybind11
74 fastjet-contrib
75 ];
76
77 nativeCheckInputs = [
78 pytestCheckHook
79 ];
80
81 env.SETUPTOOLS_SCM_PRETEND_VERSION = version;
82
83 meta = {
84 description = "Jet-finding in the Scikit-HEP ecosystem";
85 homepage = "https://github.com/scikit-hep/fastjet";
86 changelog = "https://github.com/scikit-hep/fastjet/releases/tag/v${version}";
87 license = lib.licenses.bsd3;
88 maintainers = with lib.maintainers; [ veprbl ];
89 };
90}