1{ lib
2, buildPythonPackage
3, fetchPypi
4, fetchpatch
5, pyparsing
6, numpy
7, cython
8, astropy
9, astropy-helpers
10, pytest
11, pytest-astropy
12}:
13
14buildPythonPackage rec {
15 pname = "pyregion";
16 version = "2.0";
17
18 src = fetchPypi {
19 inherit pname version;
20 sha256 = "a8ac5f764b53ec332f6bc43f6f2193ca13e8b7d5a3fb2e20ced6b2ea42a9d094";
21 };
22
23 propagatedBuildInputs = [
24 pyparsing
25 numpy
26 cython
27 astropy
28 ];
29
30 # Upstream patch needed for the test to pass
31 patches = [
32 (fetchpatch {
33 name = "conftest-astropy-3-fix.patch";
34 url = "https://github.com/astropy/pyregion/pull/136.patch";
35 sha256 = "13yxjxiqnhjy9gh24hvv6pnwx7qic2mcx3ccr1igjrc3f881d59m";
36 })
37 ];
38
39 nativeBuildInputs = [ astropy-helpers ];
40
41 checkInputs = [ pytest pytest-astropy ];
42
43 # Disable automatic update of the astropy-helper module
44 postPatch = ''
45 substituteInPlace setup.cfg --replace "auto_use = True" "auto_use = False"
46 '';
47
48 # Tests must be run in the build directory
49 checkPhase = ''
50 cd build/lib.*
51 pytest
52 '';
53
54 meta = with lib; {
55 description = "Python parser for ds9 region files";
56 homepage = "https://github.com/astropy/pyregion";
57 license = licenses.mit;
58 maintainers = [ maintainers.smaret ];
59 };
60}