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