at 23.05-pre 3.0 kB view raw
1{ lib 2, stdenv 3, buildPythonPackage 4, fetchPypi 5, fetchpatch 6, python 7, pkg-config 8, gdb 9, numpy 10, ncurses 11}: 12 13let 14 excludedTests = [ "reimport_from_subinterpreter" ] 15 # cython's testsuite is not working very well with libc++ 16 # We are however optimistic about things outside of testsuite still working 17 ++ lib.optionals (stdenv.cc.isClang or false) [ "cpdef_extern_func" "libcpp_algo" ] 18 # Some tests in the test suite isn't working on aarch64. Disable them for 19 # now until upstream finds a workaround. 20 # Upstream issue here: https://github.com/cython/cython/issues/2308 21 ++ lib.optionals stdenv.isAarch64 [ "numpy_memoryview" ] 22 ++ lib.optionals stdenv.isi686 [ "future_division" "overflow_check_longlong" ] 23 ; 24 25in buildPythonPackage rec { 26 pname = "cython"; 27 version = "0.29.32"; 28 29 src = fetchPypi { 30 pname = "Cython"; 31 inherit version; 32 hash = "sha256-hzPPR1i3kwTypOOev6xekjQbzke8zrJsElQ5iy+MGvc="; 33 }; 34 35 nativeBuildInputs = [ 36 pkg-config 37 ]; 38 39 checkInputs = [ 40 gdb numpy ncurses 41 ]; 42 43 LC_ALL = "en_US.UTF-8"; 44 45 patches = [ 46 # backport Cython 3.0 trashcan support (https://github.com/cython/cython/pull/2842) to 0.X series. 47 # it does not affect Python code unless the code explicitly uses the feature. 48 # trashcan support is needed to avoid stack overflows during object deallocation in sage (https://trac.sagemath.org/ticket/27267) 49 (fetchpatch { 50 name = "trashcan.patch"; 51 url = "https://github.com/cython/cython/commit/f781880b6780117660b2026caadf4a6d7905722f.patch"; 52 sha256 = "sha256-SnjaJdBZxm3O5gJ5Dxut6+eeVtZv+ygUUNwAwgoiFxg="; 53 }) 54 # The above commit introduces custom trashcan macros, as well as 55 # compiler changes to use them in Cython-emitted code. The latter 56 # change is still useful, but the former has been upstreamed as of 57 # Python 3.8, and the patch below makes Cython use the upstream 58 # trashcan macros whenever available. This is needed for Python 59 # 3.11 support, because the API used in Cython's implementation 60 # changed: https://github.com/cython/cython/pull/4475 61 (fetchpatch { 62 name = "disable-trashcan.patch"; 63 url = "https://github.com/cython/cython/commit/e337825cdcf5e94d38ba06a0cb0188e99ce0cc92.patch"; 64 sha256 = "sha256-q0f63eetKrDpmP5Z4v8EuGxg26heSyp/62OYqhRoSso="; 65 }) 66 ]; 67 68 checkPhase = '' 69 export HOME="$NIX_BUILD_TOP" 70 ${python.interpreter} runtests.py -j$NIX_BUILD_CORES \ 71 --no-code-style \ 72 ${lib.optionalString (builtins.length excludedTests != 0) 73 ''--exclude="(${builtins.concatStringsSep "|" excludedTests})"''} 74 ''; 75 76 # https://github.com/cython/cython/issues/2785 77 # Temporary solution 78 doCheck = false; 79 # doCheck = !stdenv.isDarwin; 80 81 meta = { 82 description = "An optimising static compiler for both the Python programming language and the extended Cython programming language"; 83 homepage = "https://cython.org"; 84 license = lib.licenses.asl20; 85 maintainers = with lib.maintainers; [ fridh ]; 86 }; 87}