at master 3.8 kB view raw
1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 gdb, 6 isPyPy, 7 ncurses, 8 numpy, 9 pkg-config, 10 pygame-ce, 11 python, 12 sage, # Reverse dependency 13 setuptools, 14 stdenv, 15}: 16 17buildPythonPackage rec { 18 pname = "cython"; 19 version = "3.1.2"; 20 pyproject = true; 21 22 src = fetchFromGitHub { 23 owner = "cython"; 24 repo = "cython"; 25 tag = version; 26 hash = "sha256-lP8ILCzAZuoPzFhCqGXwIpifN8XoWz93SJ7c3XVe69Y="; 27 }; 28 29 build-system = [ 30 pkg-config 31 setuptools 32 ]; 33 34 nativeCheckInputs = [ 35 gdb 36 numpy 37 ncurses 38 ]; 39 40 env = lib.optionalAttrs (!isPyPy) { 41 LC_ALL = "en_US.UTF-8"; 42 }; 43 44 # https://github.com/cython/cython/issues/2785 45 # Temporary solution 46 doCheck = false; 47 48 strictDeps = true; 49 50 checkPhase = 51 let 52 excludedTests = [ 53 "reimport_from_subinterpreter" 54 ] 55 # cython's testsuite is not working very well with libc++ 56 # We are however optimistic about things outside of testsuite still working 57 ++ lib.optionals (stdenv.cc.isClang or false) [ 58 "cpdef_extern_func" 59 "libcpp_algo" 60 ] 61 # Some tests in the test suite aren't working on aarch64. 62 # Disable them for now until upstream finds a workaround. 63 # Upstream issue: https://github.com/cython/cython/issues/2308 64 ++ lib.optionals stdenv.hostPlatform.isAarch64 [ "numpy_memoryview" ] 65 ++ lib.optionals stdenv.hostPlatform.isi686 [ 66 "future_division" 67 "overflow_check_longlong" 68 ]; 69 commandline = builtins.concatStringsSep " " ( 70 [ 71 "-j$NIX_BUILD_CORES" 72 "--no-code-style" 73 ] 74 ++ lib.optionals (builtins.length excludedTests != 0) [ 75 ''--exclude="(${builtins.concatStringsSep "|" excludedTests})"'' 76 ] 77 ); 78 in 79 '' 80 runHook preCheck 81 export HOME="$NIX_BUILD_TOP" 82 ${python.interpreter} runtests.py ${commandline} 83 runHook postCheck 84 ''; 85 86 passthru.tests = { 87 inherit pygame-ce sage; 88 }; 89 90 # Force code regeneration in source distributions 91 # https://github.com/cython/cython/issues/5089 92 setupHook = ./setup-hook.sh; 93 94 meta = { 95 homepage = "https://cython.org"; 96 description = "Optimising static compiler for both the Python and the extended Cython programming languages"; 97 longDescription = '' 98 Cython is an optimising static compiler for both the Python programming 99 language and the extended Cython programming language (based on Pyrex). It 100 makes writing C extensions for Python as easy as Python itself. 101 102 Cython gives you the combined power of Python and C to let you: 103 104 - write Python code that calls back and forth from and to C or C++ code 105 natively at any point. 106 - easily tune readable Python code into plain C performance by adding 107 static type declarations, also in Python syntax. 108 - use combined source code level debugging to find bugs in your Python, 109 Cython and C code. 110 - interact efficiently with large data sets, e.g. using multi-dimensional 111 NumPy arrays. 112 - quickly build your applications within the large, mature and widely used 113 CPython ecosystem. 114 - integrate natively with existing code and data from legacy, low-level or 115 high-performance libraries and applications. 116 117 The Cython language is a superset of the Python language that additionally 118 supports calling C functions and declaring C types on variables and class 119 attributes. This allows the compiler to generate very efficient C code 120 from Cython code. 121 ''; 122 changelog = "https://github.com/cython/cython/blob/${version}/CHANGES.rst"; 123 license = lib.licenses.asl20; 124 mainProgram = "cython"; 125 maintainers = with lib.maintainers; [ ]; 126 }; 127} 128# TODO: investigate recursive loop when doCheck is true