1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 # needed to build
7 cython,
8 oldest-supported-numpy,
9 setuptools,
10 setuptools-scm,
11 wheel,
12 # needed to run
13 astropy,
14 numpy,
15 pyparsing,
16 # needed to check
17 pytestCheckHook,
18 pytest-astropy,
19}:
20
21buildPythonPackage rec {
22 pname = "pyregion";
23 version = "2.2.0";
24 pyproject = true;
25
26 # pypi src contains cython-produced .c files which don't compile
27 # with python3.9
28 src = fetchFromGitHub {
29 owner = "astropy";
30 repo = pname;
31 rev = version;
32 hash = "sha256-r2STKnZwNvonXATrQ5q9NVD9QftlWI1RWl4F+GZSxVg=";
33 };
34
35 env = lib.optionalAttrs stdenv.cc.isClang {
36 # Try to remove on next update. generated code returns a NULL in a
37 # function where an int is expected.
38 NIX_CFLAGS_COMPILE = "-Wno-error=int-conversion";
39 };
40
41 propagatedBuildInputs = [
42 astropy
43 numpy
44 pyparsing
45 ];
46
47 nativeBuildInputs = [
48 cython
49 oldest-supported-numpy
50 setuptools
51 setuptools-scm
52 wheel
53 ];
54
55 nativeCheckInputs = [
56 pytestCheckHook
57 pytest-astropy
58 ];
59
60 # Tests must be run in the build directory
61 preCheck = ''
62 pushd build/lib.*
63 '';
64 postCheck = ''
65 popd
66 '';
67
68 meta = with lib; {
69 changelog = "https://github.com/astropy/pyregion/blob/${version}/CHANGES.rst";
70 description = "Python parser for ds9 region files";
71 homepage = "https://github.com/astropy/pyregion";
72 license = licenses.mit;
73 maintainers = [ maintainers.smaret ];
74 };
75}