Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Support for Python 3 relative imports? #66

Open
@willcroft

Description

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /