-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.py
More file actions
188 lines (157 loc) · 4.94 KB
/
Copy pathsetup.py
File metadata and controls
188 lines (157 loc) · 4.94 KB
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# -*- coding: utf-8 -*-
try:
from setuptools import setup
except ImportError:
print "WARNING: Failing back to distutils"
from distutils.core import setup
import sys
import os.path
import shutil
import glob
import zipfile
APP_NAME = 'metalinkc'
VERSION = '6.2'
LICENSE = 'GPL'
DESC = 'A metalink checker and download client.'
AUTHOR_NAME = 'Neil McNab'
EMAIL = 'nabber00@gmail.com'
URL = 'https://github.com/metalink-dev/pymetalink'
PYMETALINK_URL = "https://github.com/metalink-dev/pymetalink/releases/download/v6.2/pymetalink-6.2.zip"
def clean():
ignore = []
filelist = []
filelist.extend(glob.glob("*metalink*.txt"))
filelist.extend(rec_search(".exe"))
filelist.extend(rec_search(".zip"))
filelist.extend(rec_search(".pyc"))
filelist.extend(rec_search(".pyo"))
filelist.extend(rec_search(".mo"))
filelist.extend(rec_search(".pot"))
try:
shutil.rmtree("build")
except: pass
try:
shutil.rmtree(APP_NAME.replace('-','_') + ".egg-info")
except: pass
try:
shutil.rmtree("dist")
except: pass
try:
shutil.rmtree("buildMetalink")
except: pass
try:
shutil.rmtree("buildmetalinkw")
except: pass
try:
shutil.rmtree("tests_temp")
except: pass
for filename in filelist:
if filename not in ignore:
try:
os.remove(filename)
except: pass
def create_zip(rootpath, zipname, mode="w"):
print zipname
myzip = zipfile.ZipFile(zipname, mode, zipfile.ZIP_DEFLATED)
for root, dirs, files in os.walk(rootpath):
for filename in files:
filepath = os.path.join(root, filename)
filehandle = open(filepath, "rb")
filepath = filepath[len(rootpath):]
text = filehandle.read()
#print filepath, len(text)
myzip.writestr(filepath, text)
filehandle.close()
myzip.close()
def localegen():
localedir = "locale"
ignore = ("setup.py", "test.py")
files = rec_search(".py")
for pyfile in files:
if os.path.basename(pyfile) not in ignore:
potdir = os.path.join(os.path.dirname(pyfile), localedir, os.path.basename(pyfile))[:-3]
print potdir
try:
os.makedirs(os.path.join(os.path.dirname(pyfile), localedir))
except: pass
command = os.path.join(sys.prefix, "Tools/i18n/pygettext.py") + " --no-location -d \"%s\" \"%s\"" % (potdir, pyfile)
print(command)
result = os.system(command)
if result != 0:
raise AssertionError, "Generation of .pot file failed for %s." % pyfile
def localecompile():
files = rec_search(".po")
for pofile in files:
command = os.path.join(sys.prefix, "Tools/i18n/msgfmt.py") + " \"%s\"" % pofile
print(command)
result = os.system(command)
if result != 0:
raise AssertionError, "Generation of .mo file failed for %s." % pofile
def rec_search(end, abspath = True):
start = os.path.dirname(__file__)
if not start:
start = '.'
mylist = []
for root, dirs, files in os.walk(start):
for filename in files:
if filename.endswith(end):
if abspath:
mylist.append(os.path.join(root, filename))
else:
mylist.append(os.path.join(root[len(start):], filename))
return mylist
if sys.argv[1] == 'translate':
localegen()
localecompile()
elif sys.argv[1] == 'clean':
clean()
elif sys.argv[1] == 'zip':
#print "Zipping up..."
create_zip("dist/", APP_NAME + "-" + VERSION + "-win32.zip")
elif sys.argv[1] == 'py2exe':
import py2exe
#localegen()
#localecompile()
setup(console = ["metalinkc.py"],
zipfile = None,
packages = ['metalinkc'],
dependency_links=[PYMETALINK_URL],
install_requires=['pymetalink'],
name = APP_NAME,
version = VERSION,
license = LICENSE,
description = DESC,
author = AUTHOR_NAME,
author_email = EMAIL,
url = URL
)
setup(windows = ["metalinkcw.py"],
zipfile = None,
packages = ['metalinkc'],
dependency_links=[PYMETALINK_URL],
install_requires=['pymetalink'],
name = APP_NAME,
version = VERSION,
license = LICENSE,
description = DESC,
author = AUTHOR_NAME,
author_email = EMAIL,
url = URL
)
else:
#scripts = rec_search(".py")
#localegen()
scripts = ['metalinkc.py', 'metalinkcw.py']
setup(scripts = scripts,
dependency_links=[PYMETALINK_URL],
install_requires=['pymetalink'],
packages = ['metalinkc'],
#data_files = data,
name = APP_NAME,
version = VERSION,
license = LICENSE,
description = DESC,
author = AUTHOR_NAME,
author_email = EMAIL,
url = URL
)