nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 python3Packages,
4 fetchFromGitHub,
5 installShellFiles,
6 stdenv,
7}:
8
9python3Packages.buildPythonApplication rec {
10 pname = "snowflake-cli";
11 version = "3.11.0";
12 pyproject = true;
13
14 src = fetchFromGitHub {
15 owner = "snowflakedb";
16 repo = "snowflake-cli";
17 tag = "v${version}";
18 hash = "sha256-dJc5q3vE1G6oJq9V4JSPaSyODxKDyhprIwBo39Nu/bA=";
19 };
20
21 build-system = with python3Packages; [
22 hatch-vcs
23 hatchling
24 pip
25 ];
26
27 nativeBuildInputs = [ installShellFiles ];
28
29 dependencies = with python3Packages; [
30 id
31 jinja2
32 pluggy
33 pyyaml
34 rich
35 requests
36 requirements-parser
37 setuptools
38 tomlkit
39 typer
40 urllib3
41 gitpython
42 pydantic
43 prompt-toolkit
44 snowflake-core
45 snowflake-connector-python
46 ];
47
48 nativeCheckInputs = with python3Packages; [
49 pytestCheckHook
50 syrupy
51 coverage
52 pytest-randomly
53 pytest-factoryboy
54 pytest-xdist
55 pytest-httpserver
56 ];
57
58 pytestFlags = [
59 "--snapshot-warn-unused"
60 ];
61
62 disabledTests = [
63 "integration"
64 "spcs"
65 "loaded_modules"
66 "integration_experimental"
67 "test_snow_typer_help_sanitization" # Snapshot needs update?
68 "test_help_message" # Snapshot needs update?
69 "test_sql_help_if_no_query_file_or_stdin" # Snapshot needs update?
70 "test_multiple_streamlit_raise_error_if_multiple_entities" # Snapshot needs update?
71 "test_replace_and_not_exists_cannot_be_used_together" # Snapshot needs update?
72 "test_format" # Snapshot needs update?
73 "test_executing_command_sends_telemetry_usage_data" # Fails on mocked version
74 "test_internal_application_data_is_sent_if_feature_flag_is_set"
75 "test_if_bundling_dependencies_resolves_requirements" # impure?
76 "test_silent_output_help" # Snapshot needs update? Diff between received and snapshot is the word 'TABLE' moving down a line
77 "test_new_connection_can_be_added_as_default" # Snapshot needs update? Diff between received and snapshot is an empty line
78 ];
79
80 disabledTestPaths = [
81 "tests/app/test_version_check.py"
82 "tests/nativeapp/test_sf_sql_facade.py"
83 ];
84
85 pythonRelaxDeps = true;
86
87 postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
88
89 # Looks like the completion generation has some sort of a race
90 # Occasionally one of the completion generations would fail with
91 #
92 # An unexpected exception occurred. Use --debug option to see the traceback. Exception message:
93 # [Errno 17] File exists: '/build/tmp.W654FVhCPT/.config/snowflake/logs'
94 #
95 # This creates a fake config that prevents logging in the build sandbox.
96 export HOME=$(mktemp -d)
97 mkdir -p $HOME/.config/snowflake
98 cat <<EOF > $HOME/.config/snowflake/config.toml
99 [cli.logs]
100 save_logs = false
101 EOF
102 # snowcli checks the config permissions upon launch and exits with an error code if it's not 0600.
103 chmod 0600 $HOME/.config/snowflake/config.toml
104
105 # Typer tries to guess the current shell by default
106 export _TYPER_COMPLETE_TEST_DISABLE_SHELL_DETECTION=1
107
108 installShellCompletion --cmd snow \
109 --bash <($out/bin/snow --show-completion bash) \
110 --fish <($out/bin/snow --show-completion fish) \
111 --zsh <($out/bin/snow --show-completion zsh)
112 '';
113
114 meta = {
115 changelog = "https://github.com/snowflakedb/snowflake-cli/blob/main/RELEASE-NOTES.md";
116 homepage = "https://docs.snowflake.com/en/developer-guide/snowflake-cli-v2/index";
117 description = "Command-line tool explicitly designed for developer-centric workloads in addition to SQL operations";
118 license = lib.licenses.asl20;
119 maintainers = with lib.maintainers; [ vtimofeenko ];
120 mainProgram = "snow";
121 };
122}