merged in [2962] from RC_0_14
This commit is contained in:
15
bindings/python/Makefile.am
Normal file
15
bindings/python/Makefile.am
Normal file
@@ -0,0 +1,15 @@
|
||||
if ENABLE_PYTHON_BINDING
|
||||
|
||||
all-local:
|
||||
$(PYTHON) setup.py build
|
||||
|
||||
install-exec-local:
|
||||
$(PYTHON) setup.py install --prefix=$(DESTDIR)$(prefix)
|
||||
|
||||
uninstall-local:
|
||||
rm -rf $(DESTDIR)$(libdir)/python*/site-packages/*libtorrentrb*
|
||||
|
||||
clean-local:
|
||||
$(PYTHON) setup.py clean --all
|
||||
|
||||
endif
|
@@ -1,39 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from distutils.core import setup, Extension
|
||||
import commands
|
||||
import os
|
||||
|
||||
def pkgconfig(*packages, **kw):
|
||||
flag_map = {'-I': 'include_dirs', '-L': 'library_dirs', '-l': 'libraries' }
|
||||
for token in commands.getoutput("pkg-config --libs --cflags %s" % ' '.join(packages)).split():
|
||||
if flag_map.has_key(token[:2]):
|
||||
kw.setdefault(flag_map.get(token[:2]), []).append(token[2:])
|
||||
else: # throw others to extra_link_args
|
||||
kw.setdefault('extra_link_args', []).append(token)
|
||||
for k, v in kw.iteritems(): # remove duplicated
|
||||
kw[k] = list(set(v))
|
||||
return kw
|
||||
|
||||
def build_extension():
|
||||
this_dir = os.path.dirname(__file__)
|
||||
source_list = os.listdir(os.path.join(this_dir, "src"))
|
||||
source_list = [os.path.join("src", s) for s in source_list if s.endswith(".cpp")]
|
||||
|
||||
libtorrent_pkg_config = pkgconfig('libtorrent-rasterbar', libraries=['boost_python-mt'])
|
||||
|
||||
return Extension(
|
||||
'libtorrent',
|
||||
sources = source_list,
|
||||
**libtorrent_pkg_config
|
||||
)
|
||||
|
||||
libtorrent_extension = build_extension()
|
||||
|
||||
setup( name = 'py-libtorrent',
|
||||
version = '0.14',
|
||||
description = 'Python bindings for libtorrent (rasterbar)',
|
||||
author = 'Arvid Norberg',
|
||||
url = 'http://www.rasterbar.com/products/libtorrent/index.html',
|
||||
ext_modules = [libtorrent_extension]
|
||||
)
|
46
bindings/python/setup.py.in
Normal file
46
bindings/python/setup.py.in
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from distutils.core import setup, Extension
|
||||
import os
|
||||
import platform
|
||||
|
||||
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]
|
||||
|
||||
|
||||
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")]
|
||||
|
||||
extra_cmd = '@COMPILETIME_OPTIONS@ @CPPFLAGS@'
|
||||
|
||||
setup( name='python-@PACKAGE_NAME@',
|
||||
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++',
|
||||
include_dirs = ['@top_srcdir@/include','@top_srcdir@/include/libtorrent'] + parse_cmd(extra_cmd, '-I'),
|
||||
library_dirs = ['@top_builddir@/src/.libs'] + parse_cmd(extra_cmd, '-L'),
|
||||
extra_link_args = '@LDFLAGS@'.split() + arch(),
|
||||
extra_compile_args = parse_cmd(extra_cmd, '-D', True) + arch(),
|
||||
libraries = ['torrent-rasterbar','@BOOST_PYTHON_LIB@'] + parse_cmd(extra_cmd, '-l'))],
|
||||
)
|
Reference in New Issue
Block a user