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

Allow packaging shared object files in Python projects #115

Open
divergentdave opened this issue May 21, 2019 · 3 comments
Open

Allow packaging shared object files in Python projects #115

divergentdave opened this issue May 21, 2019 · 3 comments

Comments

@divergentdave
Copy link

divergentdave commented May 21, 2019

Description:

I'm working on a Python project that indirectly uses a native library through ctypes, so I need to supply the library, libspatialindex.so, in the Lambda function's package. However, when I run sam build, the file does not get copied into the output. It looks like this is due to the EXCLUDED_FILES list for PythonPipWorkflow.

Steps to reproduce the issue:

  1. Place a file ending in .so in the directory pointed to by CodeUri
  2. Run sam build

Observed result:
The file should be copied into .aws-sam/build/FunctionName/

Expected result:
The file is missing

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
I am using SAM CLI version 0.16.0 on Debian Stretch

@ingomueller-net
Copy link

I also need this functionality.

@ingomueller-net
Copy link

As a workaround, you can create a file called sitecustomize.py with the following content:

from aws_lambda_builders.workflows.python_pip.workflow import PythonPipWorkflow
PythonPipWorkflow.EXCLUDED_FILES = tuple(x for x in PythonPipWorkflow.EXCLUDED_FILES if x != "*.so")

This file will be executed when the Python interpreter starts, before it opens the interactive terminal or runs the script. It will search for a file with that name in the site-packages directories, which includes the working directory (so place the file there). Similarly, some other site-specific configuration hook can be used to patch the patterns of excluded files.

@carpnick
Copy link

This needs to be exposed in AWS SAM to support other tools like - the AWS cfn tool set. - IE - https://github.com/aws-cloudformation/cloudformation-cli-python-plugin

Directly related to this issue - aws-cloudformation/cloudformation-cli-python-plugin#247

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

5 participants