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

Support for Python 3 relative imports? #66

Open
willcroft opened this issue Jan 27, 2020 · 1 comment
Open

Support for Python 3 relative imports? #66

willcroft opened this issue Jan 27, 2020 · 1 comment

Comments

@willcroft
Copy link

We're currently running multi-package code on AWS Lambda, eg:

package_one/
    handler.py
    utils.py
package_two/
    other.py

On AWS Lambda, we're able to use:

from . import utils
from package_two import other

These imports don't work locally, presumably due to the way that python-lambda-local calls the handler as a function directly? So locally, we're using the following boilerplate in each handler we need to directly call:

if __name__[:8] in ['__main__', 'request-'] and not __package__:
    import os
    import sys
    __package__ = 'package_one'
    sys.path.append(...)

Are we missing something obvious here, or would a PR be welcomed to either inject this boilerplate automatically, or have python-lamba-local call the handler from within a package as AWS Lambda does itself?

@yxd-hde
Copy link
Contributor

yxd-hde commented Feb 17, 2020

PR is welcomed. Thanks!

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

No branches or pull requests

2 participants