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