question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sam local build does not copy .so files

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
kbrownscommented, 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

1reaction
sanathkrcommented, Aug 22, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

sam local build does not copy .so files · Issue #1360 - GitHub
The build process doesn't copy over .so files when building a Python Lambda function. Steps to reproduce. Install the ptvsd library: pip install ......
Read more >
Including local source code directories and files in aws-sam?
I work in a mono repo where I have a AWS SAM (lambda) application. The structure is more or less like so:
Read more >
sam build - AWS Serverless Application Model
The sam build command processes your AWS SAM template file, application code, and any applicable language-specific files and dependencies.
Read more >
Develop AWS Lambda locally using AWS SAM - The Chief IO
Note that while using SAM to initiate the application it will create a folder automatically, so you don't need to create one by...
Read more >
GLIBC not found with AWS SAM and Golang - Matt Gaunt
I did try using sam build --use-containers , which I assume would have ... the sam CLI will copy the functions files into...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found