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