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.0"; 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 = version; 24 sha256 = "1izar7z606czcyws9s8bjbpb1xhqshpv5009rlpc92hciw7jv4kg"; 25 }; 26 27 propagatedBuildInputs = [ 28 pyparsing 29 numpy 30 astropy 31 ]; 32 33 # Upstream patch needed for the test to pass 34 patches = [ 35 (fetchpatch { 36 name = "conftest-astropy-3-fix.patch"; 37 url = "https://github.com/astropy/pyregion/pull/136.patch"; 38 sha256 = "13yxjxiqnhjy9gh24hvv6pnwx7qic2mcx3ccr1igjrc3f881d59m"; 39 }) 40 ]; 41 42 nativeBuildInputs = [ astropy-helpers cython ]; 43 44 checkInputs = [ pytestCheckHook pytest-astropy ]; 45 46 # Disable automatic update of the astropy-helper module 47 postPatch = '' 48 substituteInPlace setup.cfg --replace "auto_use = True" "auto_use = False" 49 ''; 50 51 # Tests must be run in the build directory 52 preCheck = '' 53 pushd build/lib.* 54 ''; 55 postCheck = '' 56 popd 57 ''; 58 59 meta = with lib; { 60 description = "Python parser for ds9 region files"; 61 homepage = "https://github.com/astropy/pyregion"; 62 license = licenses.mit; 63 maintainers = [ maintainers.smaret ]; 64 }; 65}