diff --git a/exe/pyinstaller/aws.spec b/exe/pyinstaller/aws.spec index eb35333ec4ca..6a5f34c657ed 100644 --- a/exe/pyinstaller/aws.spec +++ b/exe/pyinstaller/aws.spec @@ -10,7 +10,7 @@ aws_a = Analysis(['../../bin/aws'], datas=[], hiddenimports=[], hookspath=['.'], - runtime_hooks=[], + runtime_hooks=['pyi_rth_pkg_resources_warning.py'], excludes=['cmd', 'code', 'pdb'], win_no_prefer_redirects=False, win_private_assemblies=False, diff --git a/exe/pyinstaller/aws_completer.spec b/exe/pyinstaller/aws_completer.spec index 5d114e39b8d4..5279aaafce83 100644 --- a/exe/pyinstaller/aws_completer.spec +++ b/exe/pyinstaller/aws_completer.spec @@ -11,7 +11,7 @@ completer_a = Analysis(['../../bin/aws_completer'], datas=[], hiddenimports=[], hookspath=['.'], - runtime_hooks=[], + runtime_hooks=['pyi_rth_pkg_resources_warning.py'], excludes=['cmd', 'code', 'pdb'], win_no_prefer_redirects=False, win_private_assemblies=False, diff --git a/exe/pyinstaller/hook-awscli.py b/exe/pyinstaller/hook-awscli.py index c0a8dc6389d7..93e437ab927b 100644 --- a/exe/pyinstaller/hook-awscli.py +++ b/exe/pyinstaller/hook-awscli.py @@ -10,10 +10,6 @@ 'pipes', 'colorama', 'awscli.handlers', - # NOTE: This can be removed once this hidden import issue related to - # setuptools and PyInstaller is resolved: - # https://github.com/pypa/setuptools/issues/1963 - 'pkg_resources.py2_warn', ] imports_for_legacy_plugins = hooks.collect_submodules( diff --git a/exe/pyinstaller/pyi_rth_pkg_resources_warning.py b/exe/pyinstaller/pyi_rth_pkg_resources_warning.py new file mode 100644 index 000000000000..235132996a57 --- /dev/null +++ b/exe/pyinstaller/pyi_rth_pkg_resources_warning.py @@ -0,0 +1,25 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"). You +# may not use this file except in compliance with the License. A copy of +# the License is located at +# +# http://aws.amazon.com/apache2.0/ +# +# or in the "license" file accompanying this file. This file is +# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF +# ANY KIND, either express or implied. See the License for the specific +# language governing permissions and limitations under the License. + +# PyInstaller runtime hook to suppress the pkg_resources deprecation +# warning introduced in setuptools >= 81. This hook runs early in the +# PyInstaller bootstrap process, before pkg_resources is imported by +# any other runtime hook or application code. +# See: https://github.com/aws/aws-cli/issues/10065 +import warnings + +warnings.filterwarnings( + 'ignore', + message='pkg_resources is deprecated as an API', + category=UserWarning, +)