1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchPypi,
6 setuptools,
7 python,
8 pkg-config,
9 gdb,
10 numpy,
11 ncurses,
12
13 # Reverse dependency
14 sage,
15}:
16
17let
18 excludedTests =
19 [ "reimport_from_subinterpreter" ]
20 # cython's testsuite is not working very well with libc++
21 # We are however optimistic about things outside of testsuite still working
22 ++ lib.optionals (stdenv.cc.isClang or false) [
23 "cpdef_extern_func"
24 "libcpp_algo"
25 ]
26 # Some tests in the test suite isn't working on aarch64. Disable them for
27 # now until upstream finds a workaround.
28 # Upstream issue here: https://github.com/cython/cython/issues/2308
29 ++ lib.optionals stdenv.isAarch64 [ "numpy_memoryview" ]
30 ++ lib.optionals stdenv.isi686 [
31 "future_division"
32 "overflow_check_longlong"
33 ];
34in
35buildPythonPackage rec {
36 pname = "cython";
37 version = "3.0.10";
38 pyproject = true;
39
40 src = fetchPypi {
41 pname = "Cython";
42 inherit version;
43 hash = "sha256-3MlnOTMfuFTc9QP5RgdXbP6EiAZsYcpQ39VYNvEy3pk=";
44 };
45
46 build-system = [
47 pkg-config
48 setuptools
49 ];
50
51 nativeCheckInputs = [
52 gdb
53 numpy
54 ncurses
55 ];
56
57 env.LC_ALL = "en_US.UTF-8";
58
59 checkPhase = ''
60 export HOME="$NIX_BUILD_TOP"
61 ${python.interpreter} runtests.py -j$NIX_BUILD_CORES \
62 --no-code-style \
63 ${
64 lib.optionalString (
65 builtins.length excludedTests != 0
66 ) ''--exclude="(${builtins.concatStringsSep "|" excludedTests})"''
67 }
68 '';
69
70 # https://github.com/cython/cython/issues/2785
71 # Temporary solution
72 doCheck = false;
73 # doCheck = !stdenv.isDarwin;
74
75 passthru.tests = {
76 inherit sage;
77 };
78
79 # force regeneration of generated code in source distributions
80 # https://github.com/cython/cython/issues/5089
81 setupHook = ./setup-hook.sh;
82
83 meta = {
84 changelog = "https://github.com/cython/cython/blob/${version}/CHANGES.rst";
85 description = "An optimising static compiler for both the Python programming language and the extended Cython programming language";
86 homepage = "https://cython.org";
87 license = lib.licenses.asl20;
88 };
89}