-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Hello,
Thanks for your work on this. I'm a noobie, really, so please bear with me.
I'm trying to deploy to lambda, the only module I need is pymysql, and I really started out with a single py file, but because py-lambda-packer uses setup.py I had to change my structure, this is my current structure:
getAgentsTimeout
.
├── getAgentsTimeout.yaml
├── requirements.txt
├── setup.py
└── getAgentsTimeout
├── __init__.py
└── lambda_function.py
my getAgentsTimeout.yaml:
virtualenv:
python: python3.7
path: !!null
keep: false
pip:
requirements:
- requirements.txt
packages: []
default_excludes:
- easy_install.*
- pip*/**
- py-lambda-packer.yaml
- setuptools*/**
- wheel*/**
packager:
target: py-lambda-package.zip
build_path: !!null
keep: false
followlinks: false
includes: []
excludes: []
default_excludes:
- '**/*~'
- '**/*.swp'
- '**/.*.swp'
- '**/.DS_Store'
- '**/.DS_Store?'
- '**/._*'
- '**/.Spotlight-V100'
- '**/.Trashes'
- '**/Icon?'
- '**/ehthumbs.db'
- '**/Thumbs.db'
My requirements.txt:
pymysql
my setup.py:
from distutils.core import setup
setup(
name='getAgentsTimeout',
version='0.1',
py_modules = ['getAgentsTimeout'],
)
init.py is empty, as I don't think the lambda has any use for it.
and finally my lambda_function.py:
from __future__ import print_function
import json
import urllib
import sys
import os
import pymysql
print('Loading function')
def lambda_handler(event, context):
print('Running')
def main():
""" Main entry point of the app """
lambda_handler('start', 'test')
if __name__ == "__main__":
""" This is executed when run from the command line """
main()
When I execute:
py-lambda-packer --requirement getAgentsTimeout/requirements.txt --package getAgentsTimeout/ --python python3.7
the resulting zip file contains the modules:
.
├── py-lambda-package.zip
├── __pycache__
│ └── easy_install.cpython-37.pyc
├── lambda_getAgentTimeout_function-0.1.dist-info
│ ├── INSTALLER
│ ├── METADATA
│ ├── RECORD
│ ├── top_level.txt
│ └── WHEEL
├── pkg_resources
│ ├── __init__.py
│ ├── py31compat.py
│ ├── pkg_resources
│ │ ├── __init__.py
│ │ ├── appdirs.py
│ │ ├── pyparsing.py
│ │ ├── six.py
│ │ └── pkg_resources
│ │ ├── __about__.py
│ │ ├── __init__.py
│ │ ├── _compat.py
│ │ ├── _structures.py
│ │ ├── markers.py
│ │ ├── requirements.py
│ │ ├── specifiers.py
│ │ ├── utils.py
│ │ └── version.py
│ └── pkg_resources
│ └── __init__.py
├── pymysql
│ ├── __init__.py
│ ├── _auth.py
│ ├── _compat.py
│ ├── _socketio.py
│ ├── charset.py
│ ├── connections.py
│ ├── converters.py
│ ├── cursors.py
│ ├── err.py
│ ├── optionfile.py
│ ├── protocol.py
│ ├── times.py
│ ├── util.py
│ └── pymysql
│ ├── __init__.py
│ ├── CLIENT.py
│ ├── COMMAND.py
│ ├── CR.py
│ ├── ER.py
│ ├── FIELD_TYPE.py
│ ├── FLAG.py
│ └── SERVER_STATUS.py
└── PyMySQL-0.9.3.dist-info
├── INSTALLER
├── LICENSE
├── METADATA
├── pbr.json
├── RECORD
├── top_level.txt
└── WHEEL
But I don't see my lambda_handler.py anywhere (which should be at top level), and I also don't see how lambda would reach it.
Thanks for your help and clarification!
David