From 36b29053f914c1bda7f0432545122ab37ac3784e Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 23 Nov 2008 20:41:24 +0000 Subject: [PATCH] fixed windows python bindings build. Made setup.py build with boost-build on windows, to be able to generate a windows binary installer for the python bindings --- bindings/python/Jamfile | 31 ++++++++++++++++++++++++++++--- bindings/python/setup.py.in | 27 +++++++++++++++++++++++++-- bindings/python/src/module.cpp | 2 ++ 3 files changed, 55 insertions(+), 5 deletions(-) diff --git a/bindings/python/Jamfile b/bindings/python/Jamfile index 0c356fa7e..3cfb80867 100755 --- a/bindings/python/Jamfile +++ b/bindings/python/Jamfile @@ -4,6 +4,33 @@ use-project /torrent : ../.. ; lib boost_python : : boost_python $(library-search-path) ; +rule libtorrent_linking ( properties * ) +{ + local result ; + + if gcc in $(properties) + { + result += /torrent//torrent/static/-fPIC/-fPIC ; + } + else + { + result += /torrent//torrent/static ; + } + + # when building peer_plugin.cpp on msvc-7.1 it fails + # running out of internal heap space. Don't add it + # to windows build, since it's not critical anyway + if msvc in $(properties) + { + result += TORRENT_NO_PYTHON_PLUGINS ; + } + else + { + result += src/peer_plugin.cpp ; + } + return $(result) ; +} + python-extension libtorrent : src/module.cpp src/big_number.cpp @@ -20,7 +47,6 @@ python-extension libtorrent src/alert.cpp src/datetime.cpp src/extensions.cpp - src/peer_plugin.cpp src/docstrings.cpp src/torrent.cpp src/peer_info.cpp @@ -30,7 +56,6 @@ python-extension libtorrent system:boost_python source,static:/boost/python//boost_python/static source,shared:/boost/python//boost_python/shared - gcc:/torrent//torrent/static/-fPIC/-fPIC - !gcc:/torrent//torrent/static/-fPIC/-fPIC + @libtorrent_linking ; diff --git a/bindings/python/setup.py.in b/bindings/python/setup.py.in index 870c1588b..185147f78 100644 --- a/bindings/python/setup.py.in +++ b/bindings/python/setup.py.in @@ -19,14 +19,37 @@ def arch(): a = os.uname()[4] if a == 'Power Macintosh': a = 'ppc' return ['-arch', a] - + +if platform.system() == 'Windows': +# on windows, build using bjam and build an installer + import shutil + os.system('bjam boost=source link=static boost-link=static release msvc-7.1') + try: + os.mkdir(r'libtorrent') + except: + pass + shutil.copyfile(r'bin\msvc-7.1\release\boost-source\link-static\threading-multi\libtorrent.pyd', r'.\libtorrent\libtorrent.pyd') + 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'], + package_data = {'.': [r'libtorrent.pyd']}, + package_dir={'.': 'libtorrent'} + ) + sys.exit(0) 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@', +setup( name='python-libtorrent', version='@PACKAGE_VERSION@', author = 'Arvid Norberg', author_email='@PACKAGE_BUGREPORT@', diff --git a/bindings/python/src/module.cpp b/bindings/python/src/module.cpp index 7539449cb..e0bbe381d 100644 --- a/bindings/python/src/module.cpp +++ b/bindings/python/src/module.cpp @@ -43,7 +43,9 @@ BOOST_PYTHON_MODULE(libtorrent) bind_alert(); bind_datetime(); bind_extensions(); +#ifndef TORRENT_NO_PYTHON_PLUGINS bind_peer_plugin(); +#endif bind_torrent(); bind_peer_info(); bind_ip_filter();