def zipfolder(foldername, target_dir, zips_dir, addon_dir):
    zipobj = zipfile.ZipFile(zips_dir + foldername, 'w', zipfile.ZIP_DEFLATED)
    rootlen = len(target_dir) + 1
    for base, dirs, files in os.walk(target_dir):
        for f in files:
            fn = os.path.join(base, f)
            zipobj.write(fn, os.path.join(addon_dir, fn[rootlen:]))
    zipobj.close()