make setup.py work well with both automake and bjam
This commit is contained in:
parent
8a132cb9ca
commit
2028a16d87
|
@ -152,6 +152,8 @@ EXTRA_DIST = \
|
|||
Jamroot.jam \
|
||||
CMakeLists.txt \
|
||||
LICENSE \
|
||||
bindings/python/compile_flags \
|
||||
bindings/python/link_flags \
|
||||
libtorrent-rasterbar.pc \
|
||||
libtorrent-rasterbar-cmake.pc \
|
||||
$(DOCS_PAGES) \
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
@COMPILETIME_OPTIONS@ @CPPFLAGS@ @LIBS@ @BOOST_SYSTEM_LIB@ @BOOST_PYTHON_LIB@ @PTHREAD_LIBS@ @OPENSSL_LIBS@ @OPENSSL_LDFLAGS@ @OPENSSL_INCLUDES@
|
|
@ -0,0 +1 @@
|
|||
@LDFLAGS@
|
|
@ -7,8 +7,51 @@ import platform
|
|||
import sys
|
||||
import shutil
|
||||
import multiprocessing
|
||||
import subprocess
|
||||
|
||||
if not '--help' in sys.argv \
|
||||
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]
|
||||
|
||||
def target_specific():
|
||||
|
||||
if platform.system() != 'Darwin': return []
|
||||
|
||||
# on mavericks, clang will fail when unknown arguments are
|
||||
# passed in. python distutils will pass in arguments it doesn't
|
||||
# know about
|
||||
return ['-Wno-error=unused-command-line-argument-hard-error-in-future']
|
||||
|
||||
try:
|
||||
extra_cmd = open('compile_flags').read()
|
||||
except:
|
||||
extra_cmd = None
|
||||
|
||||
try:
|
||||
ldflags = open('link_flags').read()
|
||||
except:
|
||||
ldflags = None
|
||||
|
||||
ext = None
|
||||
packages = None
|
||||
|
||||
if '--bjam' in sys.argv or ldflags == None or extra_cmd == None:
|
||||
|
||||
del sys.argv[sys.argv.index('--bjam')]
|
||||
|
||||
if not '--help' in sys.argv \
|
||||
and not '--help-commands' in sys.argv:
|
||||
|
||||
toolset = ''
|
||||
|
@ -23,7 +66,6 @@ if not '--help' in sys.argv \
|
|||
parallell_builds = ' -j%d' % multiprocessing.cpu_count()
|
||||
|
||||
# build libtorrent using bjam and build the installer with distutils
|
||||
|
||||
cmdline = 'bjam boost=source link=static geoip=static boost-link=static release optimization=space stage_module --abbreviate-paths' + toolset + parallell_builds
|
||||
print cmdline
|
||||
if os.system(cmdline) != 0:
|
||||
|
@ -40,15 +82,33 @@ if not '--help' in sys.argv \
|
|||
except: pass
|
||||
shutil.copyfile('libtorrent' + file_ext, 'build/lib/libtorrent' + file_ext)
|
||||
|
||||
setup( name='python-libtorrent',
|
||||
version='1.0.0',
|
||||
packages = ['libtorrent']
|
||||
|
||||
else:
|
||||
|
||||
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")]
|
||||
|
||||
ext = [Extension('libtorrent',
|
||||
sources = source_list,
|
||||
language='c++',
|
||||
include_dirs = ['../../include'] + parse_cmd(extra_cmd, '-I'),
|
||||
library_dirs = ['../../src/.libs'] + parse_cmd(extra_cmd, '-L'),
|
||||
extra_link_args = ldflags.split() + arch(),
|
||||
extra_compile_args = parse_cmd(extra_cmd, '-D', True) + arch() \
|
||||
+ target_specific(),
|
||||
libraries = ['torrent-rasterbar'] + parse_cmd(extra_cmd, '-l'))]
|
||||
|
||||
setup(name = 'python-libtorrent',
|
||||
version = '1.0.0',
|
||||
author = 'Arvid Norberg',
|
||||
author_email='arvid@rasterbar.com',
|
||||
author_email = 'arvid@rasterbar.com',
|
||||
description = 'Python bindings for libtorrent-rasterbar',
|
||||
long_description = 'Python bindings for libtorrent-rasterbar',
|
||||
url = 'http://libtorrent.org',
|
||||
platforms = [platform.system() + '-' + platform.machine()],
|
||||
license = 'BSD',
|
||||
packages = ['libtorrent'],
|
||||
packages = packages,
|
||||
ext_modules = ext
|
||||
)
|
||||
|
||||
|
|
|
@ -687,6 +687,8 @@ AC_CONFIG_FILES(
|
|||
[tools/Makefile]
|
||||
[bindings/Makefile]
|
||||
[bindings/python/Makefile]
|
||||
[bindings/python/link_flags]
|
||||
[bindings/python/compile_flags]
|
||||
[libtorrent-rasterbar.pc]
|
||||
[libtorrent-rasterbar-cmake.pc]
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue