nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
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 = [ "reimport_from_subinterpreter" ]
16 # cython's testsuite is not working very well with libc++
17 # We are however optimistic about things outside of testsuite still working
18 ++ 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 ++ lib.optionals stdenv.isAarch64 [ "numpy_memoryview" ]
23 ++ lib.optionals stdenv.isi686 [ "future_division" "overflow_check_longlong" ]
24 ;
25
26in buildPythonPackage rec {
27 pname = "Cython";
28 version = "0.29.28";
29
30 src = fetchPypi {
31 inherit pname version;
32 sha256 = "sha256-1vrCNCgCww5RQmgo/ghP9N6xszhzZ8+Yl2uy5ktvjkU=";
33 };
34
35 nativeBuildInputs = [
36 pkg-config
37 ];
38
39 checkInputs = [
40 gdb numpy ncurses
41 ];
42
43 buildInputs = [ glibcLocales ];
44 LC_ALL = "en_US.UTF-8";
45
46 patches = [
47 # backport Cython 3.0 trashcan support (https://github.com/cython/cython/pull/2842) to 0.X series.
48 # it does not affect Python code unless the code explicitly uses the feature.
49 # trashcan support is needed to avoid stack overflows during object deallocation in sage (https://trac.sagemath.org/ticket/27267)
50 (fetchpatch {
51 name = "trashcan.patch";
52 url = "https://git.sagemath.org/sage.git/plain/build/pkgs/cython/patches/trashcan.patch?id=4569a839f070a1a38d5dbce2a4d19233d25aeed2";
53 sha256 = "sha256-+pOF1XNTEtNseLpqPzrc1Jfwt5hGx7doUoccIhNneYY=";
54 })
55 ];
56
57 checkPhase = ''
58 export HOME="$NIX_BUILD_TOP"
59 ${python.interpreter} runtests.py -j$NIX_BUILD_CORES \
60 --no-code-style \
61 ${lib.optionalString (builtins.length excludedTests != 0)
62 ''--exclude="(${builtins.concatStringsSep "|" excludedTests})"''}
63 '';
64
65 # https://github.com/cython/cython/issues/2785
66 # Temporary solution
67 doCheck = false;
68 # doCheck = !stdenv.isDarwin;
69
70 meta = {
71 description = "An optimising static compiler for both the Python programming language and the extended Cython programming language";
72 homepage = "https://cython.org";
73 license = lib.licenses.asl20;
74 maintainers = with lib.maintainers; [ fridh ];
75 };
76}