1{ lib
2, python3
3, fetchFromGitHub
4, git
5, testers
6, aws-sam-cli
7, nix-update-script
8, enableTelemetry ? false
9}:
10
11python3.pkgs.buildPythonApplication rec {
12 pname = "aws-sam-cli";
13 version = "1.116.0";
14 pyproject = true;
15
16 disabled = python3.pythonOlder "3.8";
17
18 src = fetchFromGitHub {
19 owner = "aws";
20 repo = "aws-sam-cli";
21 rev = "refs/tags/v${version}";
22 hash = "sha256-bQET2acu2G2tKkBYrj+37f8vnvnByiqMwkMZzrhT95Q=";
23 };
24
25 build-system = with python3.pkgs; [
26 pythonRelaxDepsHook
27 setuptools
28 ];
29
30 pythonRelaxDeps = [
31 "aws-lambda-builders"
32 "aws-sam-translator"
33 "boto3-stubs"
34 "cfn-lint"
35 "cookiecutter"
36 "docker"
37 "jsonschema"
38 "pyopenssl"
39 "rich"
40 "ruamel-yaml"
41 "tomlkit"
42 "tzlocal"
43 ];
44
45 dependencies = with python3.pkgs; [
46 aws-lambda-builders
47 aws-sam-translator
48 boto3
49 boto3-stubs
50 cfn-lint
51 chevron
52 click
53 cookiecutter
54 dateparser
55 docker
56 flask
57 jsonschema
58 pyopenssl
59 pyyaml
60 requests
61 rich
62 ruamel-yaml
63 tomlkit
64 typing-extensions
65 tzlocal
66 watchdog
67 ] ++ (with python3.pkgs.boto3-stubs.optional-dependencies; [
68 apigateway
69 cloudformation
70 ecr
71 iam
72 kinesis
73 lambda
74 s3
75 schemas
76 secretsmanager
77 signer
78 sqs
79 stepfunctions
80 sts
81 xray
82 ]);
83
84 postFixup = ''
85 # Disable telemetry: https://github.com/aws/aws-sam-cli/issues/1272
86 wrapProgram $out/bin/sam \
87 --set SAM_CLI_TELEMETRY ${if enableTelemetry then "1" else "0"} \
88 --prefix PATH : $out/bin:${lib.makeBinPath [ git ]}
89 '';
90
91 nativeCheckInputs = with python3.pkgs; [
92 filelock
93 flaky
94 parameterized
95 psutil
96 pytest-timeout
97 pytest-xdist
98 pytestCheckHook
99 ];
100
101 preCheck = ''
102 export HOME=$(mktemp -d)
103 export PATH="$PATH:$out/bin:${lib.makeBinPath [ git ]}"
104 '';
105
106 pytestFlagsArray = [
107 "tests"
108 # Disable warnings
109 "-W"
110 "ignore::DeprecationWarning"
111 ];
112
113 disabledTestPaths = [
114 # Disable tests that requires networking or complex setup
115 "tests/end_to_end"
116 "tests/integration"
117 "tests/regression"
118 "tests/smoke"
119 "tests/unit/lib/telemetry"
120 # Disable flaky tests
121 "tests/unit/lib/samconfig/test_samconfig.py"
122 ];
123
124 disabledTests = [
125 # Disable flaky tests
126 "test_update_stage"
127 "test_delete_deployment"
128 "test_request_with_no_data"
129 ];
130
131 pythonImportsCheck = [
132 "samcli"
133 ];
134
135 passthru = {
136 tests.version = testers.testVersion {
137 package = aws-sam-cli;
138 command = "sam --version";
139 };
140 updateScript = nix-update-script {
141 extraArgs = [ "--version-regex" "^v([0-9.]+)$" ];
142 };
143 };
144
145 __darwinAllowLocalNetworking = true;
146
147 meta = with lib; {
148 description = "CLI tool for local development and testing of Serverless applications";
149 homepage = "https://github.com/aws/aws-sam-cli";
150 changelog = "https://github.com/aws/aws-sam-cli/releases/tag/v${version}";
151 license = licenses.asl20;
152 mainProgram = "sam";
153 maintainers = with maintainers; [ lo1tuma anthonyroussel ];
154 };
155}