1{
2 lib,
3 python,
4 buildPythonPackage,
5 fetchFromGitHub,
6 fetchpatch2,
7 substituteAll,
8
9 # build-system
10 setuptools,
11
12 # native dependencies
13 openmp,
14 xsimd,
15
16 # dependencies
17 ply,
18 gast,
19 numpy,
20 beniget,
21}:
22
23let
24 inherit (python) stdenv;
25in
26buildPythonPackage rec {
27 pname = "pythran";
28 version = "0.16.1";
29 pyproject = true;
30
31 src = fetchFromGitHub {
32 owner = "serge-sans-paille";
33 repo = "pythran";
34 rev = "refs/tags/${version}";
35 hash = "sha256-wiQmShniYZmB8hk/MC5FWFf1s5vqEHiYBkXTo4OeZ+E=";
36 };
37
38 patches = [
39 (fetchpatch2 {
40 name = "bump-gast-to-0.6.0.patch";
41 url = "https://github.com/serge-sans-paille/pythran/commit/840a0e706ec39963aec6bcd1f118bf33177c20b4.patch";
42 hash = "sha256-FHGXWuAX/Nmn6uEfQgAXfUxIdApDwSfHHtOStxyme/0=";
43 })
44 # Hardcode path to mp library
45 (substituteAll {
46 src = ./0001-hardcode-path-to-libgomp.patch;
47 gomp = "${
48 if stdenv.cc.isClang then openmp else (lib.getLib stdenv.cc.cc)
49 }/lib/libgomp${stdenv.hostPlatform.extensions.sharedLibrary}";
50 })
51 ];
52
53 # xsimd: unvendor this header-only C++ lib
54 postPatch = ''
55 rm -r pythran/xsimd
56 ln -s '${lib.getDev xsimd}'/include/xsimd pythran/
57 '';
58
59 build-system = [ setuptools ];
60
61 dependencies = [
62 ply
63 gast
64 numpy
65 beniget
66 setuptools
67 ];
68
69 pythonImportsCheck = [
70 "pythran"
71 "pythran.backend"
72 "pythran.middlend"
73 "pythran.passmanager"
74 "pythran.toolchain"
75 "pythran.spec"
76 ];
77
78 # Test suite is huge and has a circular dependency on scipy.
79 doCheck = false;
80
81 meta = {
82 changelog = "https://github.com/serge-sans-paille/pythran/blob/${src.rev}/Changelog";
83 description = "Ahead of Time compiler for numeric kernels";
84 homepage = "https://github.com/serge-sans-paille/pythran";
85 license = lib.licenses.bsd3;
86 maintainers = with lib.maintainers; [ doronbehar ];
87 };
88}