GrahamDumpleton / wrapt

A Python module for decorators, wrappers and monkey patching.
BSD 2-Clause "Simplified" License
2.04k stars 230 forks source link

Missing wheels for AWS sam build command #195

Closed gmontamat closed 2 years ago

gmontamat commented 2 years ago

When building a Python AWS Lambda function, pip looks for a wheel with the following naming convention (Python 3.6): https://aws.amazon.com/premiumsupport/knowledge-center/lambda-python-package-compatible/

module-name-version-cp36-cp36m-manylinux1_x86_64.whl

The latest release, 1.13.3, doesn't have such wheel and installing this package on a Lambda fails. The previous release had this wheel: https://files.pythonhosted.org/packages/f5/24/b8d66f045ef6aee9000fbbb1be57961338938095d2e344e2972b3bf15cbd/wrapt-1.13.2-cp36-cp36m-manylinux1_x86_64.whl

GrahamDumpleton commented 2 years ago

Are you trying to manually copy it down or somehow force it to us that exact name? Explain how you are telling Lambda to use that specific version.

The appropriate one should be:

wrapt-1.13.3-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
gmontamat commented 2 years ago

It's a pip install aws-xray-sdk==2.6.0 that's failing when installing wrapt as a dependency. This happens when we build the Lambda, we do it in an ubuntu18.04 docker image with its default python3.6. I'll get the image's details for you. This started happening with 1.13.3, never happened before, even 1.13.2 works so our best guess is the wheel name change.

GrahamDumpleton commented 2 years ago

If you have control over running pip, are you ensuring that pip itself is being updated to the most up to date version? This includes updating it inside of any virtual environment if running one, as the virtual environment may not install the most up to date version of pip.

gmontamat commented 2 years ago

So I went through the image that builds the Lambdas for us and turns out we don't have control over pip, it's a sam build command that's failing in our case. The pip wrapper in sam is searching for wheels with the following naming convention: module-name-version-cp36-cp36m-manylinux1_x86_64.whl, thus failing when trying to install wrapt as one of our dependencies. We can solve it by forcing wrapt==1.13.2 in our requirements.txt before aws-xray-sdk==2.6.0.

ps: editing the title to reflect this, not having problems within the Lambdas

GrahamDumpleton commented 2 years ago

Is this image that does the builds provided by Amazon, a third party, or your own company? Do you have links off to documentation about it if is from Amazon or a third party?

gmontamat commented 2 years ago

Hi @GrahamDumpleton thanks for your support. I managed to reproduce the error in my local machine. wrapt is innocent, the problem is that we're using an old sam release:

cd /path-to-sam-template-and-lambda
pip install aws-sam-cli==1.23.0
sam build --debug

Results in:

...
2021-11-04 12:14:19,696 | Final compatible: {six==1.16.0(wheel), python-dateutil==2.8.2(wheel), aws-lambda-powertools==1.6.1(wheel), botocore==1.22.10(wheel), zipp==3.6.0(wheel), urllib3==1.26.7(wheel), jmespath==0.10.0(wheel), importlib-metadata==4.8.1(wheel), s3transfer==0.3.7(wheel), fastjsonschema==2.15.1(wheel), future==0.18.2(wheel), typing-extensions==3.10.0.2(wheel), jsonpickle==2.0.0(wheel), boto3==1.17.22(wheel), aws-xray-sdk==2.6.0(wheel)}
2021-11-04 12:14:19,696 | Final incompatible: {wrapt==1.13.3(wheel)}
2021-11-04 12:14:19,696 | Final missing wheels: {wrapt==1.13.3(wheel)}
2021-11-04 12:14:20,017 | PythonPipBuilder:ResolveDependencies failed
Traceback (most recent call last):
  File "/sam_test/shared/venv/lib/python3.6/site-packages/aws_lambda_builders/workflows/python_pip/actions.py", line 42, in execute
    requirements_path=self.manifest_path,
  File "/sam_test/shared/venv/lib/python3.6/site-packages/aws_lambda_builders/workflows/python_pip/packager.py", line 137, in build_dependencies
    self._dependency_builder.build_site_packages(requirements_path, artifacts_dir_path, scratch_dir_path)
  File "/sam_test/shared/venv/lib/python3.6/site-packages/aws_lambda_builders/workflows/python_pip/packager.py", line 207, in build_site_packages
    raise MissingDependencyError(packages_without_wheels)
aws_lambda_builders.workflows.python_pip.packager.MissingDependencyError: {wrapt==1.13.3(wheel)}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/sam_test/shared/venv/lib/python3.6/site-packages/aws_lambda_builders/workflow.py", line 269, in run
    action.execute()
  File "/sam_test/shared/venv/lib/python3.6/site-packages/aws_lambda_builders/workflows/python_pip/actions.py", line 45, in execute
    raise ActionFailedError(str(ex))
aws_lambda_builders.actions.ActionFailedError: {wrapt==1.13.3(wheel)}

Build Failed

This is not happening with the latest aws-sam-cli release, I'll ask the cloudops to update our image with a newer SAM version. Thanks!