2008-11-21 05:09:34 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2009-04-12 02:00:24 +02:00
|
|
|
from distutils import sysconfig
|
2008-11-21 05:09:34 +01:00
|
|
|
from distutils.core import setup, Extension
|
|
|
|
import os
|
|
|
|
import platform
|
2008-12-05 18:10:56 +01:00
|
|
|
import sys
|
2008-11-21 05:09:34 +01:00
|
|
|
|
2008-12-05 17:57:37 +01:00
|
|
|
if '@BOOST_PYTHON_LIB@' == '':
|
|
|
|
print 'You need to pass --enable-python-binding to configure in order ',
|
|
|
|
print 'to properly use this setup. There is no boost.python library configured now'
|
|
|
|
sys.exit(1)
|
|
|
|
|
2008-11-21 05:09:34 +01:00
|
|
|
def parse_cmd(cmdline, prefix, keep_prefix = False):
|
|
|
|
ret = []
|
|
|
|
for token in cmdline.split():
|
|
|
|
if token[:len(prefix)] == prefix:
|
|
|
|
if keep_prefix:
|
|
|
|
ret.append(token)
|
|
|
|
else:
|
|
|
|
ret.append(token[len(prefix):])
|
|
|
|
return ret
|
|
|
|
|
|
|
|
def arch():
|
|
|
|
if platform.system() != 'Darwin': return []
|
|
|
|
a = os.uname()[4]
|
|
|
|
if a == 'Power Macintosh': a = 'ppc'
|
|
|
|
return ['-arch', a]
|
2008-11-23 21:41:24 +01:00
|
|
|
|
|
|
|
if platform.system() == 'Windows':
|
|
|
|
# on windows, build using bjam and build an installer
|
|
|
|
import shutil
|
2010-08-04 19:07:01 +02:00
|
|
|
# msvc 9.0 (2008) is the official windows compiler for python 2.6
|
|
|
|
# http://docs.python.org/whatsnew/2.6.html#build-and-c-api-changes
|
|
|
|
if os.system('bjam boost=source link=static geoip=static boost-link=static release msvc-9.0 optimization=space') != 0:
|
2008-11-24 01:38:26 +01:00
|
|
|
print 'build failed'
|
|
|
|
sys.exit(1)
|
|
|
|
try: os.mkdir(r'build')
|
|
|
|
except: pass
|
|
|
|
try: os.mkdir(r'build\lib')
|
|
|
|
except: pass
|
|
|
|
try: os.mkdir(r'libtorrent')
|
|
|
|
except: pass
|
2010-08-21 21:47:48 +02:00
|
|
|
shutil.copyfile(r'bin\msvc-9.0\release\boost-source\geoip-static\link-static\optimization-space\threading-multi\libtorrent.pyd', r'.\build\lib\libtorrent.pyd')
|
2008-11-23 21:41:24 +01:00
|
|
|
setup( name='python-libtorrent',
|
|
|
|
version='@PACKAGE_VERSION@',
|
|
|
|
author = 'Arvid Norberg',
|
|
|
|
author_email='@PACKAGE_BUGREPORT@',
|
|
|
|
description = 'Python bindings for libtorrent-rasterbar',
|
|
|
|
long_description = 'Python bindings for libtorrent-rasterbar',
|
|
|
|
url = 'http://www.rasterbar.com/products/libtorrent/index.html',
|
|
|
|
platforms = 'Windows',
|
|
|
|
license = 'Boost Software License - Version 1.0 - August 17th, 2003',
|
|
|
|
packages = ['libtorrent'],
|
|
|
|
)
|
|
|
|
sys.exit(0)
|
2008-11-21 05:09:34 +01:00
|
|
|
|
2009-04-12 02:00:24 +02:00
|
|
|
config_vars = sysconfig.get_config_vars()
|
|
|
|
if "CFLAGS" in config_vars and "-Wstrict-prototypes" in config_vars["CFLAGS"]:
|
|
|
|
config_vars["CFLAGS"] = config_vars["CFLAGS"].replace("-Wstrict-prototypes", " ")
|
|
|
|
if "OPT" in config_vars and "-Wstrict-prototypes" in config_vars["OPT"]:
|
|
|
|
config_vars["OPT"] = config_vars["OPT"].replace("-Wstrict-prototypes", " ")
|
|
|
|
|
2008-11-21 05:09:34 +01:00
|
|
|
source_list = os.listdir(os.path.join(os.path.dirname(__file__), "src"))
|
|
|
|
source_list = [os.path.join("src", s) for s in source_list if s.endswith(".cpp")]
|
|
|
|
|
2009-11-02 03:10:38 +01:00
|
|
|
extra_cmd = '@COMPILETIME_OPTIONS@ @CPPFLAGS@ @LIBS@ @BOOST_SYSTEM_LIB@ @BOOST_PYTHON_LIB@ @PTHREAD_LIBS@ @OPENSSL_LIBS@ @OPENSSL_LDFLAGS@ @OPENSSL_INCLUDES@'
|
2008-11-21 05:09:34 +01:00
|
|
|
|
2008-11-23 21:41:24 +01:00
|
|
|
setup( name='python-libtorrent',
|
2008-11-21 05:09:34 +01:00
|
|
|
version='@PACKAGE_VERSION@',
|
|
|
|
author = 'Arvid Norberg',
|
|
|
|
author_email='@PACKAGE_BUGREPORT@',
|
|
|
|
description = 'Python bindings for libtorrent-rasterbar',
|
|
|
|
long_description = 'Python bindings for libtorrent-rasterbar',
|
|
|
|
url = 'http://www.rasterbar.com/products/libtorrent/index.html',
|
|
|
|
platforms = 'any',
|
|
|
|
license = 'Boost Software License - Version 1.0 - August 17th, 2003',
|
|
|
|
ext_modules = [Extension('libtorrent',
|
|
|
|
sources = source_list,
|
|
|
|
language='c++',
|
2009-09-10 04:22:13 +02:00
|
|
|
include_dirs = ['@top_srcdir@/include'] + parse_cmd(extra_cmd, '-I'),
|
2008-11-21 05:09:34 +01:00
|
|
|
library_dirs = ['@top_builddir@/src/.libs'] + parse_cmd(extra_cmd, '-L'),
|
|
|
|
extra_link_args = '@LDFLAGS@'.split() + arch(),
|
2009-08-21 22:19:55 +02:00
|
|
|
extra_compile_args = parse_cmd(extra_cmd, '-D', True) + arch(),
|
2009-09-10 04:22:13 +02:00
|
|
|
libraries = ['torrent-rasterbar'] + parse_cmd(extra_cmd, '-l'))],
|
2008-11-21 05:09:34 +01:00
|
|
|
)
|