diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 89a6616b5e..9f6f5c0a24 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -11,6 +11,7 @@ * `snow notebook create` proving an option to create a Snowflake Notebook from a file on stage. ## Fixes and improvements +* Fixed ZIP packaging of Snowpark project dependencies containing implicit namespace packages like `snowflake`. # v2.4.0 diff --git a/src/snowflake/cli/plugins/snowpark/zipper.py b/src/snowflake/cli/plugins/snowpark/zipper.py index 2e30cb9edc..8c8eb380f4 100644 --- a/src/snowflake/cli/plugins/snowpark/zipper.py +++ b/src/snowflake/cli/plugins/snowpark/zipper.py @@ -10,15 +10,21 @@ IGNORED_FILES = [ "**/.DS_Store", + "**/.git", "**/.git/*", "**/.gitignore", + "**/.env", "**/.env/*", + "**/.venv", "**/.venv/*", "**/__pycache__", "**/*.zip", "**/*.pyc", + "**/env", "**/env/*", + "**/ENV", "**/ENV/*", + "**/venv", "**/venv/*", "**/requirements.txt", "**/requirements.snowflake.txt", @@ -52,9 +58,6 @@ def zip_dir( def _to_be_zipped(file: Path) -> bool: - if file.is_dir(): - return False - for pattern in IGNORED_FILES: # This has to be a string because of fnmatch file_as_str = str(file) diff --git a/tests/test_zipper.py b/tests/test_zipper.py index c43be82644..7b2a0ba1b3 100644 --- a/tests/test_zipper.py +++ b/tests/test_zipper.py @@ -31,6 +31,7 @@ def test_zip_current_dir(temp_dir): ] directories = [ Path(".git"), + Path("snowcli/.git"), Path("bin"), Path("snowcli"), Path("snowcli/snowcli.dist-info"), @@ -48,9 +49,13 @@ def test_zip_current_dir(temp_dir): assert set(zip_file.namelist()) == { "app.py", "additional_module.py", + "bin/", "bin/py.test", + "snowcli/", "snowcli/snowcli.py", + "snowcli/snowcli.dist-info/", "snowcli/snowcli.dist-info/METADATA.py", + "utils/", "utils/utils.py", }