1{ lib
2, stdenv
3, buildPythonPackage
4, fetchFromGitHub
5, fetchpatch
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 = {
36 SETUPTOOLS_SCM_PRETEND_VERSION = version;
37 } // lib.optionalAttrs stdenv.cc.isClang {
38 # Try to remove on next update. generated code returns a NULL in a
39 # function where an int is expected.
40 NIX_CFLAGS_COMPILE = "-Wno-error=int-conversion";
41 };
42
43 propagatedBuildInputs = [
44 astropy
45 numpy
46 pyparsing
47 ];
48
49 nativeBuildInputs = [
50 cython
51 oldest-supported-numpy
52 setuptools
53 setuptools-scm
54 wheel
55 ];
56
57 nativeCheckInputs = [ pytestCheckHook pytest-astropy ];
58
59 # Tests must be run in the build directory
60 preCheck = ''
61 pushd build/lib.*
62 '';
63 postCheck = ''
64 popd
65 '';
66
67 meta = with lib; {
68 changelog = "https://github.com/astropy/pyregion/blob/${version}/CHANGES.rst";
69 description = "Python parser for ds9 region files";
70 homepage = "https://github.com/astropy/pyregion";
71 license = licenses.mit;
72 maintainers = [ maintainers.smaret ];
73 };
74}