-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetup.py
148 lines (133 loc) · 4.73 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# -*- coding: latin-1 -*-
import application
__author__ = "Alberto Malagoli"
from PyQt4.QtCore import QSettings
from cx_Freeze import setup, Executable
from glob import glob
import os.path
import os
import shutil
import sys
import platform
sys.path.append('src')
import utils
## change setting first_time before building
# load settings
settings = QSettings("src/preferences.ini", QSettings.IniFormat)
# save value on settings file
settings.setValue("first_time", True)
settings.setValue("stats_agreement", 1)
settings.setValue("duration_representation", 0)
settings.setValue("language_representation", 1)
settings.setValue("words_separator", 0)
settings.setValue("last_visited_directory", "")
settings.setValue("renaming_rule", "title.(.year.duration.language.)")
settings.sync()
if os.path.isdir('build'):
print("removing build path...")
shutil.rmtree('build')
if os.path.isdir('src/log'):
print("removing log path...")
shutil.rmtree('src/log')
includes = [
'enzyme',
]
excludes = [
'email',
'unittest',
'_hashlib',
'_ssl',
'_sqlite3',
'sqlite3',
'sqlobject',
'bz2',
'select',
'_codecs_cn',
'_codecs_hk',
'_codecs_iso2022',
'_codecs_jp',
'_codecs_kr',
'_codecs_tw',
'_ctypes',
'_heapq',
'sqlalchemy.cprocessors',
'sqlalchemy.cresultproxy',
'PyQt4._qt',
'_json',
'_multibytecodec',
'termios'
]
include_files = [
("src/enzyme", "enzyme"),
("src/icons", "icons"),
("src/translations", "qm"),
("src/main_window.ui", "main_window.ui"),
("src/preferences_dialog.ui", "preferences_dialog.ui"),
("src/renaming_rule_dialog.ui", "renaming_rule_dialog.ui"),
("src/stats_agreement_dialog.ui", "stats_agreement_dialog.ui"),
("src/preferences.ini", "preferences.ini"),
("src/languages.txt", "languages.txt"),
"Changelog.md",
"gpl-3.0.txt",
"README.txt",
]
exclude_files = [
"QtNetwork4.dll",
"QtWebKit4.dll",
"libphonon.so.4",
"libQtDBus.so.4",
"libQtDeclarative.so.4",
"libQtMultimedia.so.4",
"libQtScript.so.4",
"libQtScriptTools.so.4",
"libQtSql.so.4",
"libQtSvg.so.4",
"libQtTest.so.4",
"libQtWebKit.so.4",
"libQtNetwork.so.4",
"libQtXml.so.4",
"libQtXml.so.4",
"libQtXmlPatterns.so.4",
]
base = None
target_name = application.NAME
archive_format = "gztar"
if sys.platform == "win32":
base = "Win32GUI"
target_name += ".exe"
archive_format = "zip"
setup(
name =application.NAME,
version =application.VERSION,
author = "Alberto Malagoli",
author_email = '[email protected]',
url = 'https://code.google.com/p/almoviesrenamer/',
options = dict(
build_exe = {"includes": includes,
"excludes": excludes,
"include_files": include_files,
"bin_excludes": exclude_files,
"optimize": 2,
"compressed": True, # Compress library.zip
"create_shared_zip": True
}),
executables = [Executable(
script = "src/main.py",
base = base,
targetName = target_name,
icon = "src/icons/brand.ico",
compress = True,
)]
)
shutil.rmtree(glob("build/exe*")[0] + '/PyQt4.uic.widget-plugins')
archive_name = "dist/{0}-{1}-{2}" \
.format(application.NAME, application.VERSION, platform.system())
archive_file_name = glob("{0}*".format(archive_name))
if len(archive_file_name) > 0 \
and os.path.isfile(archive_file_name[0]):
print("remove previously created archive")
os.remove(archive_file_name[0])
root_dir = glob("build/exe*")[0]
print("create " + archive_format + " " + archive_name)
shutil.make_archive(archive_name, archive_format, root_dir)
print("END")