2020-04-24 23:36:52 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, buildPythonPackage
|
|
|
|
, fetchPypi
|
|
|
|
, fetchpatch
|
|
|
|
, python
|
2020-06-18 07:06:33 +00:00
|
|
|
, pkg-config
|
2020-04-24 23:36:52 +00:00
|
|
|
, gdb
|
|
|
|
, numpy
|
|
|
|
, ncurses
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2021-09-18 10:52:07 +00:00
|
|
|
excludedTests = [ "reimport_from_subinterpreter" ]
|
2020-04-24 23:36:52 +00:00
|
|
|
# cython's testsuite is not working very well with libc++
|
|
|
|
# We are however optimistic about things outside of testsuite still working
|
2021-02-05 17:12:51 +00:00
|
|
|
++ lib.optionals (stdenv.cc.isClang or false) [ "cpdef_extern_func" "libcpp_algo" ]
|
2020-04-24 23:36:52 +00:00
|
|
|
# Some tests in the test suite isn't working on aarch64. Disable them for
|
|
|
|
# now until upstream finds a workaround.
|
|
|
|
# Upstream issue here: https://github.com/cython/cython/issues/2308
|
2021-02-05 17:12:51 +00:00
|
|
|
++ lib.optionals stdenv.isAarch64 [ "numpy_memoryview" ]
|
|
|
|
++ lib.optionals stdenv.isi686 [ "future_division" "overflow_check_longlong" ]
|
2020-04-24 23:36:52 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
in buildPythonPackage rec {
|
2022-07-14 12:49:19 +00:00
|
|
|
pname = "cython";
|
2023-08-04 22:07:22 +00:00
|
|
|
version = "0.29.36";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchPypi {
|
2022-07-14 12:49:19 +00:00
|
|
|
pname = "Cython";
|
|
|
|
inherit version;
|
2023-08-04 22:07:22 +00:00
|
|
|
hash = "sha256-QcDP0tdU44PJ7rle/8mqSrhH0Ml0cHfd18Dctow7wB8=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
2020-06-18 07:06:33 +00:00
|
|
|
pkg-config
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [
|
2021-07-21 07:28:18 +00:00
|
|
|
gdb numpy ncurses
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
LC_ALL = "en_US.UTF-8";
|
|
|
|
|
|
|
|
patches = [
|
2021-03-19 17:17:44 +00:00
|
|
|
# backport Cython 3.0 trashcan support (https://github.com/cython/cython/pull/2842) to 0.X series.
|
|
|
|
# it does not affect Python code unless the code explicitly uses the feature.
|
|
|
|
# trashcan support is needed to avoid stack overflows during object deallocation in sage (https://trac.sagemath.org/ticket/27267)
|
2023-02-16 17:41:37 +00:00
|
|
|
./trashcan.patch
|
2022-11-21 17:40:18 +00:00
|
|
|
# The above commit introduces custom trashcan macros, as well as
|
|
|
|
# compiler changes to use them in Cython-emitted code. The latter
|
|
|
|
# change is still useful, but the former has been upstreamed as of
|
|
|
|
# Python 3.8, and the patch below makes Cython use the upstream
|
|
|
|
# trashcan macros whenever available. This is needed for Python
|
|
|
|
# 3.11 support, because the API used in Cython's implementation
|
|
|
|
# changed: https://github.com/cython/cython/pull/4475
|
|
|
|
(fetchpatch {
|
|
|
|
name = "disable-trashcan.patch";
|
|
|
|
url = "https://github.com/cython/cython/commit/e337825cdcf5e94d38ba06a0cb0188e99ce0cc92.patch";
|
2023-03-15 16:39:30 +00:00
|
|
|
hash = "sha256-q0f63eetKrDpmP5Z4v8EuGxg26heSyp/62OYqhRoSso=";
|
2021-03-19 17:17:44 +00:00
|
|
|
})
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
checkPhase = ''
|
|
|
|
export HOME="$NIX_BUILD_TOP"
|
|
|
|
${python.interpreter} runtests.py -j$NIX_BUILD_CORES \
|
|
|
|
--no-code-style \
|
2021-02-05 17:12:51 +00:00
|
|
|
${lib.optionalString (builtins.length excludedTests != 0)
|
2020-04-24 23:36:52 +00:00
|
|
|
''--exclude="(${builtins.concatStringsSep "|" excludedTests})"''}
|
|
|
|
'';
|
|
|
|
|
|
|
|
# https://github.com/cython/cython/issues/2785
|
|
|
|
# Temporary solution
|
|
|
|
doCheck = false;
|
2021-09-18 10:52:07 +00:00
|
|
|
# doCheck = !stdenv.isDarwin;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-04-12 12:48:02 +00:00
|
|
|
# force regeneration of generated code in source distributions
|
|
|
|
# https://github.com/cython/cython/issues/5089
|
|
|
|
setupHook = ./setup-hook.sh;
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
meta = {
|
2023-02-16 17:41:37 +00:00
|
|
|
changelog = "https://github.com/cython/cython/blob/${version}/CHANGES.rst";
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "An optimising static compiler for both the Python programming language and the extended Cython programming language";
|
|
|
|
homepage = "https://cython.org";
|
|
|
|
license = lib.licenses.asl20;
|
|
|
|
maintainers = with lib.maintainers; [ fridh ];
|
|
|
|
};
|
|
|
|
}
|