From 4c3f5faff0e851d08e13b6be3b3fe007450f6d77 Mon Sep 17 00:00:00 2001 From: BrandonLWhite Date: Tue, 18 Mar 2025 12:10:10 -0500 Subject: [PATCH] Fix .dependencies.zip filename Create output directory if not exist --- package_python_function/nested_zip_loader.py | 4 ++-- package_python_function/packager.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package_python_function/nested_zip_loader.py b/package_python_function/nested_zip_loader.py index 1f686a9..e21bf10 100644 --- a/package_python_function/nested_zip_loader.py +++ b/package_python_function/nested_zip_loader.py @@ -31,13 +31,13 @@ def load_nested_zip() -> None: if staging_package_path.exists(): shutil.rmtree(str(staging_package_path)) - nested_zip_path = Path(__file__).parent / '.requirements.zip' + nested_zip_path = Path(__file__).parent / '.dependencies.zip' zipfile.ZipFile(str(nested_zip_path), 'r').extractall(str(staging_package_path)) os.rename(str(staging_package_path), str(target_package_path)) # Atomic -- TODO BW DOCME # TODO BW: Update this comment - # We want our path to look like [working_dir, serverless_requirements, ...] + # We want our path to look like [working_dir, /tmp/package-python-function, ...] sys.path.insert(1, target_package_path) importlib.reload(sys.modules[__name__]) diff --git a/package_python_function/packager.py b/package_python_function/packager.py index 2f9a634..3cc3872 100644 --- a/package_python_function/packager.py +++ b/package_python_function/packager.py @@ -34,6 +34,8 @@ def package(self) -> None: print("Input:", self.input_path) print("Entrypoint Package name:", self.project.entrypoint_package_name) + self.output_file_path.parent.mkdir(parents=True, exist_ok=True) + with NamedTemporaryFile() as dependencies_zip: self.zip_all_dependencies(Path(dependencies_zip.name))