1{ lib
2, python3
3, fetchPypi
4, enableTelemetry ? false
5}:
6
7python3.pkgs.buildPythonApplication rec {
8 pname = "aws-sam-cli";
9 version = "1.53.0";
10
11 src = fetchPypi {
12 inherit pname version;
13 hash = "sha256-kIW+aGYuS+JgOMsPbeLgPSgLFNKLSqHaZ1CHpjs/IVI=";
14 };
15
16 propagatedBuildInputs = with python3.pkgs; [
17 aws-lambda-builders
18 aws-sam-translator
19 chevron
20 click
21 cookiecutter
22 dateparser
23 python-dateutil
24 docker
25 flask
26 jmespath
27 requests
28 serverlessrepo
29 tomlkit
30 watchdog
31 typing-extensions
32 regex
33 ];
34
35 postFixup = if enableTelemetry then "echo aws-sam-cli TELEMETRY IS ENABLED" else ''
36 # Disable telemetry: https://github.com/awslabs/aws-sam-cli/issues/1272
37 wrapProgram $out/bin/sam --set SAM_CLI_TELEMETRY 0
38 '';
39
40 patches = [
41 # Click 8.1 removed `get_terminal_size`, recommending
42 # `shutil.get_terminal_size` instead.
43 # (https://github.com/pallets/click/pull/2130)
44 ./support-click-8-1.patch
45 # Werkzeug >= 2.1.0 breaks the `sam local start-lambda` command because
46 # aws-sam-cli uses a "WERKZEUG_RUN_MAIN" hack to suppress flask output.
47 # (https://github.com/cs01/gdbgui/issues/425)
48 ./use_forward_compatible_log_silencing.patch
49 ];
50
51 # fix over-restrictive version bounds
52 postPatch = ''
53 substituteInPlace requirements/base.txt \
54 --replace "aws_lambda_builders==" "aws-lambda-builders #" \
55 --replace "aws-sam-translator==1.46.0" "aws-sam-translator~=1.46" \
56 --replace "click~=7.1" "click~=8.1" \
57 --replace "cookiecutter~=1.7.2" "cookiecutter>=1.7.2" \
58 --replace "dateparser~=1.0" "dateparser>=0.7" \
59 --replace "docker~=4.2.0" "docker>=4.2.0" \
60 --replace "Flask~=1.1.4" "Flask~=2.0" \
61 --replace "jmespath~=0.10.0" "jmespath" \
62 --replace "MarkupSafe==2.0.1" "MarkupSafe #" \
63 --replace "PyYAML~=5.3" "PyYAML #" \
64 --replace "regex==" "regex #" \
65 --replace "requests==" "requests #" \
66 --replace "typing_extensions==" "typing-extensions #" \
67 --replace "tzlocal==3.0" "tzlocal #" \
68 --replace "tomlkit==0.7.2" "tomlkit #" \
69 --replace "watchdog==" "watchdog #"
70 '';
71
72 # Tests are not included in the PyPI package
73 doCheck = false;
74
75 meta = with lib; {
76 homepage = "https://github.com/awslabs/aws-sam-cli";
77 description = "CLI tool for local development and testing of Serverless applications";
78 license = licenses.asl20;
79 maintainers = with maintainers; [ lo1tuma ];
80 };
81}