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