1{ lib
2, apsw
3, buildPythonPackage
4, cython
5, fetchFromGitHub
6, flask
7, python
8, sqlite
9, withMysql ? false
10, mysql-connector
11, withPostgres ? false
12, psycopg2
13, pythonOlder
14}:
15
16buildPythonPackage rec {
17 pname = "peewee";
18 version = "3.17.0";
19 format = "setuptools";
20
21 disabled = pythonOlder "3.7";
22
23 src = fetchFromGitHub {
24 owner = "coleifer";
25 repo = pname;
26 rev = "refs/tags/${version}";
27 hash = "sha256-QbbwC55q/BjMGtm3fH8HPd0aETMzLAFwVYFvOS/4dqA=";
28 };
29
30 buildInputs = [
31 sqlite
32 cython
33 ];
34
35 propagatedBuildInputs = [
36 apsw
37 ] ++ lib.optionals withPostgres [
38 psycopg2
39 ] ++ lib.optionals withMysql [
40 mysql-connector
41 ];
42
43 nativeCheckInputs = [
44 flask
45 ];
46
47 doCheck = withPostgres;
48
49 checkPhase = ''
50 rm -r playhouse # avoid using the folder in the cwd
51 ${python.interpreter} runtests.py
52 '';
53
54 pythonImportsCheck = [
55 "peewee"
56 ];
57
58 meta = with lib; {
59 description = "Python ORM with support for various database implementation";
60 homepage = "http://peewee-orm.com";
61 license = licenses.mit;
62 maintainers = with maintainers; [ ];
63 };
64}