1 | #
|
---|
2 | # setup.py
|
---|
3 | #
|
---|
4 | # Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
---|
5 | #
|
---|
6 | # This program is free software; you can redistribute it and/or modify
|
---|
7 | # it under the terms of the GNU General Public License as published by
|
---|
8 | # the Free Software Foundation; either version 3, or (at your option)
|
---|
9 | # any later version.
|
---|
10 | #
|
---|
11 | # This program is distributed in the hope that it will be useful,
|
---|
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | # GNU General Public License for more details.
|
---|
15 | #
|
---|
16 | # You should have received a copy of the GNU General Public License
|
---|
17 | # along with this program. If not, write to:
|
---|
18 | # The Free Software Foundation, Inc.,
|
---|
19 | # 51 Franklin Street, Fifth Floor
|
---|
20 | # Boston, MA 02110-1301, USA.
|
---|
21 | #
|
---|
22 |
|
---|
23 | import ez_setup
|
---|
24 | ez_setup.use_setuptools()
|
---|
25 | import glob
|
---|
26 |
|
---|
27 | from setuptools import setup, find_packages, Extension
|
---|
28 | from distutils import cmd, sysconfig
|
---|
29 | from distutils.command.build import build as _build
|
---|
30 | from distutils.command.clean import clean as _clean
|
---|
31 | from setuptools.command.install import install as _install
|
---|
32 |
|
---|
33 | import msgfmt
|
---|
34 | import os
|
---|
35 | import platform
|
---|
36 |
|
---|
37 | python_version = platform.python_version()[0:3]
|
---|
38 |
|
---|
39 | def windows_check():
|
---|
40 | return platform.system() in ('Windows', 'Microsoft')
|
---|
41 |
|
---|
42 | def osx_check():
|
---|
43 | return platform.system() == "Darwin"
|
---|
44 |
|
---|
45 | if not os.environ.has_key("CC"):
|
---|
46 | os.environ["CC"] = "gcc"
|
---|
47 |
|
---|
48 | if not os.environ.has_key("CXX"):
|
---|
49 | os.environ["CXX"] = "gcc"
|
---|
50 |
|
---|
51 | if not os.environ.has_key("CPP"):
|
---|
52 | os.environ["CPP"] = "g++"
|
---|
53 |
|
---|
54 | # The libtorrent extension
|
---|
55 | _extra_compile_args = [
|
---|
56 | "-D_FILE_OFFSET_BITS=64",
|
---|
57 | "-DNDEBUG",
|
---|
58 | "-DTORRENT_USE_OPENSSL=1",
|
---|
59 | "-O2",
|
---|
60 | ]
|
---|
61 |
|
---|
62 | if windows_check():
|
---|
63 | _extra_compile_args += [
|
---|
64 | "-D__USE_W32_SOCKETS",
|
---|
65 | "-D_WIN32_WINNT=0x0500",
|
---|
66 | "-D_WIN32",
|
---|
67 | "-DWIN32_LEAN_AND_MEAN",
|
---|
68 | "-DBOOST_ALL_NO_LIB",
|
---|
69 | "-DBOOST_THREAD_USE_LIB",
|
---|
70 | "-DBOOST_WINDOWS",
|
---|
71 | "-DBOOST_WINDOWS_API",
|
---|
72 | "-DWIN32",
|
---|
73 | "-DUNICODE",
|
---|
74 | "-D_UNICODE",
|
---|
75 | "-D_SCL_SECURE_NO_WARNINGS",
|
---|
76 | "/O2",
|
---|
77 | "/Ob2",
|
---|
78 | "/W3",
|
---|
79 | "/GR",
|
---|
80 | "/MD",
|
---|
81 | "/wd4675",
|
---|
82 | "/Zc:wchar_t",
|
---|
83 | "/Zc:forScope",
|
---|
84 | "/EHsc",
|
---|
85 | "-c",
|
---|
86 | ]
|
---|
87 | else:
|
---|
88 | _extra_compile_args += ["-Wno-missing-braces"]
|
---|
89 |
|
---|
90 | removals = ["-Wstrict-prototypes"]
|
---|
91 |
|
---|
92 | if not windows_check():
|
---|
93 | if python_version == '2.5':
|
---|
94 | cv_opt = sysconfig.get_config_vars()["CFLAGS"]
|
---|
95 | for removal in removals:
|
---|
96 | cv_opt = cv_opt.replace(removal, " ")
|
---|
97 | sysconfig.get_config_vars()["CFLAGS"] = " ".join(cv_opt.split())
|
---|
98 | else:
|
---|
99 | cv_opt = sysconfig.get_config_vars()["OPT"]
|
---|
100 | for removal in removals:
|
---|
101 | cv_opt = cv_opt.replace(removal, " ")
|
---|
102 | sysconfig.get_config_vars()["OPT"] = " ".join(cv_opt.split())
|
---|
103 |
|
---|
104 | _library_dirs = [
|
---|
105 | ]
|
---|
106 |
|
---|
107 | _include_dirs = [
|
---|
108 | './libtorrent',
|
---|
109 | './libtorrent/include',
|
---|
110 | './libtorrent/include/libtorrent'
|
---|
111 | ]
|
---|
112 |
|
---|
113 | if windows_check():
|
---|
114 | _include_dirs += ['./win32/include','./win32/include/openssl', './win32/include/zlib']
|
---|
115 | _library_dirs += ['./win32/lib']
|
---|
116 | _libraries = [
|
---|
117 | 'advapi32',
|
---|
118 | 'boost_filesystem-vc-mt-1_37',
|
---|
119 | 'boost_date_time-vc-mt-1_37',
|
---|
120 | 'boost_iostreams-vc-mt-1_37',
|
---|
121 | 'boost_python-vc-mt-1_37',
|
---|
122 | 'boost_system-vc-mt-1_37',
|
---|
123 | 'boost_thread-vc-mt-1_37',
|
---|
124 | 'gdi32',
|
---|
125 | 'libeay32',
|
---|
126 | 'ssleay32',
|
---|
127 | 'ws2_32',
|
---|
128 | 'wsock32',
|
---|
129 | 'zlib'
|
---|
130 | ]
|
---|
131 | else:
|
---|
132 | _include_dirs += [
|
---|
133 | '/usr/include/python' + python_version,
|
---|
134 | sysconfig.get_config_var("INCLUDEDIR")
|
---|
135 | ]
|
---|
136 | _library_dirs += [sysconfig.get_config_var("LIBDIR"), '/opt/local/lib']
|
---|
137 | if osx_check():
|
---|
138 | _include_dirs += [
|
---|
139 | '/opt/local/include/boost-1_35',
|
---|
140 | '/opt/local/include/boost-1_36'
|
---|
141 | ]
|
---|
142 | _libraries = [
|
---|
143 | 'boost_filesystem',
|
---|
144 | 'boost_date_time',
|
---|
145 | 'boost_iostreams',
|
---|
146 | 'boost_python',
|
---|
147 | 'boost_thread',
|
---|
148 | 'pthread',
|
---|
149 | 'ssl',
|
---|
150 | 'z'
|
---|
151 | ]
|
---|
152 |
|
---|
153 | if not windows_check():
|
---|
154 | dynamic_lib_extension = ".so"
|
---|
155 | if osx_check():
|
---|
156 | dynamic_lib_extension = ".dylib"
|
---|
157 |
|
---|
158 | _lib_extensions = ['-mt-1_36', '-mt-1_35', '-mt']
|
---|
159 |
|
---|
160 | # Modify the libs if necessary for systems with only -mt boost libs
|
---|
161 | for lib in _libraries:
|
---|
162 | if lib[:6] == "boost_":
|
---|
163 | for lib_prefix in _library_dirs:
|
---|
164 | for lib_suffix in _lib_extensions:
|
---|
165 | # If there is a -mt version use that
|
---|
166 | if os.path.exists(os.path.join(lib_prefix, "lib" + lib + lib_suffix + dynamic_lib_extension)):
|
---|
167 | _libraries[_libraries.index(lib)] = lib + lib_suffix
|
---|
168 | lib = lib + lib_suffix
|
---|
169 | break
|
---|
170 |
|
---|
171 | _sources = glob.glob("./libtorrent/src/*.cpp") + \
|
---|
172 | glob.glob("./libtorrent/src/*.c") + \
|
---|
173 | glob.glob("./libtorrent/src/kademlia/*.cpp") + \
|
---|
174 | glob.glob("./libtorrent/bindings/python/src/*.cpp")
|
---|
175 |
|
---|
176 | # Remove some files from the source that aren't needed
|
---|
177 | _source_removals = ["mapped_storage.cpp", "memdebug.cpp"]
|
---|
178 | to_remove = []
|
---|
179 | for source in _sources:
|
---|
180 | for rem in _source_removals:
|
---|
181 | if rem in source:
|
---|
182 | to_remove.append(source)
|
---|
183 |
|
---|
184 | for rem in to_remove:
|
---|
185 | _sources.remove(rem)
|
---|
186 |
|
---|
187 | _ext_modules = []
|
---|
188 |
|
---|
189 | # Check for a system libtorrent and if found, then do not build the libtorrent extension
|
---|
190 | build_libtorrent = True
|
---|
191 | try:
|
---|
192 | import libtorrent
|
---|
193 | except ImportError:
|
---|
194 | build_libtorrent = True
|
---|
195 | else:
|
---|
196 | if libtorrent.version_major == 0 and libtorrent.version_minor == 14:
|
---|
197 | build_libtorrent = False
|
---|
198 |
|
---|
199 | if build_libtorrent:
|
---|
200 | # There isn't a system libtorrent library, so let's build the one included with deluge
|
---|
201 | libtorrent = Extension(
|
---|
202 | 'libtorrent',
|
---|
203 | extra_compile_args = _extra_compile_args,
|
---|
204 | include_dirs = _include_dirs,
|
---|
205 | libraries = _libraries,
|
---|
206 | library_dirs = _library_dirs,
|
---|
207 | sources = _sources
|
---|
208 | )
|
---|
209 |
|
---|
210 | _ext_modules = [libtorrent]
|
---|
211 |
|
---|
212 | class build_trans(cmd.Command):
|
---|
213 | description = 'Compile .po files into .mo files'
|
---|
214 |
|
---|
215 | user_options = [
|
---|
216 | ('build-lib', None, "lib build folder")
|
---|
217 | ]
|
---|
218 |
|
---|
219 | def initialize_options(self):
|
---|
220 | self.build_lib = None
|
---|
221 |
|
---|
222 | def finalize_options(self):
|
---|
223 | self.set_undefined_options('build', ('build_lib', 'build_lib'))
|
---|
224 |
|
---|
225 | def run(self):
|
---|
226 | po_dir = os.path.join(os.path.dirname(__file__), 'deluge/i18n/')
|
---|
227 | for path, names, filenames in os.walk(po_dir):
|
---|
228 | for f in filenames:
|
---|
229 | if f.endswith('.po'):
|
---|
230 | lang = f[:len(f) - 3]
|
---|
231 | src = os.path.join(path, f)
|
---|
232 | dest_path = os.path.join(self.build_lib, 'deluge', 'i18n', lang, \
|
---|
233 | 'LC_MESSAGES')
|
---|
234 | dest = os.path.join(dest_path, 'deluge.mo')
|
---|
235 | if not os.path.exists(dest_path):
|
---|
236 | os.makedirs(dest_path)
|
---|
237 | if not os.path.exists(dest):
|
---|
238 | print('Compiling %s' % src)
|
---|
239 | msgfmt.make(src, dest)
|
---|
240 | else:
|
---|
241 | src_mtime = os.stat(src)[8]
|
---|
242 | dest_mtime = os.stat(dest)[8]
|
---|
243 | if src_mtime > dest_mtime:
|
---|
244 | print('Compiling %s' % src)
|
---|
245 | msgfmt.make(src, dest)
|
---|
246 |
|
---|
247 | class build_plugins(cmd.Command):
|
---|
248 | description = "Build plugins into .eggs"
|
---|
249 |
|
---|
250 | user_options = []
|
---|
251 |
|
---|
252 | def initialize_options(self):
|
---|
253 | pass
|
---|
254 |
|
---|
255 | def finalize_options(self):
|
---|
256 | pass
|
---|
257 |
|
---|
258 | def run(self):
|
---|
259 | # Build the plugin eggs
|
---|
260 | PLUGIN_PATH = "deluge/plugins/*"
|
---|
261 | if windows_check():
|
---|
262 | PLUGIN_PATH = "deluge\\plugins\\"
|
---|
263 |
|
---|
264 | for path in glob.glob(PLUGIN_PATH):
|
---|
265 | if os.path.exists(os.path.join(path, "setup.py")):
|
---|
266 | os.system("cd " + path + "&& python setup.py bdist_egg -d ..")
|
---|
267 |
|
---|
268 | class build(_build):
|
---|
269 | sub_commands = [('build_trans', None), ('build_plugins', None)] + _build.sub_commands
|
---|
270 | def run(self):
|
---|
271 | # Run all sub-commands (at least those that need to be run)
|
---|
272 | _build.run(self)
|
---|
273 |
|
---|
274 | class clean_plugins(cmd.Command):
|
---|
275 | description = "Cleans the plugin folders"
|
---|
276 | user_options = [
|
---|
277 | ('all', 'a', "remove all build output, not just temporary by-products")
|
---|
278 | ]
|
---|
279 | boolean_options = ['all']
|
---|
280 |
|
---|
281 | def initialize_options(self):
|
---|
282 | self.all = None
|
---|
283 |
|
---|
284 | def finalize_options(self):
|
---|
285 | self.set_undefined_options('clean', ('all', 'all'))
|
---|
286 |
|
---|
287 | def run(self):
|
---|
288 | print("Cleaning the plugin folders..")
|
---|
289 |
|
---|
290 | PLUGIN_PATH = "deluge/plugins/*"
|
---|
291 | if windows_check():
|
---|
292 | PLUGIN_PATH = "deluge\\plugins\\"
|
---|
293 |
|
---|
294 | for path in glob.glob(PLUGIN_PATH):
|
---|
295 | if os.path.exists(os.path.join(path, "setup.py")):
|
---|
296 | c = "cd " + path + "&& python setup.py clean"
|
---|
297 | if self.all:
|
---|
298 | c += " -a"
|
---|
299 | os.system(c)
|
---|
300 |
|
---|
301 | # Delete the .eggs
|
---|
302 | if path[-4:] == ".egg":
|
---|
303 | print("Deleting %s" % path)
|
---|
304 | os.remove(path)
|
---|
305 |
|
---|
306 | class clean(_clean):
|
---|
307 | sub_commands = _clean.sub_commands + [('clean_plugins', None)]
|
---|
308 |
|
---|
309 | def run(self):
|
---|
310 | # Run all sub-commands (at least those that need to be run)
|
---|
311 | for cmd_name in self.get_sub_commands():
|
---|
312 | self.run_command(cmd_name)
|
---|
313 | _clean.run(self)
|
---|
314 |
|
---|
315 | class install(_install):
|
---|
316 | def run(self):
|
---|
317 | for cmd_name in self.get_sub_commands():
|
---|
318 | self.run_command(cmd_name)
|
---|
319 | _install.run(self)
|
---|
320 | if not self.root:
|
---|
321 | self.do_egg_install()
|
---|
322 |
|
---|
323 | cmdclass = {
|
---|
324 | 'build': build,
|
---|
325 | 'build_trans': build_trans,
|
---|
326 | 'build_plugins': build_plugins,
|
---|
327 | 'clean_plugins': clean_plugins,
|
---|
328 | 'clean': clean,
|
---|
329 | 'install': install
|
---|
330 | }
|
---|
331 |
|
---|
332 | # Data files to be installed to the system
|
---|
333 | _data_files = [
|
---|
334 | ('share/icons/scalable/apps', ['deluge/data/icons/scalable/apps/deluge.svg']),
|
---|
335 | ('share/icons/hicolor/128x128/apps', ['deluge/data/icons/hicolor/128x128/apps/deluge.png']),
|
---|
336 | ('share/icons/hicolor/16x16/apps', ['deluge/data/icons/hicolor/16x16/apps/deluge.png']),
|
---|
337 | ('share/icons/hicolor/192x192/apps', ['deluge/data/icons/hicolor/192x192/apps/deluge.png']),
|
---|
338 | ('share/icons/hicolor/22x22/apps', ['deluge/data/icons/hicolor/22x22/apps/deluge.png']),
|
---|
339 | ('share/icons/hicolor/24x24/apps', ['deluge/data/icons/hicolor/24x24/apps/deluge.png']),
|
---|
340 | ('share/icons/hicolor/256x256/apps', ['deluge/data/icons/hicolor/256x256/apps/deluge.png']),
|
---|
341 | ('share/icons/hicolor/32x32/apps', ['deluge/data/icons/hicolor/32x32/apps/deluge.png']),
|
---|
342 | ('share/icons/hicolor/36x36/apps', ['deluge/data/icons/hicolor/36x36/apps/deluge.png']),
|
---|
343 | ('share/icons/hicolor/48x48/apps', ['deluge/data/icons/hicolor/48x48/apps/deluge.png']),
|
---|
344 | ('share/icons/hicolor/64x64/apps', ['deluge/data/icons/hicolor/64x64/apps/deluge.png']),
|
---|
345 | ('share/icons/hicolor/72x72/apps', ['deluge/data/icons/hicolor/72x72/apps/deluge.png']),
|
---|
346 | ('share/icons/hicolor/96x96/apps', ['deluge/data/icons/hicolor/96x96/apps/deluge.png']),
|
---|
347 | ('share/applications', ['deluge/data/share/applications/deluge.desktop']),
|
---|
348 | ('share/pixmaps', ['deluge/data/pixmaps/deluge.png', 'deluge/data/pixmaps/deluge.xpm']),
|
---|
349 | ('share/man/man1', ['deluge/docs/man/deluge.1', 'deluge/docs/man/deluged.1'])
|
---|
350 | ]
|
---|
351 |
|
---|
352 | # Main setup
|
---|
353 | setup(
|
---|
354 | author = "Andrew Resch, Marcos Pinto, Martijn Voncken, Damien Churchill",
|
---|
355 | author_email = "andrewresch@gmail.com, markybob@dipconsultants.com, mvoncken@gmail.com, damoxc@gmail.com",
|
---|
356 | cmdclass = cmdclass,
|
---|
357 | data_files = _data_files,
|
---|
358 | description = "Bittorrent Client",
|
---|
359 | long_description = """Deluge is a bittorrent client that utilizes a
|
---|
360 | daemon/client model. There are various user interfaces available for
|
---|
361 | Deluge such as the GTKui, the webui and a console ui. Deluge uses
|
---|
362 | libtorrent in it's backend to handle the bittorrent protocol.""",
|
---|
363 | keywords = "torrent bittorrent p2p fileshare filesharing",
|
---|
364 | entry_points = """
|
---|
365 | [console_scripts]
|
---|
366 | deluge = deluge.main:start_ui
|
---|
367 | deluged = deluge.main:start_daemon
|
---|
368 | """,
|
---|
369 | ext_package = "deluge",
|
---|
370 | ext_modules = _ext_modules,
|
---|
371 | fullname = "Deluge Bittorrent Client",
|
---|
372 | include_package_data = True,
|
---|
373 | license = "GPLv3",
|
---|
374 | name = "deluge",
|
---|
375 | package_data = {"deluge": ["ui/gtkui/glade/*.glade",
|
---|
376 | "data/pixmaps/*.png",
|
---|
377 | "data/pixmaps/*.svg",
|
---|
378 | "data/pixmaps/*.ico",
|
---|
379 | "data/pixmaps/flags/*.png",
|
---|
380 | "data/revision",
|
---|
381 | "data/GeoIP.dat",
|
---|
382 | "plugins/*.egg",
|
---|
383 | "i18n/*.pot",
|
---|
384 | "i18n/*/LC_MESSAGES/*.mo",
|
---|
385 | "ui/webui/scripts/*",
|
---|
386 | "ui/webui/static/*.css",
|
---|
387 | "ui/webui/static/*.js",
|
---|
388 | "ui/webui/static/images/*.png",
|
---|
389 | "ui/webui/static/images/*.jpg",
|
---|
390 | "ui/webui/static/images/*.gif",
|
---|
391 | "ui/webui/static/images/16/*.png",
|
---|
392 | "ui/webui/templates/deluge/*",
|
---|
393 | "ui/webui/templates/classic/*",
|
---|
394 | "ui/webui/templates/white/*",
|
---|
395 | "ui/webui/templates/ajax/*.cfg",
|
---|
396 | "ui/webui/templates/ajax/*.js",
|
---|
397 | "ui/webui/templates/ajax/*.html",
|
---|
398 | "ui/webui/templates/ajax/*.css",
|
---|
399 | "ui/webui/templates/ajax/render/html/*.html",
|
---|
400 | "ui/webui/templates/ajax/render/js/*",
|
---|
401 | "ui/webui/templates/ajax/static/css/*.css",
|
---|
402 | "ui/webui/templates/ajax/static/icons/16/*.png",
|
---|
403 | "ui/webui/templates/ajax/static/icons/32/*.png",
|
---|
404 | "ui/webui/templates/ajax/static/images/*.gif",
|
---|
405 | "ui/webui/templates/ajax/static/js/*.js",
|
---|
406 | "ui/webui/templates/ajax/static/themes/classic/*.png",
|
---|
407 | "ui/webui/templates/ajax/static/themes/classic/*.css",
|
---|
408 | "ui/webui/templates/ajax/static/themes/classic/mime_icons/*.png",
|
---|
409 | "ui/webui/templates/ajax/static/themes/white/*.png",
|
---|
410 | "ui/webui/templates/ajax/static/themes/white/*.css",
|
---|
411 | "ui/webui/templates/ajax/static/themes/white/mime_icons/*.png",
|
---|
412 | ]},
|
---|
413 | packages = find_packages(exclude=["plugins"]),
|
---|
414 | url = "http://deluge-torrent.org",
|
---|
415 | version = "1.1.1",
|
---|
416 | )
|
---|