diff --git a/pkgs/by-name/ha/harlequin/package.nix b/pkgs/by-name/ha/harlequin/package.nix index 406aec8e7876..acfedcc450a5 100644 --- a/pkgs/by-name/ha/harlequin/package.nix +++ b/pkgs/by-name/ha/harlequin/package.nix @@ -9,8 +9,8 @@ writableTmpDirAsHomeHook, withPostgresAdapter ? true, withBigQueryAdapter ? true, + withOdbcAdapter ? true, }: - python3Packages.buildPythonApplication (finalAttrs: { pname = "harlequin"; version = "2.16.1"; @@ -61,7 +61,8 @@ python3Packages.buildPythonApplication (finalAttrs: { wcwidth ] ++ lib.optionals withPostgresAdapter [ harlequin-postgres ] - ++ lib.optionals withBigQueryAdapter [ harlequin-bigquery ]; + ++ lib.optionals withBigQueryAdapter [ harlequin-bigquery ] + ++ lib.optionals withOdbcAdapter [ harlequin-odbc ]; pythonImportsCheck = [ "harlequin" @@ -112,6 +113,12 @@ python3Packages.buildPythonApplication (finalAttrs: { ++ lib.optionals (!stdenv.hostPlatform.isx86_64) [ # Test incorrectly tries to load a dylib/so compiled for x86_64 "test_load_extension" + ] + ++ lib.optionals withOdbcAdapter [ + # harlequin-odbc declares no adapter options (its connection string is a + # positional argument), and this test requires every installed adapter to + # declare at least one. + "test_spec_covers_every_installed_adapter" ]; disabledTestPaths = [ diff --git a/pkgs/development/python-modules/harlequin-odbc/default.nix b/pkgs/development/python-modules/harlequin-odbc/default.nix new file mode 100644 index 000000000000..dbaa4a720fc1 --- /dev/null +++ b/pkgs/development/python-modules/harlequin-odbc/default.nix @@ -0,0 +1,52 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + pythonAtLeast, + hatchling, + duckdb, + pyodbc, +}: +buildPythonPackage (finalAttrs: { + pname = "harlequin-odbc"; + version = "0.4.0"; + pyproject = true; + __structuredAttrs = true; + + src = fetchFromGitHub { + owner = "tconbeer"; + repo = "harlequin-odbc"; + tag = "v${finalAttrs.version}"; + hash = "sha256-U0z7fgBzdL+PRhll6AH4DziqY26kVYA4qkOEbZbWF1g="; + }; + + build-system = [ + hatchling + ]; + + # harlequin loads this adapter as a plugin, so depending on harlequin would + # create a cycle, as harlequin can depend on this package. + pythonRemoveDeps = [ + "harlequin" + ]; + + dependencies = [ + pyodbc + ] + ++ lib.optionals (pythonAtLeast "3.14") [ + duckdb + ]; + + # The test suite needs harlequin (removed above) and a live database + # reachable over ODBC. + doCheck = false; + + meta = { + description = "A Harlequin adapter for ODBC drivers"; + homepage = "https://github.com/tconbeer/harlequin-odbc"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ + c4patino + ]; + }; +}) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 411eae4c15fc..23284c8e27ca 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -7547,6 +7547,8 @@ self: super: with self; { harlequin-bigquery = callPackage ../development/python-modules/harlequin-bigquery { }; + harlequin-odbc = callPackage ../development/python-modules/harlequin-odbc { }; + harlequin-postgres = callPackage ../development/python-modules/harlequin-postgres { }; hass-client = callPackage ../development/python-modules/hass-client { };