remove libtorrent build code

This commit is contained in:
Calum Lind 2012-11-14 12:27:41 +00:00
parent c92b3debb7
commit 64e1ab481b
2 changed files with 7 additions and 244 deletions

View File

@ -1,21 +0,0 @@
#!/bin/bash
#
# This script checks out libtorrent from subversion
#
SVN=$(which svn)
LT_URL=https://libtorrent.svn.sourceforge.net/svnroot/libtorrent
VERSION=16
[ "$1" != "" ] && VERSION=$1
BRANCH=branches/RC_0_$VERSION
if [ -z $SVN ]; then
echo "Please install an 'svn' client"
exit 1
fi
if [ -d libtorrent ]; then
$SVN up libtorrent
else
$SVN co $LT_URL/$BRANCH libtorrent
fi

230
setup.py
View File

@ -29,12 +29,14 @@ except ImportError:
ez_setup.use_setuptools()
from setuptools import setup, find_packages, Extension
import glob
import os
import sys
import platform
import msgfmt
import glob
from distutils import cmd, sysconfig
from distutils.command.build import build as _build
from distutils.command.build_ext import build_ext as _build_ext
from distutils.command.clean import clean as _clean
try:
from sphinx.setup_command import BuildDoc
@ -42,204 +44,14 @@ except ImportError:
class BuildDoc(object):
pass
import msgfmt
import os
import platform
python_version = platform.python_version()[0:3]
def windows_check():
return platform.system() in ('Windows', 'Microsoft')
def osx_check():
return platform.system() == "Darwin"
if not os.environ.has_key("CC"):
os.environ["CC"] = "gcc"
if not os.environ.has_key("CXX"):
os.environ["CXX"] = "gcc"
if not os.environ.has_key("CPP"):
os.environ["CPP"] = "g++"
# The libtorrent extension
_extra_compile_args = [
"-D_FILE_OFFSET_BITS=64",
"-DNDEBUG",
"-DTORRENT_USE_OPENSSL=1",
"-DBOOST_FILESYSTEM_VERSION=2",
"-DBOOST_ASIO_ENABLE_CANCELIO",
"-DBOOST_ASIO_SEPARATE_COMPILATION",
"-O2",
]
if windows_check():
_extra_compile_args += [
"-D__USE_W32_SOCKETS",
"-D_WIN32_WINNT=0x0500",
"-D_WIN32",
"-DWIN32_LEAN_AND_MEAN",
"-DBOOST_ALL_NO_LIB",
"-DBOOST_THREAD_USE_LIB",
"-DBOOST_WINDOWS",
"-DBOOST_WINDOWS_API",
"-DWIN32",
"-DUNICODE",
"-D_UNICODE",
"-D_SCL_SECURE_NO_WARNINGS",
"/O2",
"/Ob2",
"/W3",
"/GR",
"/MD",
"/wd4675",
"/Zc:wchar_t",
"/Zc:forScope",
"/EHsc",
"-c",
]
else:
_extra_compile_args += ["-Wno-missing-braces"]
def remove_from_cflags(flags):
if not windows_check():
keys = ["OPT", "CFLAGS"]
if python_version == '2.5':
keys = ["CFLAGS"]
for key in keys:
cv_opt = sysconfig.get_config_vars()[key]
for flag in flags:
cv_opt = cv_opt.replace(flag, " ")
sysconfig.get_config_vars()[key] = " ".join(cv_opt.split())
removals = ["-Wstrict-prototypes"]
remove_from_cflags(removals)
_library_dirs = [
]
_include_dirs = [
'./libtorrent',
'./libtorrent/include',
'./libtorrent/include/libtorrent'
]
if windows_check():
_include_dirs += ['./win32/include','./win32/include/openssl', './win32/include/zlib']
_library_dirs += ['./win32/lib']
_libraries = [
'advapi32',
'boost_filesystem-vc-mt-1_37',
'boost_date_time-vc-mt-1_37',
'boost_iostreams-vc-mt-1_37',
'boost_python-vc-mt-1_37',
'boost_system-vc-mt-1_37',
'boost_thread-vc-mt-1_37',
'gdi32',
'libeay32',
'ssleay32',
'ws2_32',
'wsock32',
'zlib'
]
else:
_include_dirs += [
'/usr/include/python' + python_version,
sysconfig.get_config_var("INCLUDEDIR")
]
for include in os.environ.get("INCLUDEDIR", "").split(":"):
_include_dirs.append(include)
_library_dirs += [sysconfig.get_config_var("LIBDIR"), '/opt/local/lib', '/usr/local/lib']
if osx_check():
_include_dirs += [
'/opt/local/include/boost-1_35',
'/opt/local/include/boost-1_36',
'/usr/local/include'
'/sw/include/boost-1_35',
'/sw/include/boost'
]
_libraries = [
'boost_filesystem',
'boost_date_time',
'boost_iostreams',
'boost_python',
'boost_thread',
'pthread',
'ssl',
'z'
]
if not windows_check():
dynamic_lib_extension = ".so"
if osx_check():
dynamic_lib_extension = ".dylib"
_lib_extensions = ['-mt', '-mt_1_39', '-mt-1_38', '-mt-1_37', '-mt-1_36', '-mt-1_35']
# Modify the libs if necessary for systems with only -mt boost libs
for lib in _libraries:
if lib[:6] == "boost_":
for lib_prefix in _library_dirs:
for lib_suffix in _lib_extensions:
# If there is a -mt version use that
if os.path.exists(os.path.join(lib_prefix, "lib" + lib + lib_suffix + dynamic_lib_extension)):
_libraries[_libraries.index(lib)] = lib + lib_suffix
lib = lib + lib_suffix
break
_sources = glob.glob("./libtorrent/src/*.cpp") + \
glob.glob("./libtorrent/src/*.c") + \
glob.glob("./libtorrent/src/kademlia/*.cpp") + \
glob.glob("./libtorrent/bindings/python/src/*.cpp")
# Remove some files from the source that aren't needed
_source_removals = ["mapped_storage.cpp", "memdebug.cpp"]
to_remove = []
for source in _sources:
for rem in _source_removals:
if rem in source:
to_remove.append(source)
for rem in to_remove:
_sources.remove(rem)
_ext_modules = []
# Check for a system libtorrent and if found, then do not build the libtorrent extension
build_libtorrent = True
try:
from deluge._libtorrent import lt
except ImportError:
build_libtorrent = True
else:
build_libtorrent = False
if build_libtorrent:
got_libtorrent = False
if not os.path.exists("libtorrent"):
import subprocess
if subprocess.call(['./get_libtorrent.sh']) > 0:
got_libtorrent = False
else:
got_libtorrent = True
else:
got_libtorrent = True
if got_libtorrent:
# There isn't a system libtorrent library, so let's build the one included with deluge
libtorrent = Extension(
'libtorrent',
extra_compile_args = _extra_compile_args,
include_dirs = _include_dirs,
libraries = _libraries,
library_dirs = _library_dirs,
sources = _sources
)
_ext_modules = [libtorrent]
print "Found libtorrent version: %s" % lt.version
except ImportError, e:
print "Warning libtorrent not found: %s" % e
desktop_data = 'deluge/ui/data/share/applications/deluge.desktop'
@ -398,29 +210,6 @@ class build(_build):
# Run all sub-commands (at least those that need to be run)
_build.run(self)
class build_debug(build):
sub_commands = [x for x in build.sub_commands if x[0] != 'build_ext'] + [('build_ext_debug', None)]
class build_ext_debug(_build_ext):
def run(self):
if not self.distribution.ext_modules:
return _build_ext.run(self)
lt_ext = None
for ext in self.distribution.ext_modules:
if ext.name == 'libtorrent':
lt_ext = ext
if not lt_ext:
return _build_ext.run(self)
lt_ext.extra_compile_args.remove('-DNDEBUG')
lt_ext.extra_compile_args.remove('-O2')
lt_ext.extra_compile_args.append('-g')
remove_from_cflags(["-DNDEBUG", "-O2"])
return _build_ext.run(self)
class clean_plugins(cmd.Command):
description = "Cleans the plugin folders"
user_options = [
@ -487,8 +276,6 @@ cmdclass = {
'build_trans': build_trans,
'build_plugins': build_plugins,
'build_docs': build_docs,
'build_debug': build_debug,
'build_ext_debug': build_ext_debug,
'clean_plugins': clean_plugins,
'clean': clean,
'develop_plugins': develop_plugins,
@ -534,7 +321,6 @@ entry_points = {
]
}
if windows_check():
entry_points["console_scripts"].append("deluge-debug = deluge.main:start_ui")
@ -555,8 +341,6 @@ setup(
license = "GPLv3",
cmdclass = cmdclass,
data_files = _data_files,
ext_package = "deluge",
ext_modules = _ext_modules,
package_data = {"deluge": ["ui/gtkui/glade/*.glade",
"ui/gtkui/glade/*.ui",
"ui/data/pixmaps/*.png",