1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5
6 # build-system
7 setuptools,
8
9 # dependencies
10 greenlet,
11
12 # optionals
13 aiomysql,
14 aiosqlite,
15 asyncmy,
16 asyncpg,
17 cx-oracle,
18 mariadb,
19 mypy,
20 mysql-connector,
21 mysqlclient,
22 pg8000,
23 psycopg2,
24 psycopg2cffi,
25 # TODO: pymssql
26 pymysql,
27 pyodbc,
28 # TODO: sqlcipher3
29 typing-extensions,
30
31 # tests
32 mock,
33 pytest-xdist,
34 pytestCheckHook,
35}:
36
37buildPythonPackage rec {
38 pname = "sqlalchemy";
39 version = "1.4.54";
40 pyproject = true;
41
42 src = fetchFromGitHub {
43 owner = "sqlalchemy";
44 repo = "sqlalchemy";
45 rev = "rel_${lib.replaceStrings [ "." ] [ "_" ] version}";
46 hash = "sha256-6qAjyqMVrugABHssAQuql3z1YHTAOSm5hARJuJXJJvo=";
47 };
48
49 postPatch = ''
50 sed -i '/tag_build = dev/d' setup.cfg
51 '';
52
53 nativeBuildInputs = [ setuptools ];
54
55 propagatedBuildInputs = [ greenlet ];
56
57 optional-dependencies = lib.fix (self: {
58 asyncio = [ greenlet ];
59 mypy = [ mypy ];
60 mssql = [ pyodbc ];
61 mssql_pymysql = [
62 # TODO: pymssql
63 ];
64 mssql_pyodbc = [ pyodbc ];
65 mysql = [ mysqlclient ];
66 mysql_connector = [ mysql-connector ];
67 mariadb_connector = [ mariadb ];
68 oracle = [ cx-oracle ];
69 postgresql = [ psycopg2 ];
70 postgresql_pg8000 = [ pg8000 ];
71 postgresql_asyncpg = [ asyncpg ] ++ self.asyncio;
72 postgresql_psycopg2binary = [ psycopg2 ];
73 postgresql_psycopg2cffi = [ psycopg2cffi ];
74 pymysql = [ pymysql ];
75 aiomysql = [ aiomysql ] ++ self.asyncio;
76 asyncmy = [ asyncmy ] ++ self.asyncio;
77 aiosqlite = [
78 aiosqlite
79 typing-extensions
80 ]
81 ++ self.asyncio;
82 sqlcipher = [
83 # TODO: sqlcipher3
84 ];
85 });
86
87 nativeCheckInputs = [
88 pytest-xdist
89 pytestCheckHook
90 mock
91 ];
92
93 disabledTestPaths = [
94 # typing correctness, not interesting
95 "test/ext/mypy"
96 # slow and high memory usage, not interesting
97 "test/aaa_profiling"
98 ];
99
100 pythonImportsCheck = [ "sqlalchemy" ];
101
102 meta = with lib; {
103 changelog = "https://github.com/sqlalchemy/sqlalchemy/releases/tag/rel_${
104 builtins.replaceStrings [ "." ] [ "_" ] version
105 }";
106 description = "Database Toolkit for Python";
107 homepage = "https://github.com/sqlalchemy/sqlalchemy";
108 license = licenses.mit;
109 };
110}