From 9f5df22dba9042492a6cb730d917d8a2b4c14778 Mon Sep 17 00:00:00 2001 From: Ian Liu Rodrigues Date: Wed, 12 Jul 2023 22:14:09 -0300 Subject: [PATCH] aws-sam-cli: 1.53.0 -> 1.90.0 aws-sam-cli is too outdated, and can't create newer resources available in AWS, such as AWS Lambda functions with python3.10 runtime. This patch fixes this problem. Also, both patches were already applied upstream, as referenced below: * support-click-8-1.patch -> https://github.com/aws/aws-sam-cli/commit/c887458ccf3bd442d7d47aa7fcd4cb9645c92e42#diff-a7e8dd2d23df6667705bc0c8236e507a39bfb7b924ea21d0dca7715c296e43dc * use_forward_compatible_log_silencing.patch -> https://github.com/aws/aws-sam-cli/commit/0fd46082d6ad6439422c2483736b024d5dc6707a#diff-f0e7f12ebbb6534d97b6052531cf8ce2eb185739c213a148c1c76a429e6f4037 Version 1.53.0 was released in Jun 29, 2022 on pypi https://github.com/aws/aws-sam-cli/releases/tag/v1.53.0 Version 1.90.0 was released in Jul 6, 2023 on pypi https://github.com/aws/aws-sam-cli/releases/tag/v1.90.0 --- .../development/tools/aws-sam-cli/default.nix | 58 +++++++------------ .../tools/aws-sam-cli/support-click-8-1.patch | 21 ------- ...use_forward_compatible_log_silencing.patch | 19 ------ 3 files changed, 21 insertions(+), 77 deletions(-) delete mode 100644 pkgs/development/tools/aws-sam-cli/support-click-8-1.patch delete mode 100644 pkgs/development/tools/aws-sam-cli/use_forward_compatible_log_silencing.patch diff --git a/pkgs/development/tools/aws-sam-cli/default.nix b/pkgs/development/tools/aws-sam-cli/default.nix index 37d4d0878634..a91500e14948 100644 --- a/pkgs/development/tools/aws-sam-cli/default.nix +++ b/pkgs/development/tools/aws-sam-cli/default.nix @@ -6,30 +6,32 @@ python3.pkgs.buildPythonApplication rec { pname = "aws-sam-cli"; - version = "1.53.0"; + version = "1.90.0"; src = fetchPypi { inherit pname version; - hash = "sha256-kIW+aGYuS+JgOMsPbeLgPSgLFNKLSqHaZ1CHpjs/IVI="; + hash = "sha256-JXUfc37O6cTTOCTTtWE05m+GR4iDyBsmRPyXoTRxFmo="; }; propagatedBuildInputs = with python3.pkgs; [ aws-lambda-builders aws-sam-translator + boto3 + cfn-lint chevron - click cookiecutter dateparser - python-dateutil docker flask - jmespath - requests + pyopenssl + pyyaml + rich + ruamel-yaml serverlessrepo tomlkit - watchdog typing-extensions - regex + tzlocal + watchdog ]; postFixup = if enableTelemetry then "echo aws-sam-cli TELEMETRY IS ENABLED" else '' @@ -37,39 +39,21 @@ python3.pkgs.buildPythonApplication rec { wrapProgram $out/bin/sam --set SAM_CLI_TELEMETRY 0 ''; - patches = [ - # Click 8.1 removed `get_terminal_size`, recommending - # `shutil.get_terminal_size` instead. - # (https://github.com/pallets/click/pull/2130) - ./support-click-8-1.patch - # Werkzeug >= 2.1.0 breaks the `sam local start-lambda` command because - # aws-sam-cli uses a "WERKZEUG_RUN_MAIN" hack to suppress flask output. - # (https://github.com/cs01/gdbgui/issues/425) - ./use_forward_compatible_log_silencing.patch - ]; - - # fix over-restrictive version bounds postPatch = '' substituteInPlace requirements/base.txt \ - --replace "aws_lambda_builders==" "aws-lambda-builders #" \ - --replace "aws-sam-translator==1.46.0" "aws-sam-translator~=1.46" \ - --replace "click~=7.1" "click~=8.1" \ - --replace "cookiecutter~=1.7.2" "cookiecutter>=1.7.2" \ - --replace "dateparser~=1.0" "dateparser>=0.7" \ - --replace "docker~=4.2.0" "docker>=4.2.0" \ - --replace "Flask~=1.1.4" "Flask~=2.0" \ - --replace "jmespath~=0.10.0" "jmespath" \ - --replace "MarkupSafe==2.0.1" "MarkupSafe #" \ - --replace "PyYAML~=5.3" "PyYAML #" \ - --replace "regex==" "regex #" \ - --replace "requests==" "requests #" \ - --replace "typing_extensions==" "typing-extensions #" \ - --replace "tzlocal==3.0" "tzlocal #" \ - --replace "tomlkit==0.7.2" "tomlkit #" \ - --replace "watchdog==" "watchdog #" + --replace 'PyYAML>=' 'PyYAML>=5.4.1 #' \ + --replace 'aws-sam-translator==1.70.0' 'aws-sam-translator>=1.60.1' \ + --replace 'boto3>=' 'boto3>=1.26.79 #' \ + --replace 'cfn-lint~=0.77.9' 'cfn-lint~=0.73.2' \ + --replace 'docker~=6.1.0' 'docker~=6.0.1' \ + --replace 'pyopenssl~=23.2.0' 'pyopenssl~=23.1.0' \ + --replace 'ruamel_yaml~=0.17.32' 'ruamel_yaml~=0.17.21' \ + --replace 'tomlkit==0.11.8' 'tomlkit~=0.11.6' \ + --replace 'typing_extensions~=4.4.0' 'typing_extensions~=4.4' \ + --replace 'tzlocal==3.0' 'tzlocal>=3.0' \ + --replace 'watchdog==' 'watchdog>=2.1.2 #' ''; - # Tests are not included in the PyPI package doCheck = false; meta = with lib; { diff --git a/pkgs/development/tools/aws-sam-cli/support-click-8-1.patch b/pkgs/development/tools/aws-sam-cli/support-click-8-1.patch deleted file mode 100644 index dc7af080ac66..000000000000 --- a/pkgs/development/tools/aws-sam-cli/support-click-8-1.patch +++ /dev/null @@ -1,21 +0,0 @@ -diff --git a/samcli/commands/_utils/table_print.py b/samcli/commands/_utils/table_print.py -index de63af29..a9d0f2fe 100644 ---- a/samcli/commands/_utils/table_print.py -+++ b/samcli/commands/_utils/table_print.py -@@ -7,6 +7,7 @@ from functools import wraps - from typing import Sized - - import click -+import shutil - - MIN_OFFSET = 20 - -@@ -30,7 +31,7 @@ def pprint_column_names( - - def pprint_wrap(func): - # Calculate terminal width, number of columns in the table -- width, _ = click.get_terminal_size() -+ width, _ = shutil.get_terminal_size() - # For UX purposes, set a minimum width for the table to be usable - # and usable_width keeps margins in mind. - width = max(width, min_width) diff --git a/pkgs/development/tools/aws-sam-cli/use_forward_compatible_log_silencing.patch b/pkgs/development/tools/aws-sam-cli/use_forward_compatible_log_silencing.patch deleted file mode 100644 index 76297875f36a..000000000000 --- a/pkgs/development/tools/aws-sam-cli/use_forward_compatible_log_silencing.patch +++ /dev/null @@ -1,19 +0,0 @@ -diff --git a/samcli/local/services/base_local_service.py b/samcli/local/services/base_local_service.py -index 7b1ab95895d1..76812f02e00a 100644 ---- a/samcli/local/services/base_local_service.py -+++ b/samcli/local/services/base_local_service.py -@@ -56,9 +56,11 @@ class BaseLocalService: - - LOG.debug("Localhost server is starting up. Multi-threading = %s", multi_threaded) - -- # This environ signifies we are running a main function for Flask. This is true, since we are using it within -- # our cli and not on a production server. -- os.environ["WERKZEUG_RUN_MAIN"] = "true" -+ # Suppress flask dev server output in a forward-compatible way -+ # Source: https://github.com/cs01/gdbgui/issues/425#issuecomment-1119836533 -+ import flask.cli -+ -+ flask.cli.show_server_banner = lambda *args: None - - self._app.run(threaded=multi_threaded, host=self.host, port=self.port) -