deluge/setup.py

341 lines
12 KiB
Python
Raw Normal View History

2007-07-04 08:24:30 +00:00
# setup.py
#
# Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
2007-07-04 08:24:30 +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
2008-08-08 05:59:07 +00:00
# the Free Software Foundation; either version 3, or (at your option)
2007-07-04 08:24:30 +00:00
# any later version.
2008-07-14 20:42:11 +00:00
#
2007-07-04 08:24:30 +00:00
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
2007-07-13 01:34:18 +00:00
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2007-07-04 08:24:30 +00:00
# GNU General Public License for more details.
2008-07-14 20:42:11 +00:00
#
2007-07-04 08:24:30 +00:00
# You should have received a copy of the GNU General Public License
2007-07-13 01:34:18 +00:00
# along with this program. If not, write to:
2007-07-04 08:24:30 +00:00
# The Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor
2007-07-13 01:34:18 +00:00
# Boston, MA 02110-1301, USA.
2007-07-04 08:24:30 +00:00
#
2007-07-13 01:34:18 +00:00
# In addition, as a special exception, the copyright holders give
# permission to link the code of portions of this program with the OpenSSL
# library.
# You must obey the GNU General Public License in all respects for all of
# the code used other than OpenSSL. If you modify file(s) with this
# exception, you may extend this exception to your version of the file(s),
# but you are not obligated to do so. If you do not wish to do so, delete
# this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here.
2007-07-04 08:24:30 +00:00
import ez_setup
ez_setup.use_setuptools()
2008-07-10 04:40:13 +00:00
import glob
2007-07-04 08:24:30 +00:00
from setuptools import setup, find_packages, Extension
from distutils import cmd, sysconfig
2007-09-16 01:24:08 +00:00
from distutils.command.build import build as _build
from distutils.command.install import install as _install
from distutils.command.install_data import install_data as _install_data
2008-07-10 04:40:13 +00:00
import msgfmt
import os
2008-07-10 04:40:13 +00:00
import platform
2007-07-04 08:24:30 +00:00
python_version = platform.python_version()[0:3]
2008-02-03 01:04:26 +00:00
def windows_check():
import platform
if platform.system() in ('Windows', 'Microsoft'):
return True
else:
return False
# Try to get SVN revision number to append to version
revision_string = ""
try:
stdout = os.popen("svn info")
for line in stdout:
if line.split(" ")[0] == "Revision:":
revision_string = line.split(" ")[1].strip()
break
# Try to get the SVN revision on Gentoo systems
if revision_string == "":
stdout = os.popen("svn info /usr/portage/distfiles/svn-src/deluge/deluge-0.6")
for line in stdout:
if line.split(" ")[0] == "Revision:":
revision_string = line.split(" ")[1].strip()
break
2008-07-14 20:42:11 +00:00
f = open("deluge/data/revision", "w")
f.write(revision_string)
f.close()
except:
pass
if not os.environ.has_key("CC"):
os.environ["CC"] = "gcc"
if not os.environ.has_key("CXX"):
os.environ["CXX"] = "gcc"
2008-07-14 20:42:11 +00:00
if not os.environ.has_key("CPP"):
os.environ["CPP"] = "g++"
2008-07-14 20:42:11 +00:00
2007-07-04 08:24:30 +00:00
# The libtorrent extension
_extra_compile_args = [
2008-04-16 03:52:08 +00:00
"-D_FILE_OFFSET_BITS=64",
2008-05-20 06:23:48 +00:00
"-DNDEBUG",
2008-07-10 04:40:13 +00:00
"-DTORRENT_USE_OPENSSL=1",
"-O2",
2008-02-03 01:04:26 +00:00
]
2008-02-03 01:12:46 +00:00
2008-02-03 01:04:26 +00:00
if windows_check():
2008-07-14 20:42:11 +00:00
_extra_compile_args += [
2008-02-03 01:04:26 +00:00
"-D__USE_W32_SOCKETS",
2008-07-10 04:40:13 +00:00
"-D_WIN32_WINNT=0x0500",
2008-02-03 01:04:26 +00:00
"-D_WIN32",
2008-07-10 04:40:13 +00:00
"-DWIN32_LEAN_AND_MEAN",
2008-02-03 01:04:26 +00:00
"-DBOOST_ALL_NO_LIB",
2008-07-10 04:40:13 +00:00
"-DBOOST_STATIC_LINK",
2008-02-03 01:04:26 +00:00
"-DBOOST_THREAD_USE_LIB",
2008-07-10 04:40:13 +00:00
"-DBOOST_WINDOWS",
"-DBOOST_WINDOWS_API",
2008-02-03 01:04:26 +00:00
"-DTORRENT_BUILDING_SHARED",
"-DTORRENT_LINKING_SHARED",
2008-07-10 04:40:13 +00:00
"-DWIN32",
"-DUNICODE",
"-D_UNICODE",
2008-07-10 04:40:13 +00:00
"/GR",
"/Zc:wchar_t",
2008-02-03 01:04:26 +00:00
]
2008-02-03 01:12:46 +00:00
else:
_extra_compile_args += ["-Wno-missing-braces"]
2008-07-14 20:42:11 +00:00
removals = ["-Wstrict-prototypes"]
2008-02-03 01:04:26 +00:00
if not windows_check():
if python_version == '2.5':
cv_opt = sysconfig.get_config_vars()["CFLAGS"]
for removal in removals:
cv_opt = cv_opt.replace(removal, " ")
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, " ")
sysconfig.get_config_vars()["OPT"] = " ".join(cv_opt.split())
2008-02-03 01:12:46 +00:00
2008-02-03 03:24:36 +00:00
_library_dirs = [
]
_include_dirs = [
2007-07-13 01:34:18 +00:00
'./libtorrent',
'./libtorrent/include',
'./libtorrent/include/libtorrent',
2007-07-04 08:24:30 +00:00
]
2008-02-03 01:04:26 +00:00
if windows_check():
2008-07-05 00:25:04 +00:00
_include_dirs += ['./win32/include','./win32/include/openssl', './win32/include/zlib']
_library_dirs += ['./win32/lib']
2008-02-03 09:05:55 +00:00
_libraries = [
2008-07-10 04:40:13 +00:00
'advapi32',
2008-07-05 00:25:04 +00:00
'boost_filesystem-vc71-mt-1_35',
'boost_date_time-vc71-mt-1_35',
'boost_iostreams-vc71-mt-1_35',
2008-07-10 04:40:13 +00:00
'boost_python-vc71-mt-1_35',
'boost_system-vc71-mt-1_35',
'boost_thread-vc71-mt-1_35',
'gdi32',
2008-07-05 00:25:04 +00:00
'libeay32',
2008-07-10 04:40:13 +00:00
'ssleay32',
'ws2_32',
2008-02-03 01:04:26 +00:00
'wsock32',
2008-07-10 04:40:13 +00:00
'zlib'
2008-02-03 01:04:26 +00:00
]
2008-02-03 01:12:46 +00:00
else:
_include_dirs += ['/usr/include/python' + python_version]
2008-02-03 22:50:06 +00:00
_libraries = [
2008-02-03 09:05:55 +00:00
'boost_filesystem',
'boost_date_time',
'boost_iostreams',
2008-07-10 04:40:13 +00:00
'boost_python',
'boost_thread',
2008-02-03 09:05:55 +00:00
'pthread',
2008-02-03 05:12:47 +00:00
'ssl',
'z'
]
# Modify the libs if necessary for systems with only -mt boost libs
if not os.path.exists(
2008-08-28 04:03:39 +00:00
os.path.join(sysconfig.PREFIX, "lib", "libboost_filesystem.so")):
# It's likely that this system doesn't have symlinks setup
# So add '-mt' to the libraries
for lib in _libraries:
if lib[:6] == "boost_":
_libraries[_libraries.index(lib)] = lib + "-mt"
2008-07-14 20:42:11 +00:00
2007-07-09 02:50:20 +00:00
_sources = glob.glob("./libtorrent/src/*.cpp") + \
glob.glob("./libtorrent/src/*.c") + \
2007-07-13 01:34:18 +00:00
glob.glob("./libtorrent/src/kademlia/*.cpp") + \
glob.glob("./libtorrent/bindings/python/src/*.cpp")
2007-07-04 08:24:30 +00:00
# Remove some files from the source that aren't needed
_source_removals = ["mapped_storage.cpp"]
for source in _sources:
for rem in _source_removals:
if rem in source:
2008-02-03 01:04:26 +00:00
_sources.remove(source)
break
2007-07-04 08:24:30 +00:00
libtorrent = Extension(
2007-07-13 01:34:18 +00:00
'libtorrent',
2008-07-10 04:40:13 +00:00
extra_compile_args = _extra_compile_args,
2007-07-13 01:34:18 +00:00
include_dirs = _include_dirs,
libraries = _libraries,
2008-07-10 04:40:13 +00:00
library_dirs = _library_dirs,
2007-07-13 01:34:18 +00:00
sources = _sources
2007-07-04 08:24:30 +00:00
)
2007-09-16 01:24:08 +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__), 'deluge/i18n/')
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('deluge', 'i18n', 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)
2007-09-16 01:24:08 +00:00
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)
2007-09-16 01:24:08 +00:00
msgfmt.make(src, dest)
class build(_build):
sub_commands = _build.sub_commands + [('build_trans', None)]
def run(self):
_build.run(self)
class install_data(_install_data):
def run(self):
_install_data.run(self)
cmdclass = {
'build': build,
'build_trans': build_trans,
'install_data': install_data
}
# Build the plugin eggs
2008-07-06 00:47:08 +00:00
PLUGIN_PATH = "deluge/plugins/*"
if windows_check():
PLUGIN_PATH = "deluge\\plugins\\"
2008-07-14 20:42:11 +00:00
2008-07-06 00:47:08 +00:00
for path in glob.glob(PLUGIN_PATH):
if os.path.exists(os.path.join(path, "setup.py")):
os.system("cd " + path + "&& python setup.py bdist_egg -d ..")
2007-07-04 08:24:30 +00:00
# Main setup
2008-07-06 00:47:08 +00:00
PREFIX = "/usr/"
if windows_check():
PREFIX = ""
_data_files = [(os.path.join(PREFIX, 'share/icons/scalable/apps'), [
'deluge/data/icons/scalable/apps/deluge.svg']),
(os.path.join(PREFIX, 'share/icons/hicolor/128x128/apps'), [
'deluge/data/icons/hicolor/128x128/apps/deluge.png']),
(os.path.join(PREFIX, 'share/icons/hicolor/16x16/apps'), [
'deluge/data/icons/hicolor/16x16/apps/deluge.png']),
(os.path.join(PREFIX, 'share/icons/hicolor/192x192/apps'), [
'deluge/data/icons/hicolor/192x192/apps/deluge.png']),
(os.path.join(PREFIX, 'share/icons/hicolor/22x22/apps'), [
'deluge/data/icons/hicolor/22x22/apps/deluge.png']),
(os.path.join(PREFIX, 'share/icons/hicolor/24x24/apps'), [
'deluge/data/icons/hicolor/24x24/apps/deluge.png']),
(os.path.join(PREFIX, 'share/icons/hicolor/256x256/apps'), [
'deluge/data/icons/hicolor/256x256/apps/deluge.png']),
(os.path.join(PREFIX, 'share/icons/hicolor/32x32/apps'), [
'deluge/data/icons/hicolor/32x32/apps/deluge.png']),
(os.path.join(PREFIX, 'share/icons/hicolor/36x36/apps'), [
'deluge/data/icons/hicolor/36x36/apps/deluge.png']),
(os.path.join(PREFIX, 'share/icons/hicolor/48x48/apps'), [
'deluge/data/icons/hicolor/48x48/apps/deluge.png']),
(os.path.join(PREFIX, 'share/icons/hicolor/64x64/apps'), [
'deluge/data/icons/hicolor/64x64/apps/deluge.png']),
(os.path.join(PREFIX, 'share/icons/hicolor/72x72/apps'), [
'deluge/data/icons/hicolor/72x72/apps/deluge.png']),
(os.path.join(PREFIX, 'share/icons/hicolor/96x96/apps'), [
'deluge/data/icons/hicolor/96x96/apps/deluge.png']),
(os.path.join(PREFIX, 'share/applications'), [
'deluge/data/share/applications/deluge.desktop']),
(os.path.join(PREFIX, 'share/pixmaps'), ['deluge/data/pixmaps/deluge.png'])]
2007-07-04 08:24:30 +00:00
setup(
2008-07-13 03:33:56 +00:00
author = "Andrew Resch, Marcos Pinto, Martijn Voncken, Sadrul Habib Chowdhury",
2008-07-13 03:40:22 +00:00
author_email = "andrewresch@gmail.com, markybob@dipconsultants.com, \
mvoncken@gmail.com, sadrul@users.sourceforge.net",
2008-07-10 04:40:13 +00:00
cmdclass=cmdclass,
data_files = _data_files,
2008-07-13 03:33:56 +00:00
description = "Bittorrent Client",
2008-07-10 04:40:13 +00:00
entry_points = """
[console_scripts]
deluge = deluge.main:start_ui
deluged = deluge.main:start_daemon
""",
ext_package = "deluge",
ext_modules = [libtorrent],
fullname = "Deluge Bittorent Client",
2007-07-13 01:34:18 +00:00
include_package_data = True,
license = "GPLv3",
2008-07-10 04:40:13 +00:00
name = "deluge",
2008-07-14 20:42:11 +00:00
package_data = {"deluge": ["ui/gtkui/glade/*.glade",
2007-07-14 01:33:16 +00:00
"data/pixmaps/*.png",
"data/pixmaps/*.svg",
"data/pixmaps/*.ico",
2008-04-08 04:46:01 +00:00
"data/pixmaps/flags/*.png",
"data/revision",
"plugins/*.egg",
2007-09-16 01:24:08 +00:00
"i18n/*.pot",
"i18n/*/LC_MESSAGES/*.mo",
2008-04-13 03:42:05 +00:00
"ui/webui/LICENSE",
"ui/webui/scripts/*",
"ui/webui/ssl/*",
"ui/webui/static/*.css",
2008-04-14 00:49:31 +00:00
"ui/webui/static/*.js",
2008-04-13 03:42:05 +00:00
"ui/webui/static/images/*.png",
"ui/webui/static/images/*.jpg",
"ui/webui/static/images/*.gif",
"ui/webui/static/images/tango/*.png",
"ui/webui/templates/deluge/*",
2008-07-14 20:42:11 +00:00
"ui/webui/templates/classic/*",
2008-04-13 03:42:05 +00:00
"ui/webui/templates/white/*"
]},
packages = find_packages(exclude=["plugins"]),
2008-07-10 04:40:13 +00:00
url = "http://deluge-torrent.org",
2008-07-20 22:41:04 +00:00
version = "1.1.0_dev",
2008-07-10 04:40:13 +00:00
)
2008-07-14 20:42:11 +00:00
try:
f = open("deluge/data/revision", "w")
f.write("")
f.close()
except:
pass