aws-samples / amazon-bedrock-workshop

This is a workshop designed for Amazon Bedrock a foundational model service.
https://catalog.us-east-1.prod.workshops.aws/amazon-bedrock/en-US
MIT No Attribution
1.48k stars 635 forks source link

awscli install fails due to cpython error #7

Closed gopinaath closed 1 year ago

gopinaath commented 1 year ago
$ python --version
Python 3.11.1

$  pip3 install ./dependencies/awscli-1.27.162-py3-none-any.whl --force-reinstall 
Processing ./dependencies/awscli-1.27.162-py3-none-any.whl
Collecting botocore==1.29.162 (from awscli==1.27.162)
  Obtaining dependency information for botocore==1.29.162 from https://files.pythonhosted.org/packages/f5/b1/f171070c895f6ca3731da818a28a7f420dd2269a2e92893841a80c862d01/botocore-1.29.162-py3-none-any.whl.metadata
  Downloading botocore-1.29.162-py3-none-any.whl.metadata (5.9 kB)
Collecting docutils<0.17,>=0.10 (from awscli==1.27.162)
  Using cached docutils-0.16-py2.py3-none-any.whl (548 kB)
Collecting s3transfer<0.7.0,>=0.6.0 (from awscli==1.27.162)
  Using cached s3transfer-0.6.1-py3-none-any.whl (79 kB)
