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