GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Support for Python 3 relative imports? · Issue #66 · HDE/python-lambda-local

Support for Python 3 relative imports? #66

New issue
Copy link
New issue
Copy link
Open
Open
Support for Python 3 relative imports?#66
Copy link

Description

@willcroft
willcroft
opened on Jan 27, 2020
Issue body actions

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?

Reacted by Hiroyuki Wakabayashi and Robert J. Berger

Activity

  1. yxd-hde commented on Feb 17, 2020

    @yxd-hde
    yxd-hde
    on Feb 17, 2020
    Contributor
    More actions

    PR is welcomed. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.