summaryrefslogtreecommitdiffstats
path: root/deluge/_libtorrent.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 21:38:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 21:38:38 +0000
commit2e2851dc13d73352530dd4495c7e05603b2e520d (patch)
tree622b9cd8e5d32091c9aa9e4937b533975a40356c /deluge/_libtorrent.py
parentInitial commit. (diff)
downloaddeluge-2e2851dc13d73352530dd4495c7e05603b2e520d.tar.xz
deluge-2e2851dc13d73352530dd4495c7e05603b2e520d.zip
Adding upstream version 2.1.2~dev0+20240219.upstream/2.1.2_dev0+20240219upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'deluge/_libtorrent.py')
-rw-r--r--deluge/_libtorrent.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/deluge/_libtorrent.py b/deluge/_libtorrent.py
new file mode 100644
index 0000000..642855c
--- /dev/null
+++ b/deluge/_libtorrent.py
@@ -0,0 +1,35 @@
+#
+# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
+#
+# This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
+# the additional special exception to link portions of this program with the OpenSSL library.
+# See LICENSE for more details.
+#
+
+"""
+This module is used to handle the importing of libtorrent and also controls
+the minimum versions of libtorrent that this version of Deluge supports.
+
+Example:
+ >>> from deluge._libtorrent import lt
+
+"""
+from deluge.common import VersionSplit, get_version
+from deluge.error import LibtorrentImportError
+
+try:
+ import deluge.libtorrent as lt
+except ImportError:
+ try:
+ import libtorrent as lt
+ except ImportError as ex:
+ raise LibtorrentImportError('No libtorrent library found: %s' % (ex))
+
+
+REQUIRED_VERSION = '1.2.0.0'
+LT_VERSION = lt.__version__
+
+if VersionSplit(LT_VERSION) < VersionSplit(REQUIRED_VERSION):
+ raise LibtorrentImportError(
+ f'Deluge {get_version()} requires libtorrent >= {REQUIRED_VERSION}'
+ )