summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/sqlalchemy/default.nix
blob: 40c59e716df462f91171b265506dcb71ae2d9b8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
{
  lib,
  isPyPy,
  fetchFromGitHub,
  buildPythonPackage,
  nix-update-script,

  # build
  cython,
  setuptools,

  # propagates
  greenlet,
  typing-extensions,

  # optionals
  aiomysql,
  # TODO: aioodbc
  aiosqlite,
  asyncmy,
  asyncpg,
  cx-oracle,
  mariadb,
  mypy,
  mysql-connector,
  mysqlclient,
  oracledb,
  pg8000,
  psycopg,
  psycopg2,
  psycopg2cffi,
  pymssql,
  pymysql,
  pyodbc,
  sqlcipher3,
  types-greenlet,

  # tests
  mock,
  pytest-xdist,
  pytestCheckHook,
}:

buildPythonPackage rec {
  pname = "sqlalchemy";
  version = "2.0.45";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "sqlalchemy";
    repo = "sqlalchemy";
    tag = "rel_${lib.replaceStrings [ "." ] [ "_" ] version}";
    hash = "sha256-ZAiRR456KkSdXkCiy+TXjdeOJwrLlmVxJfl1x8/XHIs=";
  };

  postPatch = ''
    sed -i '/tag_build = dev/d' setup.cfg
  '';

  build-system = [ setuptools ] ++ lib.optionals (!isPyPy) [ cython ];

  dependencies = [
    greenlet
    typing-extensions
  ];

  optional-dependencies = lib.fix (self: {
    asyncio = [ greenlet ];
    mypy = [
      mypy
      types-greenlet
    ];
    mssql = [ pyodbc ];
    mssql_pymysql = [ pymssql ];
    mssql_pyodbc = [ pyodbc ];
    mysql = [ mysqlclient ];
    mysql_connector = [ mysql-connector ];
    mariadb_connector = [ mariadb ];
    oracle = [ cx-oracle ];
    oracle_oracledb = [ oracledb ];
    postgresql = [ psycopg2 ];
    postgresql_pg8000 = [ pg8000 ];
    postgresql_asyncpg = [ asyncpg ] ++ self.asyncio;
    postgresql_psycopg2binary = [ psycopg2 ];
    postgresql_psycopg2cffi = [ psycopg2cffi ];
    postgresql_psycopg = [ psycopg ];
    postgresql_psycopgbinary = [ psycopg ];
    pymysql = [ pymysql ];
    aiomysql = [ aiomysql ] ++ self.asyncio;
    # TODO: aioodbc
    asyncmy = [ asyncmy ] ++ self.asyncio;
    aiosqlite = [ aiosqlite ] ++ self.asyncio;
    sqlcipher = [ sqlcipher3 ];
  });

  nativeCheckInputs = [
    pytest-xdist
    pytestCheckHook
    mock
  ];

  disabledTestPaths = [
    # typing correctness, not interesting
    "test/ext/mypy"
    "test/typing"
    # slow and high memory usage, not interesting
    "test/aaa_profiling"
  ];

  passthru.updateScript = nix-update-script {
    extraArgs = [
      "--version-regex"
      "^rel_([0-9]+)_([0-9]+)_([0-9]+)$"
    ];
  };

  meta = {
    changelog = "https://github.com/sqlalchemy/sqlalchemy/releases/tag/rel_${
      builtins.replaceStrings [ "." ] [ "_" ] version
    }";
    description = "Python SQL toolkit and Object Relational Mapper";
    homepage = "http://www.sqlalchemy.org/";
    license = lib.licenses.mit;
  };
}