1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 pg8000, 6 postgresql, 7 psycopg2, 8 pytestCheckHook, 9 pythonOlder, 10 sqlalchemy, 11 testing-common-database, 12}: 13 14buildPythonPackage rec { 15 pname = "testing-postgresql"; 16 # Version 1.3.0 isn't working so let's use the latest commit from GitHub 17 version = "unstable-2017-10-31"; 18 format = "setuptools"; 19 20 disabled = pythonOlder "3.7"; 21 22 src = fetchFromGitHub { 23 owner = "tk0miya"; 24 repo = "testing.postgresql"; 25 rev = "c81ded434d00ec8424de0f9e1f4063c778c6aaa8"; 26 hash = "sha256-A4tahAaa98X66ZYa3QxIQDZkwAwVB6ZDRObEhkbUWKs="; 27 }; 28 29 propagatedBuildInputs = [ 30 testing-common-database 31 pg8000 32 ]; 33 34 nativeCheckInputs = [ 35 pytestCheckHook 36 psycopg2 37 sqlalchemy 38 ]; 39 40 # Add PostgreSQL to search path 41 prePatch = '' 42 substituteInPlace src/testing/postgresql.py \ 43 --replace "/usr/local/pgsql" "${postgresql}" 44 ''; 45 46 postPatch = '' 47 substituteInPlace setup.py \ 48 --replace "pg8000 >= 1.10" "pg8000" 49 ''; 50 51 pythonImportsCheck = [ "testing.postgresql" ]; 52 53 # Fix tests for Darwin build. See: 54 # https://github.com/NixOS/nixpkgs/pull/74716#issuecomment-598546916 55 __darwinAllowLocalNetworking = true; 56 57 meta = with lib; { 58 description = "Use temporary postgresql instance in testing"; 59 homepage = "https://github.com/tk0miya/testing.postgresql"; 60 license = licenses.asl20; 61 platforms = platforms.linux; 62 maintainers = with maintainers; [ jluttine ]; 63 }; 64}