Skip to content

Commit 80ed5c5

Browse files
committed
Add POC script
1 parent 0a47d3e commit 80ed5c5

11 files changed

Lines changed: 103 additions & 0 deletions

File tree

scripts/poc/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.test

scripts/poc/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is the original proof-of-concept script used to work out the nested-ZIP automatic extraction during Lambda INIT

scripts/poc/inner_package/other_package/__init__.py

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def other_package_module():
2+
print("other_package_module")
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This file represents the original module's __init__.py file that gets renamed when creating the innner ZIP.
2+
3+
print("__init__ original")
4+
5+
GLOBAL_VALUE_IN_INIT_ORIGINAL = "This global is defined in the original __init__.py"
6+
7+
from .other_module import other_module_function
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
print("main.py: Load")
2+
3+
from zip_in_zip_test import GLOBAL_VALUE_IN_INIT_ORIGINAL, other_module_function
4+
from other_package.other_package_module import other_package_module
5+
6+
def main():
7+
print("Hello from main!")
8+
print(GLOBAL_VALUE_IN_INIT_ORIGINAL)
9+
other_module_function()
10+
other_package_module()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def other_module_function():
2+
print("I'm in other_module_function")

scripts/poc/lambda-runner.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This is my best attempt at simulating what AWS Lambda does
2+
# Instead of messing with zipping and unzipping in this experiment, I just copy the files to the .test directory.
3+
4+
from pathlib import Path
5+
import shutil
6+
import sys
7+
8+
print('[lambda-runner]')
9+
print('sys.path:', sys.path)
10+
11+
module_path = Path(__file__).parent
12+
TEST_DIR = module_path / ".test"
13+
PACKAGE_NAME = "zip_in_zip_test"
14+
TEST_PACKAGE_DIR = TEST_DIR / PACKAGE_NAME
15+
16+
shutil.rmtree(TEST_DIR, ignore_errors=True)
17+
shutil.copytree(str(module_path / PACKAGE_NAME), str(TEST_PACKAGE_DIR))
18+
shutil.copytree(str(module_path / "inner_package"), str(TEST_PACKAGE_DIR / ".inner_package"))
19+
20+
sys.path.insert(0, str(TEST_DIR))
21+
22+
import importlib
23+
module = importlib.import_module('zip_in_zip_test.main')
24+
module.__dict__['main']()

scripts/poc/poetry.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/poc/pyproject.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[tool.poetry]
2+
name = "zip-in-zip-test"
3+
version = "0.1.0"
4+
description = ""
5+
authors = ["BrandonLWhite <brandonlwhite@gmail.com>"]
6+
readme = "README.md"
7+
8+
[tool.poetry.dependencies]
9+
python = "^3.13"
10+
11+
12+
[build-system]
13+
requires = ["poetry-core"]
14+
build-backend = "poetry.core.masonry.api"

0 commit comments

Comments
 (0)