Collecting PyYAML<5.5,>=3.10 (from awscli==1.27.162)
  Using cached PyYAML-5.4.1.tar.gz (175 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [68 lines of output]
      /private/var/folders/hw/qz34y_7n2tdb97zg6jmj03m00000gr/T/pip-build-env-ytda0uc3/overlay/lib/python3.11/site-packages/setuptools/config/setupcfg.py:293: _DeprecatedConfig: Deprecated config in `setup.cfg`
      !!

              ********************************************************************************
              The license_file parameter is deprecated, use license_files instead.

              By 2023-Oct-30, you need to update your project and remove deprecated calls
              or your builds will no longer be supported.

              See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
              ********************************************************************************

      !!
        parsed = self.parsers.get(option_name, lambda x: x)(value)
      running egg_info
      writing lib3/PyYAML.egg-info/PKG-INFO
      writing dependency_links to lib3/PyYAML.egg-info/dependency_links.txt
      writing top-level names to lib3/PyYAML.egg-info/top_level.txt
      Traceback (most recent call last):
        File "/Users/dev/wrksp/amazon-bedrock-workshop/amazon-bedrock-workshop/.venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/Users/dev/wrksp/amazon-bedrock-workshop/amazon-bedrock-workshop/.venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/dev/wrksp/amazon-bedrock-workshop/amazon-bedrock-workshop/.venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/hw/qz34y_7n2tdb97zg6jmj03m00000gr/T/pip-build-env-ytda0uc3/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/hw/qz34y_7n2tdb97zg6jmj03m00000gr/T/pip-build-env-ytda0uc3/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
          self.run_setup()
        File "/private/var/folders/hw/qz34y_7n2tdb97zg6jmj03m00000gr/T/pip-build-env-ytda0uc3/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 338, in run_setup
          exec(code, locals())
        File "<string>", line 271, in <module>
        File "/private/var/folders/hw/qz34y_7n2tdb97zg6jmj03m00000gr/T/pip-build-env-ytda0uc3/overlay/lib/python3.11/site-packages/setuptools/__init__.py", line 107, in setup
          return distutils.core.setup(**attrs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/hw/qz34y_7n2tdb97zg6jmj03m00000gr/T/pip-build-env-ytda0uc3/overlay/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 185, in setup
          return run_commands(dist)
                 ^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/hw/qz34y_7n2tdb97zg6jmj03m00000gr/T/pip-build-env-ytda0uc3/overlay/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
          dist.run_commands()
        File "/private/var/folders/hw/qz34y_7n2tdb97zg6jmj03m00000gr/T/pip-build-env-ytda0uc3/overlay/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
          self.run_command(cmd)
        File "/private/var/folders/hw/qz34y_7n2tdb97zg6jmj03m00000gr/T/pip-build-env-ytda0uc3/overlay/lib/python3.11/site-packages/setuptools/dist.py", line 1234, in run_command
          super().run_command(command)
        File "/private/var/folders/hw/qz34y_7n2tdb97zg6jmj03m00000gr/T/pip-build-env-ytda0uc3/overlay/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/private/var/folders/hw/qz34y_7n2tdb97zg6jmj03m00000gr/T/pip-build-env-ytda0uc3/overlay/lib/python3.11/site-packages/setuptools/command/egg_info.py", line 314, in run
          self.find_sources()
        File "/private/var/folders/hw/qz34y_7n2tdb97zg6jmj03m00000gr/T/pip-build-env-ytda0uc3/overlay/lib/python3.11/site-packages/setuptools/command/egg_info.py", line 322, in find_sources
          mm.run()
        File "/private/var/folders/hw/qz34y_7n2tdb97zg6jmj03m00000gr/T/pip-build-env-ytda0uc3/overlay/lib/python3.11/site-packages/setuptools/command/egg_info.py", line 551, in run
          self.add_defaults()
        File "/private/var/folders/hw/qz34y_7n2tdb97zg6jmj03m00000gr/T/pip-build-env-ytda0uc3/overlay/lib/python3.11/site-packages/setuptools/command/egg_info.py", line 589, in add_defaults
          sdist.add_defaults(self)
        File "/private/var/folders/hw/qz34y_7n2tdb97zg6jmj03m00000gr/T/pip-build-env-ytda0uc3/overlay/lib/python3.11/site-packages/setuptools/command/sdist.py", line 104, in add_defaults
          super().add_defaults()
        File "/private/var/folders/hw/qz34y_7n2tdb97zg6jmj03m00000gr/T/pip-build-env-ytda0uc3/overlay/lib/python3.11/site-packages/setuptools/_distutils/command/sdist.py", line 251, in add_defaults
          self._add_defaults_ext()
        File "/private/var/folders/hw/qz34y_7n2tdb97zg6jmj03m00000gr/T/pip-build-env-ytda0uc3/overlay/lib/python3.11/site-packages/setuptools/_distutils/command/sdist.py", line 336, in _add_defaults_ext
          self.filelist.extend(build_ext.get_source_files())
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "<string>", line 201, in get_source_files
        File "/private/var/folders/hw/qz34y_7n2tdb97zg6jmj03m00000gr/T/pip-build-env-ytda0uc3/overlay/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 107, in __getattr__
          raise AttributeError(attr)
      AttributeError: cython_sources
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
rmartine-ias commented 1 year ago

This is because of https://github.com/yaml/pyyaml/issues/601 and can be resolved with:

pip install wheel
pip install dependencies/awscli-1.27.162-py3-none-any.whl --no-build-isolation

A newer awscli might fix it as well.

athewsey commented 1 year ago

Same error observed in SageMaker Studio Data Science 3.0 kernel (Python 3.10.6), blocking #12

In that environment, upgrading wheel (default is already 0.40.0, newest available is 0.41.0) does not solve the issue - maybe there's a downgrade that might? Either way it's a bit of a fundamental package that I prefer to avoid messing with when possible 🫤

As far as i can tell, nothing in the workshop actually uses the preview AWS CLI today: The only CLI commands I see are aws s3 cp ...

So another option (aside from waiting for new CLI) could be to just remove the custom awscli install from the workshop notebooks altogether? Pros: Python 3.10+ environments including DataSci3.0 should work; Cons: If anybody did want to explore/demonstrate the Bedrock CLI (or expand the workshop examples to show it in action), they couldn't.

athewsey commented 1 year ago

@rmartine-ias In Studio I'm seeing that instead of installing wheel (which doesn't work on DataSci 3.0), running the awscli/boto installs with --no-build-isolation as shown below fixes it:

%pip install --no-build-isolation --force-reinstall \
    ../dependencies/awscli-1.27.162-py3-none-any.whl \
    ../dependencies/boto3-1.26.162-py3-none-any.whl \
    ../dependencies/botocore-1.29.162-py3-none-any.whl

I'd appreciate feedback whether that approach works for other people facing this issue in non-Studio environments too? (Or if anybody deeper on Python packaging than I am has reason to believe it's a bad idea!)