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