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