From 3ddba90d94d0bee4ed27c2430e0ae96f5223ad45 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 26 Oct 2013 17:23:16 +0800 Subject: [PATCH] Fix creating zip distribution on Windows. --- script/create-dist.py | 7 +++---- script/lib/util.py | 7 ++++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/script/create-dist.py b/script/create-dist.py index a948def2..0081bc37 100755 --- a/script/create-dist.py +++ b/script/create-dist.py @@ -136,10 +136,9 @@ def create_zip(): zip_file = os.path.join(SOURCE_ROOT, 'dist', dist_name) with scoped_cwd(DIST_DIR): - files = TARGET_BINARIES[TARGET_PLATFORM] + \ - TARGET_DIRECTORIES[TARGET_PLATFORM] + \ - ['LICENSE', 'version'] - make_zip(zip_file, files) + files = TARGET_BINARIES[TARGET_PLATFORM] + ['LICENSE', 'version'] + dirs = TARGET_DIRECTORIES[TARGET_PLATFORM] + make_zip(zip_file, files, dirs) def create_header_tarball(): diff --git a/script/lib/util.py b/script/lib/util.py index 411bce8a..af714686 100644 --- a/script/lib/util.py +++ b/script/lib/util.py @@ -64,14 +64,19 @@ def extract_zip(zip_path, destination): with zipfile.ZipFile(zip_path) as z: z.extractall(destination) -def make_zip(zip_file_path, files): +def make_zip(zip_file_path, files, dirs): safe_unlink(zip_file_path) if sys.platform == 'darwin': + files += dirs subprocess.check_call(['zip', '-r', '-y', zip_file_path] + files) else: zip_file = zipfile.ZipFile(zip_file_path, "w") for filename in files: zip_file.write(filename, filename) + for dirname in dirs: + for root, _, filenames in os.walk(dirname): + for f in filenames: + zip_file.write(os.path.join(root, f)) zip_file.close() -- 2.43.0