2007-01-08 04:18:24 +00:00
|
|
|
# Copyright (c) 2006 Zach Tibbitts ('zachtib') <zach@collegegeek.org>
|
2006-11-29 23:41:58 +00:00
|
|
|
#
|
2006-12-01 23:03:00 +00:00
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
# any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
2007-01-08 19:38:19 +00:00
|
|
|
#
|
2006-12-01 23:03:00 +00:00
|
|
|
# You should have received a copy of the GNU General Public License
|
2007-01-08 19:38:19 +00:00
|
|
|
# along with this program. If not, write to:
|
|
|
|
# The Free Software Foundation, Inc.,
|
|
|
|
# 51 Franklin Street, Fifth Floor
|
|
|
|
# Boston, MA 02110-1301, USA.
|
2006-12-01 23:03:00 +00:00
|
|
|
|
2007-03-27 20:32:45 +00:00
|
|
|
import os, platform
|
|
|
|
print "Attempting to detect your system information"
|
|
|
|
if platform.machine() == "i386" or platform.machine() == "i686":
|
|
|
|
print "32bit x86 system detected"
|
|
|
|
ARCH = "x86"
|
2007-03-28 22:45:25 +00:00
|
|
|
elif platform.machine() == "x86_64" or platform.machine() == "amd64":
|
2007-03-27 20:32:45 +00:00
|
|
|
print "64bit x86_64 system detected"
|
|
|
|
ARCH = "x64"
|
|
|
|
elif platform.processor() == "powerpc":
|
|
|
|
print "PowerPC system detected"
|
|
|
|
ARCH = "ppc"
|
|
|
|
else:
|
|
|
|
print "Couldn't detect CPU architecture"
|
|
|
|
ARCH = ""
|
|
|
|
if platform.system() == "Linux":
|
|
|
|
print "Linux operating system detected"
|
|
|
|
OS = "linux"
|
|
|
|
elif platform.system() == "Darwin" :
|
|
|
|
print "Darwin / OS X system detected"
|
|
|
|
OS = "osx"
|
|
|
|
elif platform.system() == "Windows":
|
|
|
|
print "Windows system detected"
|
|
|
|
OS = "win"
|
|
|
|
elif os.name == "posix":
|
|
|
|
print "Unix system detected"
|
|
|
|
OS = "nix"
|
|
|
|
else:
|
|
|
|
print "Couldn't detect operating system"
|
|
|
|
OS = ""
|
|
|
|
import os.path, glob
|
2007-02-12 21:30:54 +00:00
|
|
|
from distutils.core import setup, Extension
|
2007-01-11 18:58:28 +00:00
|
|
|
from distutils import sysconfig
|
2007-03-05 20:44:53 +00:00
|
|
|
import shutil
|
|
|
|
from distutils import cmd
|
|
|
|
from distutils.command.install import install as _install
|
|
|
|
from distutils.command.install_data import install_data as _install_data
|
|
|
|
from distutils.command.build import build as _build
|
|
|
|
import msgfmt
|
2007-01-11 18:58:28 +00:00
|
|
|
|
2007-03-27 20:32:45 +00:00
|
|
|
python_version = platform.python_version()[0:3]
|
2007-02-19 23:02:23 +00:00
|
|
|
|
2007-05-23 19:51:21 +00:00
|
|
|
NAME = "deluge"
|
|
|
|
FULLNAME = "Deluge BitTorrent Client"
|
2007-03-18 16:35:04 +00:00
|
|
|
VERSION = "0.5.0"
|
2007-05-23 14:32:04 +00:00
|
|
|
AUTHOR = "Zach Tibbitts, Alon Zakai, Marcos Pinto"
|
2007-05-23 19:51:21 +00:00
|
|
|
EMAIL = "zach@collegegeek.org, kripkensteiner@gmail.com, marcospinto@dipconsultants.com"
|
2007-03-08 18:36:57 +00:00
|
|
|
DESCRIPTION = "A bittorrent client written in PyGTK"
|
2007-05-23 19:51:21 +00:00
|
|
|
URL = "http://deluge-torrent.org"
|
2007-03-08 18:36:57 +00:00
|
|
|
LICENSE = "GPLv2"
|
2007-03-02 00:33:15 +00:00
|
|
|
|
2007-03-27 20:32:45 +00:00
|
|
|
EXTRA_COMPILE_ARGS = ["-Wno-missing-braces"]
|
|
|
|
if ARCH == "x64":
|
|
|
|
EXTRA_COMPILE_ARGS.append("-DAMD64")
|
|
|
|
|
|
|
|
|
2007-03-02 00:33:15 +00:00
|
|
|
# NOTE: The following "hack" removes the -g and -Wstrict-prototypes
|
|
|
|
# build options from the command that will compile the C++ module,
|
|
|
|
# deluge_core. While we understand that you aren't generally
|
|
|
|
# encouraged to do this, we have done so for the following reasons:
|
|
|
|
# 1) The -g compiler option produces debugging information about
|
|
|
|
# the compiled module. However, this option increases the
|
|
|
|
# size of deluge_core.so from ~1.9MB to 13.6MB and slows down
|
|
|
|
# the program's execution without offering any benefits
|
|
|
|
# whatsoever.
|
|
|
|
# 2) -Wstrict-prototypes is not a valid C++ build option, and the
|
|
|
|
# compiler will throw a number of warnings at compile time.
|
|
|
|
# While this does not really impact anything, it makes it
|
|
|
|
# seem as if something is going wrong with the compile, and
|
|
|
|
# it has been removed to prevent confusion.
|
|
|
|
|
2007-03-27 22:13:09 +00:00
|
|
|
if not OS == "win":
|
2007-05-23 19:51:21 +00:00
|
|
|
|
2007-05-24 06:57:37 +00:00
|
|
|
if os.WEXITSTATUS(os.system('grep -q "Debian GNU/Linux 4.0\|Ubuntu 7.04\|Ubuntu 6.06" /etc/issue')) == 0:
|
2007-05-23 19:51:21 +00:00
|
|
|
boosttype = 'nomt'
|
|
|
|
else:
|
|
|
|
boosttype = 'mt'
|
2007-03-27 22:13:09 +00:00
|
|
|
removals = ['-g', '-DNDEBUG', '-O2', '-Wstrict-prototypes']
|
|
|
|
additions = ['-DNDEBUG', '-O2']
|
2007-01-11 18:58:28 +00:00
|
|
|
|
2007-03-27 22:13:09 +00:00
|
|
|
if python_version == '2.5':
|
|
|
|
cv_opt = sysconfig.get_config_vars()["CFLAGS"]
|
|
|
|
for removal in removals:
|
|
|
|
cv_opt = cv_opt.replace(removal, " ")
|
|
|
|
for addition in additions:
|
|
|
|
cv_opt = cv_opt + " " + addition
|
|
|
|
sysconfig.get_config_vars()["CFLAGS"] = ' '.join(cv_opt.split())
|
|
|
|
else:
|
|
|
|
cv_opt = sysconfig.get_config_vars()["OPT"]
|
|
|
|
for removal in removals:
|
|
|
|
cv_opt = cv_opt.replace(removal, " ")
|
|
|
|
for addition in additions:
|
|
|
|
cv_opt = cv_opt + " " + addition
|
|
|
|
sysconfig.get_config_vars()["OPT"] = ' '.join(cv_opt.split())
|
2007-05-23 19:51:21 +00:00
|
|
|
else:
|
|
|
|
librariestype = 'mt'
|
2007-01-11 18:58:28 +00:00
|
|
|
|
2007-03-02 00:33:15 +00:00
|
|
|
# NOTE: The Rasterbar Libtorrent source code is in the libtorrent/ directory
|
|
|
|
# inside of Deluge's source tarball. On several occasions, it has been
|
|
|
|
# pointed out to us that we should build against the system's installed
|
|
|
|
# libtorrent rather than our internal copy, and a few people even submitted
|
|
|
|
# patches to do just that. However, as of now, this version
|
|
|
|
# of libtorrent is not available in Debian, and as a result, Ubuntu. Once
|
|
|
|
# libtorrent-rasterbar is available in the repositories of these distributions,
|
|
|
|
# we will probably begin to build against a system libtorrent, but at the
|
|
|
|
# moment, we are including the source code to make packaging on Debian and
|
|
|
|
# Ubuntu possible.
|
2007-05-23 19:51:21 +00:00
|
|
|
if boosttype == "nomt":
|
|
|
|
librariestype = ['boost_filesystem', 'boost_date_time',
|
|
|
|
'boost_regex', 'boost_serialization',
|
|
|
|
'boost_thread',
|
|
|
|
'z', 'pthread']
|
|
|
|
print 'Libraries nomt'
|
|
|
|
elif boosttype == "mt":
|
|
|
|
librariestype = ['boost_filesystem-mt', 'boost_date_time-mt',
|
|
|
|
'boost_regex-mt', 'boost_serialization-mt',
|
|
|
|
'boost_thread-mt',
|
|
|
|
'z', 'pthread']
|
|
|
|
print 'Libraries mt'
|
2007-03-08 18:36:57 +00:00
|
|
|
|
2007-01-08 17:23:21 +00:00
|
|
|
deluge_core = Extension('deluge_core',
|
2007-03-02 00:33:15 +00:00
|
|
|
include_dirs = ['./libtorrent', './libtorrent/include',
|
|
|
|
'./libtorrent/include/libtorrent',
|
2007-03-27 20:32:45 +00:00
|
|
|
'/usr/include/python' + python_version],
|
2007-05-23 19:51:21 +00:00
|
|
|
libraries = librariestype,
|
2007-03-27 20:32:45 +00:00
|
|
|
extra_compile_args = EXTRA_COMPILE_ARGS,
|
2007-02-08 18:42:01 +00:00
|
|
|
sources = ['src/deluge_core.cpp',
|
2007-02-26 23:56:17 +00:00
|
|
|
'libtorrent/src/alert.cpp',
|
|
|
|
'libtorrent/src/allocate_resources.cpp',
|
2007-05-23 02:39:03 +00:00
|
|
|
'libtorrent/src/bandwidth_manager.cpp',
|
2007-02-26 23:56:17 +00:00
|
|
|
'libtorrent/src/bt_peer_connection.cpp',
|
|
|
|
'libtorrent/src/entry.cpp',
|
|
|
|
'libtorrent/src/escape_string.cpp',
|
|
|
|
'libtorrent/src/file.cpp',
|
2007-05-23 02:39:03 +00:00
|
|
|
'libtorrent/src/file_pool.cpp',
|
2007-02-26 23:56:17 +00:00
|
|
|
'libtorrent/src/http_tracker_connection.cpp',
|
|
|
|
'libtorrent/src/identify_client.cpp',
|
|
|
|
'libtorrent/src/ip_filter.cpp',
|
2007-05-23 02:39:03 +00:00
|
|
|
'libtorrent/src/logger.cpp',
|
|
|
|
'libtorrent/src/metadata_transfer.cpp',
|
2007-02-26 23:56:17 +00:00
|
|
|
'libtorrent/src/peer_connection.cpp',
|
|
|
|
'libtorrent/src/piece_picker.cpp',
|
|
|
|
'libtorrent/src/policy.cpp',
|
|
|
|
'libtorrent/src/session.cpp',
|
|
|
|
'libtorrent/src/session_impl.cpp',
|
|
|
|
'libtorrent/src/sha1.cpp',
|
|
|
|
'libtorrent/src/stat.cpp',
|
|
|
|
'libtorrent/src/storage.cpp',
|
|
|
|
'libtorrent/src/torrent.cpp',
|
|
|
|
'libtorrent/src/torrent_handle.cpp',
|
|
|
|
'libtorrent/src/torrent_info.cpp',
|
|
|
|
'libtorrent/src/tracker_manager.cpp',
|
|
|
|
'libtorrent/src/udp_tracker_connection.cpp',
|
2007-05-23 02:39:03 +00:00
|
|
|
'libtorrent/src/ut_pex.cpp',
|
2007-02-26 23:56:17 +00:00
|
|
|
'libtorrent/src/web_peer_connection.cpp',
|
|
|
|
'libtorrent/src/kademlia/closest_nodes.cpp',
|
|
|
|
'libtorrent/src/kademlia/dht_tracker.cpp',
|
|
|
|
'libtorrent/src/kademlia/find_data.cpp',
|
|
|
|
'libtorrent/src/kademlia/node.cpp',
|
|
|
|
'libtorrent/src/kademlia/node_id.cpp',
|
|
|
|
'libtorrent/src/kademlia/refresh.cpp',
|
|
|
|
'libtorrent/src/kademlia/routing_table.cpp',
|
|
|
|
'libtorrent/src/kademlia/rpc_manager.cpp',
|
|
|
|
'libtorrent/src/kademlia/traversal_algorithm.cpp'])
|
2007-01-07 22:50:26 +00:00
|
|
|
|
2007-03-20 02:18:32 +00:00
|
|
|
upnp = Extension('upnp',
|
|
|
|
include_dirs = ['./miniupnpc'],
|
|
|
|
sources=['src/python-upnp.c',
|
|
|
|
'miniupnpc/igd_desc_parse.c',
|
|
|
|
'miniupnpc/minisoap.c',
|
|
|
|
'miniupnpc/miniupnpc.c',
|
|
|
|
'miniupnpc/miniwget.c',
|
|
|
|
'miniupnpc/minixml.c',
|
|
|
|
'miniupnpc/minixmlvalid.c',
|
|
|
|
'miniupnpc/upnpcommands.c',
|
|
|
|
'miniupnpc/upnpreplyparse.c'])
|
|
|
|
|
2007-02-28 06:09:32 +00:00
|
|
|
# Thanks to Iain Nicol for code to save the location for installed prefix
|
2007-02-26 23:56:17 +00:00
|
|
|
# At runtime, we need to know where we installed the data to.
|
2007-03-05 20:44:53 +00:00
|
|
|
|
2007-02-26 23:56:17 +00:00
|
|
|
class write_data_install_path(cmd.Command):
|
|
|
|
description = 'saves the data installation path for access at runtime'
|
|
|
|
|
|
|
|
def initialize_options(self):
|
2007-03-08 18:36:57 +00:00
|
|
|
self.prefix = None
|
2007-02-26 23:56:17 +00:00
|
|
|
self.lib_build_dir = None
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
self.set_undefined_options('install',
|
2007-03-08 18:36:57 +00:00
|
|
|
('prefix', 'prefix')
|
|
|
|
)
|
2007-02-26 23:56:17 +00:00
|
|
|
self.set_undefined_options('build',
|
|
|
|
('build_lib', 'lib_build_dir')
|
|
|
|
)
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
conf_filename = os.path.join(self.lib_build_dir,
|
2007-03-26 21:09:39 +00:00
|
|
|
'deluge', 'common.py')
|
2007-02-26 23:56:17 +00:00
|
|
|
|
|
|
|
conf_file = open(conf_filename, 'r')
|
|
|
|
data = conf_file.read()
|
|
|
|
conf_file.close()
|
2007-03-08 18:36:57 +00:00
|
|
|
data = data.replace('@datadir@', self.prefix)
|
2007-02-26 23:56:17 +00:00
|
|
|
|
|
|
|
conf_file = open(conf_filename, 'w')
|
|
|
|
conf_file.write(data)
|
|
|
|
conf_file.close()
|
|
|
|
|
|
|
|
class unwrite_data_install_path(cmd.Command):
|
|
|
|
description = 'undoes write_data_install_path'
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
self.lib_build_dir = None
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
self.set_undefined_options('build',
|
|
|
|
('build_lib', 'lib_build_dir')
|
|
|
|
)
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
dest = os.path.join(self.lib_build_dir,
|
2007-03-26 21:09:39 +00:00
|
|
|
'deluge', 'common.py')
|
|
|
|
shutil.copyfile('src/common.py', dest)
|
2007-02-26 23:56:17 +00:00
|
|
|
|
2007-03-05 20:44:53 +00:00
|
|
|
class build_trans(cmd.Command):
|
|
|
|
description = 'Compile .po files into .mo files'
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
po_dir = os.path.join(os.path.dirname(__file__), 'po')
|
|
|
|
for path, names, filenames in os.walk(po_dir):
|
|
|
|
for f in filenames:
|
|
|
|
if f.endswith('.po'):
|
|
|
|
lang = f[:len(f) - 3]
|
|
|
|
src = os.path.join(path, f)
|
|
|
|
dest_path = os.path.join('build', 'locale', lang, 'LC_MESSAGES')
|
|
|
|
dest = os.path.join(dest_path, 'deluge.mo')
|
|
|
|
if not os.path.exists(dest_path):
|
|
|
|
os.makedirs(dest_path)
|
|
|
|
if not os.path.exists(dest):
|
|
|
|
print 'Compiling %s' % src
|
|
|
|
msgfmt.make(src, dest)
|
|
|
|
else:
|
|
|
|
src_mtime = os.stat(src)[8]
|
|
|
|
dest_mtime = os.stat(dest)[8]
|
|
|
|
if src_mtime > dest_mtime:
|
|
|
|
print 'Compiling %s' % src
|
|
|
|
msgfmt.make(src, dest)
|
|
|
|
|
|
|
|
class build(_build):
|
|
|
|
sub_commands = _build.sub_commands + [('build_trans', None)]
|
|
|
|
def run(self):
|
|
|
|
_build.run(self)
|
|
|
|
|
2007-02-26 23:56:17 +00:00
|
|
|
class install(_install):
|
|
|
|
sub_commands = [('write_data_install_path', None)] + \
|
|
|
|
_install.sub_commands + [('unwrite_data_install_path', None)]
|
2007-03-05 20:44:53 +00:00
|
|
|
def run(self):
|
|
|
|
_install.run(self)
|
|
|
|
|
|
|
|
class install_data(_install_data):
|
|
|
|
def run(self):
|
|
|
|
for lang in os.listdir('build/locale/'):
|
|
|
|
lang_dir = os.path.join('share', 'locale', lang, 'LC_MESSAGES')
|
|
|
|
lang_file = os.path.join('build', 'locale', lang, 'LC_MESSAGES', 'deluge.mo')
|
|
|
|
self.data_files.append( (lang_dir, [lang_file]) )
|
|
|
|
_install_data.run(self)
|
|
|
|
|
2007-02-26 23:56:17 +00:00
|
|
|
cmdclass = {
|
2007-03-05 20:44:53 +00:00
|
|
|
'build': build,
|
2007-02-26 23:56:17 +00:00
|
|
|
'install': install,
|
2007-03-05 20:44:53 +00:00
|
|
|
'build_trans': build_trans,
|
|
|
|
'install_data': install_data,
|
2007-02-26 23:56:17 +00:00
|
|
|
'write_data_install_path': write_data_install_path,
|
|
|
|
'unwrite_data_install_path': unwrite_data_install_path,
|
|
|
|
}
|
|
|
|
|
2007-03-05 20:44:53 +00:00
|
|
|
data = [('share/deluge/glade', glob.glob('glade/*.glade')),
|
|
|
|
('share/deluge/pixmaps', glob.glob('pixmaps/*.png')),
|
|
|
|
('share/applications' , ['deluge.desktop']),
|
|
|
|
('share/pixmaps' , ['deluge.xpm'])]
|
|
|
|
|
|
|
|
for plugin in glob.glob('plugins/*'):
|
|
|
|
data.append( ('share/deluge/' + plugin, glob.glob(plugin + '/*')) )
|
2007-02-26 23:56:17 +00:00
|
|
|
|
2007-03-08 18:43:29 +00:00
|
|
|
setup(name=NAME, fullname=FULLNAME, version=VERSION,
|
2007-03-08 18:36:57 +00:00
|
|
|
author=AUTHOR, author_email=EMAIL, description=DESCRIPTION,
|
|
|
|
url=URL, license=LICENSE,
|
2007-01-07 22:50:26 +00:00
|
|
|
scripts=["scripts/deluge"],
|
2007-02-06 22:53:26 +00:00
|
|
|
packages=['deluge'],
|
|
|
|
package_dir = {'deluge': 'src'},
|
2007-02-12 21:30:54 +00:00
|
|
|
data_files=data,
|
2007-02-26 23:56:17 +00:00
|
|
|
ext_package='deluge',
|
2007-03-20 02:18:32 +00:00
|
|
|
ext_modules=[deluge_core, upnp],
|
2007-02-26 23:56:17 +00:00
|
|
|
cmdclass=cmdclass
|
2007-05-23 19:51:21 +00:00
|
|
|
)
|