Merge pull request #135 from kiwix/zip_archive

Zip archive
This commit is contained in:
Matthieu Gautier 2018-03-21 15:16:26 +01:00 committed by GitHub
commit c828bc80f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -5,7 +5,7 @@ import shutil
from os import environ from os import environ
from pathlib import Path from pathlib import Path
from datetime import date from datetime import date
import tarfile import tarfile, zipfile
import subprocess import subprocess
import re import re
from urllib.request import urlretrieve from urllib.request import urlretrieve
@ -91,9 +91,15 @@ def make_archive(project, platform):
except FileExistsError: except FileExistsError:
pass pass
base_bin_dir = BASE_DIR/'INSTALL'/'bin' base_bin_dir = BASE_DIR/'INSTALL'/'bin'
with tarfile.open(str(archive), 'w:gz') as arch: if platform == "win32":
open_archive = lambda a : zipfile.ZipFile(str(a), 'w', compression=zipfile.ZIP_LZMA)
archive_add = lambda a, f : a.write(str(base_bin_dir/f), arcname=str(f))
else:
open_archive = lambda a : tarfile.open(str(a), 'w:gz')
archive_add = lambda a, f : a.add(str(base_bin_dir/f), arcname="{}/{}".format(archive_name, str(f)))
with open_archive(archive) as arch:
for f in file_to_archives: for f in file_to_archives:
arch.add(str(base_bin_dir/f), arcname=str(f)) archive_add(arch, f)
def make_deps_archive(target, full=False): def make_deps_archive(target, full=False):