1{ lib
2, buildPythonPackage
3, fetchFromGitHub
4, pythonOlder
5, pytestCheckHook
6, python-dateutil
7, duckdb
8, setuptools-scm
9}:
10buildPythonPackage rec {
11 pname = "sqlglot";
12 version = "17.14.2";
13
14 disabled = pythonOlder "3.8";
15
16 src = fetchFromGitHub {
17 repo = "sqlglot";
18 owner = "tobymao";
19 rev = "v${version}";
20 hash = "sha256-aImshQ5jf0k62ucpK4X8G7uHGAFQkhGgjMYo4mvSvew=";
21 };
22
23 SETUPTOOLS_SCM_PRETEND_VERSION = version;
24
25 nativeBuildInputs = [ setuptools-scm ];
26
27 # optional dependency used in the sqlglot optimizer
28 propagatedBuildInputs = [ python-dateutil ];
29
30 nativeCheckInputs = [ pytestCheckHook duckdb ];
31
32 # these integration tests assume a running Spark instance
33 disabledTestPaths = [ "tests/dataframe/integration" ];
34
35 pythonImportsCheck = [ "sqlglot" ];
36
37 meta = with lib; {
38 description = "A no dependency Python SQL parser, transpiler, and optimizer";
39 homepage = "https://github.com/tobymao/sqlglot";
40 license = licenses.mit;
41 maintainers = with maintainers; [ cpcloud ];
42 };
43}