1{ lib 2, buildPythonPackage 3, fetchFromGitHub 4, fetchpatch 5, pyparsing 6, numpy 7, cython 8, astropy 9, astropy-helpers 10, pytestCheckHook 11, pytest-astropy 12}: 13 14buildPythonPackage rec { 15 pname = "pyregion"; 16 version = "2.1.1"; 17 18 # pypi src contains cython-produced .c files which don't compile 19 # with python3.9 20 src = fetchFromGitHub { 21 owner = "astropy"; 22 repo = pname; 23 rev = "v${version}"; 24 sha256 = "sha256-xo+XbBJ2HKql9rd7Ma84JofRg8M4u6vmz44Qo8JhEBc="; 25 }; 26 27 propagatedBuildInputs = [ 28 pyparsing 29 numpy 30 astropy 31 ]; 32 33 # Upstream patches needed for the tests to pass 34 # See https://github.com/astropy/pyregion/pull/157/ 35 patches = [ 36 (fetchpatch { 37 url = "https://github.com/astropy/pyregion/pull/157/commits/082649730d353a0d0c0ee9619be1aa501aabba62.patch"; 38 sha256 = "sha256-4mHZt3S29ZfK+QKavm6DLBwVxGl/ga7W7GEcQ5ewxuo="; 39 }) 40 (fetchpatch { 41 url = "https://github.com/astropy/pyregion/pull/157/commits/c448a465dd56887979da62aec6138fc89bb37b19.patch"; 42 sha256 = "sha256-GEtvScmVbAdE4E5Xx0hNOPommvzcnJ3jNZpBmY3PbyE="; 43 }) 44 ]; 45 46 nativeBuildInputs = [ astropy-helpers cython ]; 47 48 checkInputs = [ pytestCheckHook pytest-astropy ]; 49 50 # Disable automatic update of the astropy-helper module 51 postPatch = '' 52 substituteInPlace setup.cfg --replace "auto_use = True" "auto_use = False" 53 ''; 54 55 # Tests must be run in the build directory 56 preCheck = '' 57 pushd build/lib.* 58 ''; 59 postCheck = '' 60 popd 61 ''; 62 63 meta = with lib; { 64 description = "Python parser for ds9 region files"; 65 homepage = "https://github.com/astropy/pyregion"; 66 license = licenses.mit; 67 maintainers = [ maintainers.smaret ]; 68 }; 69}