Skip to content

Commit 5bad878

Browse files
committed
Fix to zip paths
1 parent 373c42e commit 5bad878

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

infra/upload_assets.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,16 @@ def zip_filter(filename: str) -> bool:
5555
Returns:
5656
bool: True if should filter
5757
"""
58-
return os.path.isfile(filename) and filename not in [".DS_Store"]
58+
dir_name = os.path.basename(os.path.dirname(filename))
59+
base_name = os.path.basename(filename)
60+
return (
61+
os.path.isfile(filename)
62+
and base_name not in [".DS_Store"]
63+
and not dir_name == "cdk.out"
64+
and not dir_name == "__pycache__"
65+
and not filename.endswith(".pyc")
66+
and not dir_name.endswith(".egg-info")
67+
)
5968

6069

6170
def make_zipfile(source_dir: str) -> str:
@@ -68,16 +77,12 @@ def make_zipfile(source_dir: str) -> str:
6877
str: Returns the zip filename created
6978
"""
7079
output_filename = source_dir + ".zip"
71-
relroot = os.path.abspath(os.path.join(source_dir, os.pardir))
7280
with zipfile.ZipFile(output_filename, "w", zipfile.ZIP_DEFLATED) as zip:
7381
for root, dirs, files in os.walk(source_dir):
74-
# add directory (needed for empty dirs)
75-
zip.write(root, os.path.relpath(root, relroot))
7682
for file in files:
7783
filename = os.path.join(root, file)
7884
if zip_filter(filename):
79-
arcname = os.path.join(os.path.relpath(root, relroot), file)
80-
# print(root, arcname)
85+
arcname = os.path.join(os.path.relpath(root, source_dir), file)
8186
zip.write(filename, arcname)
8287
return output_filename
8388

0 commit comments

Comments
 (0)