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