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