awslabs / aws-crt-python

Python bindings for the AWS Common Runtime
Apache License 2.0
87 stars 43 forks source link

Unable to run when included in python layer #527

Closed Lewenhaupt closed 10 months ago

Lewenhaupt commented 10 months ago

Describe the bug

I'm including awscrt in a python lambda layer via the aws-cdk. But upon loading my lambda function which imports it I get: No module named '_awscrt'.

In the root of the layer I have another python file which I can import and it's that file that causes the import to aws-crt. In the layer I have the awscrt folder and _awscrt.cpython-38-x86_64-linux-gnu.so

I also have this when it's being built (by @aws-cdk/lambda-python-alpha) Collecting awscrt==0.19.* (from -r requirements.txt (line 4)) Downloading awscrt-0.19.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (3.3 kB)

So I believe everything looks like it should, but it still fails.

Expected Behavior

_awscrt should be available to import

Current Behavior

_awscrt was not possible to import.

Reproduction Steps

Create a simple layer with @aws-cdk/aws-lambda-python-alpha that list awscrt in requirements.txt Then import that in the lambda handler

Possible Solution

No response

Additional Information/Context

No response

aws-crt-python version used

0.19.1

Python version used

3.8

Operating System and version

Ubuntu 22

Lewenhaupt commented 10 months ago

It seems the issue stems from trying to build a layer for multiple different architectures, i.e. not setting one explicitly.