1{ lib
2, stdenv
3, buildPythonPackage
4, fetchPypi
5, python
6, glibcLocales
7, pkgconfig
8, gdb
9, numpy
10, ncurses
11, fetchpatch
12}:
13
14let
15 excludedTests = []
16 # cython's testsuite is not working very well with libc++
17 # We are however optimistic about things outside of testsuite still working
18 ++ stdenv.lib.optionals (stdenv.cc.isClang or false) [ "cpdef_extern_func" "libcpp_algo" ]
19 # Some tests in the test suite isn't working on aarch64. Disable them for
20 # now until upstream finds a workaround.
21 # Upstream issue here: https://github.com/cython/cython/issues/2308
22 ++ stdenv.lib.optionals stdenv.isAarch64 [ "numpy_memoryview" ]
23 ++ stdenv.lib.optionals stdenv.isi686 [ "future_division" "overflow_check_longlong" ]
24 ;
25
26in buildPythonPackage rec {
27 pname = "Cython";
28 version = "0.28.3";
29
30 src = fetchPypi {
31 inherit pname version;
32 sha256 = "1aae6d6e9858888144cea147eb5e677830f45faaff3d305d77378c3cba55f526";
33 };
34
35 nativeBuildInputs = [
36 pkgconfig
37 ];
38 checkInputs = [
39 numpy ncurses
40 ];
41 buildInputs = [ glibcLocales gdb ];
42 LC_ALL = "en_US.UTF-8";
43
44 checkPhase = ''
45 export HOME="$NIX_BUILD_TOP"
46 ${python.interpreter} runtests.py -j$NIX_BUILD_CORES \
47 ${stdenv.lib.optionalString (builtins.length excludedTests != 0)
48 ''--exclude="(${builtins.concatStringsSep "|" excludedTests})"''}
49 '';
50
51 doCheck = !stdenv.isDarwin;
52
53 patches = [
54 # The following is in GitHub in 0.28.3 but not in the `sdist`.
55 # https://github.com/cython/cython/issues/2319
56 (fetchpatch {
57 url = https://github.com/cython/cython/commit/c485b1b77264c3c75d090a3c526de24966830d42.patch;
58 sha256 = "1p6jj9rb097kqvhs5j5127sj5zy18l7x9v0p478cjyzh41khh9r0";
59 })
60 ];
61
62 meta = {
63 description = "An optimising static compiler for both the Python programming language and the extended Cython programming language";
64 homepage = http://cython.org;
65 license = lib.licenses.asl20;
66 maintainers = with lib.maintainers; [ fridh ];
67 };
68}