Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sam local build does not copy .so files #1360

Closed
jrowen opened this issue Aug 22, 2019 · 7 comments
Closed

sam local build does not copy .so files #1360

jrowen opened this issue Aug 22, 2019 · 7 comments

Comments

@jrowen
Copy link

jrowen commented Aug 22, 2019

Description

The build process doesn't copy over .so files when building a Python Lambda function.

Steps to reproduce

Install the ptvsd library:

pip install --upgrade -t ./package ptvsd

Build a Lambda function that uses ptvsd

sam build --template ./aws/template.yaml --use-container

The template file should include a reference to the package folder noted earlier (like CodeUri: ../package).

Observed result

When following the ptvsd debugging steps, the following error is thrown from the sam local invoke process:

Expected: /var/task/ptvsd/_vendored/pydevd/pydevd_attach_to_process/attach_linux_amd64.so to exist.

Looking into the .aws-sam/build/Function/ptvsd/pydevd/pydevd_attach_to_process folder, I can confirm the .so files were not copied over. Looking in package/ptvsd/_vendored/pydevd/pydevd_attach_to_process, I can confirm that the .so files are present.

Expected result

Debugging process runs without error.

@sanathkr
Copy link
Contributor

This is indeed a bug. We intentionally ignore certain files, .so files are one of them - https://github.com/awslabs/aws-lambda-builders/blob/develop/aws_lambda_builders/workflows/python_pip/workflow.py#L27

The intention behind excluding .so files is to prevent people from inadvertently including .so files built for one platform (say Mac) and hoping it will run on Lambda.

Since ptvsd produces .so files it needs to be compiled for the Lambda environment. I would recommend adding ptvsd to your requirements.txt during development and removing it before you push to production.

If this works, I can update the documentation to reflect the "sam build" usecase as well. Of course, it will be easier if sam build had support a requirements-dev.txt that gets built only for development.

@jrowen
Copy link
Author

jrowen commented Aug 23, 2019

I tried adding ptvsd to my requirements.txt file, but it didn't seem to resolve the issue.

My current workaround is to run the following after the build step, which eliminates the error

cp ./package/ptvsd/_vendored/pydevd/pydevd_attach_to_process/*.so .aws-sam/build/Function/ptvsd/_vendored/pydevd/pydevd_attach_to_process

@kbrowns
Copy link

kbrowns commented Jan 17, 2020

Are there any plans to support some kind of .samignore file type of mechanism? This really needs to be customizable by the user IMO. I'm seeing that sam build is including my .vagrant directory and other things I don't want it including and is bloating my deployment packages (which as you know have a size limitation. Many tools (e.g. Vagrant) need to have files in the root directory

@tomlockwood
Copy link

I've precompiled pymssql using freetds and want to use this with my lambda. It'd be great for me if I could do this with SAM somehow.

@rtrive
Copy link

rtrive commented Oct 5, 2020

This feature will be useful for certain libraries that require .so files

@torresxb1
Copy link
Contributor

We have a few issues asking for a similar thing in ignore: or a .samignore file. Closing so that we can track here: aws/aws-lambda-builders#185

@github-actions
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants