Add python bindings (-python subpackage).
This commit is contained in:
parent
d8e0261730
commit
30e9aafec6
126
rb_libtorrent-python-setup.py
Normal file
126
rb_libtorrent-python-setup.py
Normal file
@ -0,0 +1,126 @@
|
||||
# setup.py - Builds the python rb_libtorrent bindings
|
||||
#
|
||||
# Copyright (C) 2008 Peter Gordon ('codergeek42') <peter@thecodergeek.com>
|
||||
# Based heavily on the Deluge setuptools script, which is
|
||||
# Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
|
||||
import glob
|
||||
|
||||
from setuptools import setup, find_packages, Extension
|
||||
from distutils import cmd, sysconfig
|
||||
from distutils.command.build import build as _build
|
||||
from distutils.command.install import install as _install
|
||||
from distutils.command.install_data import install_data as _install_data
|
||||
|
||||
import os
|
||||
import platform
|
||||
|
||||
python_version = platform.python_version()[0:3]
|
||||
|
||||
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
|
||||
_libtorrent_compile_args = [
|
||||
"-D_FILE_OFFSET_BITS=64",
|
||||
"-DNDEBUG",
|
||||
"-DTORRENT_USE_OPENSSL=1",
|
||||
"-O2",
|
||||
"-Wno-missing-braces"
|
||||
]
|
||||
|
||||
cv_opt = sysconfig.get_config_vars()["CFLAGS"]
|
||||
|
||||
_library_dirs = [
|
||||
'../../src/.libs'
|
||||
]
|
||||
|
||||
_include_dirs = [
|
||||
'../../include/',
|
||||
'../../include/libtorrent',
|
||||
'/usr/include/python' + python_version
|
||||
]
|
||||
|
||||
_libraries = [
|
||||
'torrent-rasterbar',
|
||||
'boost_python-mt'
|
||||
]
|
||||
|
||||
_sources = glob.glob("src/*.cpp")
|
||||
|
||||
## Remove some files from the source that aren't needed
|
||||
_source_removals = ["mapped_storage.cpp"]
|
||||
|
||||
for source in _sources:
|
||||
for rem in _source_removals:
|
||||
if rem in source:
|
||||
_sources.remove(source)
|
||||
break
|
||||
|
||||
libtorrent = Extension(
|
||||
'libtorrent',
|
||||
extra_compile_args = _libtorrent_compile_args,
|
||||
include_dirs = _include_dirs,
|
||||
libraries = _libraries,
|
||||
library_dirs = _library_dirs,
|
||||
sources = _sources
|
||||
)
|
||||
|
||||
class build(_build):
|
||||
def run(self):
|
||||
_build.run(self)
|
||||
|
||||
class install_data(_install_data):
|
||||
def run(self):
|
||||
_install_data.run(self)
|
||||
|
||||
cmdclass = {
|
||||
'build': build,
|
||||
'install_data': install_data
|
||||
}
|
||||
|
||||
setup(
|
||||
author = "Arvid Norberg",
|
||||
author_email = "",
|
||||
cmdclass=cmdclass,
|
||||
description = "Python rb_libtorrent Bindings",
|
||||
ext_modules = [libtorrent],
|
||||
fullname = "Python rb_libtorrent Bindings",
|
||||
include_package_data = False,
|
||||
license = "Boost",
|
||||
name = "libtorrent",
|
||||
url = "http://www.rasterbar.com/products/libtorrent/",
|
||||
version = "0.13.1",
|
||||
)
|
@ -1,6 +1,9 @@
|
||||
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
|
||||
%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
|
||||
|
||||
Name: rb_libtorrent
|
||||
Version: 0.13.1
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
Summary: A C++ BitTorrent library aiming to be the best alternative
|
||||
|
||||
Group: System Environment/Libraries
|
||||
@ -11,13 +14,18 @@ Source0: http://www.libtorrent.org/libtorrent-rasterbar-%{version}.tar.gz
|
||||
Source1: %{name}-README-renames.Fedora
|
||||
Source2: %{name}-COPYING.Boost
|
||||
Source3: %{name}-COPYING.zlib
|
||||
## Sent upstream via the libtorrent-discuss ML.
|
||||
## Message-Id: <1216701448.24546.11.camel@tuxhugs>
|
||||
Source4: %{name}-python-setup.py
|
||||
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
|
||||
BuildRequires: asio-devel
|
||||
BuildRequires: boost-devel
|
||||
BuildRequires: zlib-devel
|
||||
BuildRequires: libtool
|
||||
BuildRequires: python-devel
|
||||
BuildRequires: python-setuptools
|
||||
BuildRequires: zlib-devel
|
||||
## Necessary for 'rename'...
|
||||
BuildRequires: util-linux-ng
|
||||
|
||||
@ -54,7 +62,6 @@ licenses, as well as the comments blocks in the source code for which license
|
||||
a given source or header file is released under.
|
||||
|
||||
|
||||
|
||||
#package examples
|
||||
#Summary: Example clients using %{name}
|
||||
#Group: Applications/Internet
|
||||
@ -68,6 +75,17 @@ a given source or header file is released under.
|
||||
#included documentation for more details.)
|
||||
|
||||
|
||||
%package python
|
||||
Summary: Python bindings for %{name}
|
||||
Group: Development/Languages
|
||||
License: Boost Software License
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
|
||||
%description python
|
||||
The %{name}-python package contains Python language bindings (the 'libtorrent'
|
||||
module) that allow it to be used from within Python applications.
|
||||
|
||||
|
||||
%prep
|
||||
%setup -q -n "libtorrent-rasterbar-%{version}"
|
||||
## The RST files are the sources used to create the final HTML files; and are
|
||||
@ -80,6 +98,8 @@ install -p -m 0644 %{SOURCE3} COPYING.zlib
|
||||
## Finally, ensure that everything is UTF-8, as it should be.
|
||||
iconv -t UTF-8 -f ISO_8859-15 AUTHORS -o AUTHORS.iconv
|
||||
mv AUTHORS.iconv AUTHORS
|
||||
## Install the necessary build script for the python bindings module...
|
||||
install -p -m 0755 %{SOURCE4} bindings/python/setup.py
|
||||
|
||||
|
||||
%build
|
||||
@ -98,6 +118,12 @@ rm -rf include/libtorrent/asio*
|
||||
## Use the system libtool to ensure that we don't get unnecessary RPATH
|
||||
## hacks in our final build.
|
||||
make %{?_smp_mflags} LIBTOOL=%{_bindir}/libtool
|
||||
## Finally, build the python module.
|
||||
pushd bindings/python
|
||||
CFLAGS="%{optflags}" %{__python} setup.py build
|
||||
## Fix the interpreter for the example clients
|
||||
sed -i -e 's:^#!/bin/python$:#!/usr/bin/python:' {simple_,}client.py
|
||||
popd
|
||||
|
||||
|
||||
%check
|
||||
@ -110,8 +136,12 @@ rm -rf %{buildroot}
|
||||
export CPPROG="%{__cp} -p"
|
||||
make install DESTDIR=%{buildroot} INSTALL="%{__install} -c -p"
|
||||
## Do the renaming due to the somewhat limited %%_bindir namespace.
|
||||
rename client torrent_client %{buildroot}%{_bindir}/*
|
||||
install -p -m 0644 %{SOURCE1} ./README-renames.Fedora
|
||||
#rename client torrent_client %{buildroot}%{_bindir}/*
|
||||
#install -p -m 0644 %{SOURCE1} ./README-renames.Fedora
|
||||
## Install the python binding module.
|
||||
pushd bindings/python
|
||||
%{__python} setup.py install -O1 --skip-build --root %{buildroot}
|
||||
popd
|
||||
|
||||
|
||||
%clean
|
||||
@ -134,7 +164,7 @@ rm -rf %{buildroot}
|
||||
## time, so we must exclude them here.
|
||||
%exclude %{_libdir}/*.a
|
||||
|
||||
%files devel
|
||||
%files devel
|
||||
%defattr(-,root,root,-)
|
||||
%doc COPYING.Boost COPYING.BSD COPYING.zlib docs/
|
||||
%{_libdir}/pkgconfig/libtorrent-rasterbar.pc
|
||||
@ -146,8 +176,17 @@ rm -rf %{buildroot}
|
||||
#doc COPYING README-renames.Fedora
|
||||
#{_bindir}/*torrent*
|
||||
|
||||
%files python
|
||||
%defattr(-,root,root,-)
|
||||
%doc AUTHORS ChangeLog COPYING.Boost bindings/python/{simple_,}client.py
|
||||
%{python_sitearch}/libtorrent-%{version}-py2.5.egg-info
|
||||
%{python_sitearch}/libtorrent.so
|
||||
|
||||
|
||||
%changelog
|
||||
* Mon Jul 14 2008 Peter Gordon <peter@thecodergeek.com> - 0.13.1-2
|
||||
- Add python bindings in a -python subpackage.
|
||||
|
||||
* Mon Jul 14 2008 Peter Gordon <peter@thecodergeek.com> - 0.13.1-1
|
||||
- Update to new upstream release (0.13.1): Contains an incompatible ABI/API
|
||||
bump.
|
||||
|
Loading…
Reference in New Issue
Block a user