Fix creating zip distribution on Windows.

This commit is contained in:
Cheng Zhao 2013-10-26 17:23:16 +08:00
parent 887a2a3c00
commit 3ddba90d94
2 changed files with 9 additions and 5 deletions

View file

@ -136,10 +136,9 @@ def create_zip():
zip_file = os.path.join(SOURCE_ROOT, 'dist', dist_name) zip_file = os.path.join(SOURCE_ROOT, 'dist', dist_name)
with scoped_cwd(DIST_DIR): with scoped_cwd(DIST_DIR):
files = TARGET_BINARIES[TARGET_PLATFORM] + \ files = TARGET_BINARIES[TARGET_PLATFORM] + ['LICENSE', 'version']
TARGET_DIRECTORIES[TARGET_PLATFORM] + \ dirs = TARGET_DIRECTORIES[TARGET_PLATFORM]
['LICENSE', 'version'] make_zip(zip_file, files, dirs)
make_zip(zip_file, files)
def create_header_tarball(): def create_header_tarball():

View file

@ -64,14 +64,19 @@ def extract_zip(zip_path, destination):
with zipfile.ZipFile(zip_path) as z: with zipfile.ZipFile(zip_path) as z:
z.extractall(destination) z.extractall(destination)
def make_zip(zip_file_path, files): def make_zip(zip_file_path, files, dirs):
safe_unlink(zip_file_path) safe_unlink(zip_file_path)
if sys.platform == 'darwin': if sys.platform == 'darwin':
files += dirs
subprocess.check_call(['zip', '-r', '-y', zip_file_path] + files) subprocess.check_call(['zip', '-r', '-y', zip_file_path] + files)
else: else:
zip_file = zipfile.ZipFile(zip_file_path, "w") zip_file = zipfile.ZipFile(zip_file_path, "w")
for filename in files: for filename in files:
zip_file.write(filename, filename) 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() zip_file.close()