-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
setup.py
77 lines (60 loc) · 2.67 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
"""
Most of this build process was copied from DigitalArc's Guardian project.
https://gitlab.com/digitalarc/guardian/-/blob/master/setup.py
"""
from cx_Freeze import setup, Executable
import sys
import zipfile
import os
import shutil
zip_exclude_packages = ['pydivert']
build_options = dict(packages=[], includes=['pydivert'],
replace_paths=[("*", "")], optimize=2, zip_include_packages="*",
zip_exclude_packages=zip_exclude_packages, silent=True)
executables = [
Executable('main.py', targetName="SCBlocker.exe", icon="icon.ico", uac_admin=True,
copyright='Copyright (C) 2023 Daniel Summer')
]
version = "0.2.0"
build_path = 'build/exe.win-amd64-{}.{}'.format(sys.version_info.major, sys.version_info.minor)
if os.path.exists(build_path):
shutil.rmtree(build_path)
if not os.path.exists('build/exe'):
os.makedirs('build/exe')
if os.path.isfile('build/exe/guardian-{}.zip'.format(version)):
os.remove('build/exe/guardian-{}.zip'.format(version))
setup(name='SocialClub Notification Blocker',
version=version,
description="Prevents SocialClub Notification Spam",
options=dict(build_exe=build_options),
executables=executables)
def zip_folder(folder_path, output_path):
"""Zip the contents of an entire folder (with that folder included
in the archive). Empty subfolders will be included in the archive
as well.
This function was copied from DigitalArc's Guardian project under the LGPLv3 license.
https://gitlab.com/digitalarc/guardian/-/blob/master/LICENSE
"""
parent_folder = os.path.dirname(folder_path)
# Retrieve the paths of the folder contents.
contents = os.walk(folder_path, )
zip_file = zipfile.ZipFile(output_path, 'w', zipfile.ZIP_DEFLATED)
for root, folders, files in contents:
# Include all subfolders, including empty ones.
for folder_name in folders:
absolute_path = os.path.join(root, folder_name)
relative_path = absolute_path.replace(parent_folder + '\\',
'')
zip_file.write(absolute_path, relative_path.replace(build_path, ''))
for file_name in files:
absolute_path = os.path.join(root, file_name)
relative_path = absolute_path.replace(parent_folder + '\\',
'')
zip_file.write(absolute_path, relative_path.replace(build_path, ''))
zip_file.close()
try:
shutil.copyfile('LICENSE', build_path + '/LICENSE')
shutil.copyfile('SOURCE', build_path + '/SOURCE')
except:
pass
zip_folder(build_path, 'build\exe\SocialClubBlocker-{}.zip'.format(version))