2011-05-21 12:00:59 +00:00
|
|
|
#!/usr/bin/env python
|
2007-07-04 08:24:30 +00:00
|
|
|
#
|
2008-11-23 04:58:01 +00:00
|
|
|
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
2014-09-22 21:15:33 +00:00
|
|
|
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
|
2008-07-14 20:42:11 +00:00
|
|
|
#
|
2014-09-22 21:15:33 +00:00
|
|
|
# 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.
|
2007-07-04 08:24:30 +00:00
|
|
|
#
|
|
|
|
|
2014-09-03 23:27:11 +00:00
|
|
|
import glob
|
2012-11-14 12:27:41 +00:00
|
|
|
import os
|
|
|
|
import platform
|
2014-09-03 23:27:11 +00:00
|
|
|
import sys
|
2007-09-16 01:24:08 +00:00
|
|
|
from distutils.command.build import build as _build
|
2008-11-25 22:21:14 +00:00
|
|
|
from distutils.command.clean import clean as _clean
|
2015-08-24 22:35:24 +00:00
|
|
|
from distutils.command.install_data import install_data as _install_data
|
2021-12-25 12:34:49 +00:00
|
|
|
from shutil import rmtree, which
|
2013-05-06 06:34:26 +00:00
|
|
|
|
2021-12-13 21:10:42 +00:00
|
|
|
from setuptools import Command, find_packages, setup
|
2014-09-25 20:05:57 +00:00
|
|
|
from setuptools.command.test import test as _test
|
2014-09-03 23:27:11 +00:00
|
|
|
|
|
|
|
import msgfmt
|
2016-11-26 19:35:53 +00:00
|
|
|
from version import get_version
|
2014-09-03 23:27:11 +00:00
|
|
|
|
2009-07-22 23:52:18 +00:00
|
|
|
try:
|
|
|
|
from sphinx.setup_command import BuildDoc
|
|
|
|
except ImportError:
|
2018-10-02 14:39:51 +00:00
|
|
|
|
2021-12-28 20:20:57 +00:00
|
|
|
class BuildDoc:
|
2009-07-22 23:52:18 +00:00
|
|
|
pass
|
|
|
|
|
2013-05-06 06:34:26 +00:00
|
|
|
|
2008-02-03 01:04:26 +00:00
|
|
|
def windows_check():
|
2008-10-23 11:27:37 +00:00
|
|
|
return platform.system() in ('Windows', 'Microsoft')
|
2008-02-03 01:04:26 +00:00
|
|
|
|
2015-09-20 17:39:20 +00:00
|
|
|
|
|
|
|
def osx_check():
|
2016-11-03 21:26:46 +00:00
|
|
|
return platform.system() == 'Darwin'
|
2015-09-20 17:39:20 +00:00
|
|
|
|
2016-11-16 22:18:18 +00:00
|
|
|
|
2012-02-20 16:56:20 +00:00
|
|
|
desktop_data = 'deluge/ui/data/share/applications/deluge.desktop'
|
2017-02-07 19:18:09 +00:00
|
|
|
appdata_data = 'deluge/ui/data/share/appdata/deluge.appdata.xml'
|
2012-02-20 16:56:20 +00:00
|
|
|
|
2016-11-27 22:04:31 +00:00
|
|
|
# Variables for setuptools.setup
|
|
|
|
_package_data = {}
|
|
|
|
_exclude_package_data = {}
|
|
|
|
_entry_points = {'console_scripts': [], 'gui_scripts': [], 'deluge.ui': []}
|
|
|
|
_data_files = []
|
|
|
|
_version = get_version(prefix='deluge-', suffix='.dev0')
|
|
|
|
|
2014-09-03 21:28:28 +00:00
|
|
|
|
2014-09-25 20:05:57 +00:00
|
|
|
class PyTest(_test):
|
2014-09-21 14:37:29 +00:00
|
|
|
def initialize_options(self):
|
2014-09-25 20:05:57 +00:00
|
|
|
_test.initialize_options(self)
|
2014-09-21 14:37:29 +00:00
|
|
|
self.pytest_args = []
|
|
|
|
|
|
|
|
def finalize_options(self):
|
2014-09-25 20:05:57 +00:00
|
|
|
_test.finalize_options(self)
|
2014-09-21 14:37:29 +00:00
|
|
|
self.test_args = []
|
|
|
|
self.test_suite = True
|
|
|
|
|
|
|
|
def run_tests(self):
|
|
|
|
import pytest
|
2018-10-02 14:39:51 +00:00
|
|
|
|
2014-09-21 14:37:29 +00:00
|
|
|
errcode = pytest.main(self.test_args)
|
|
|
|
sys.exit(errcode)
|
|
|
|
|
|
|
|
|
2021-12-13 21:10:42 +00:00
|
|
|
class CleanDocs(Command):
|
2018-10-05 08:33:26 +00:00
|
|
|
description = 'Clean the documentation build and module rst files'
|
2016-11-27 17:04:12 +00:00
|
|
|
user_options = []
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def run(self):
|
2018-10-05 08:33:26 +00:00
|
|
|
docs_build = 'docs/build'
|
2021-12-28 20:20:57 +00:00
|
|
|
print(f'Deleting {docs_build}')
|
2018-10-05 08:33:26 +00:00
|
|
|
try:
|
|
|
|
rmtree(docs_build)
|
|
|
|
except OSError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
for module in glob.glob('docs/source/modules/deluge*.rst'):
|
|
|
|
os.remove(module)
|
2016-11-27 17:04:12 +00:00
|
|
|
|
|
|
|
|
2021-12-13 21:10:42 +00:00
|
|
|
class BuildWebUI(Command):
|
2015-08-22 13:25:15 +00:00
|
|
|
description = 'Minify WebUI files'
|
2016-11-27 22:07:56 +00:00
|
|
|
user_options = []
|
2015-08-22 13:25:15 +00:00
|
|
|
|
2016-11-27 22:07:56 +00:00
|
|
|
JS_DIR = os.path.join('deluge', 'ui', 'web', 'js')
|
|
|
|
JS_SRC_DIRS = ('deluge-all', os.path.join('extjs', 'ext-extensions'))
|
2015-08-22 13:25:15 +00:00
|
|
|
|
|
|
|
def initialize_options(self):
|
2016-11-27 22:07:56 +00:00
|
|
|
pass
|
2015-08-22 13:25:15 +00:00
|
|
|
|
|
|
|
def finalize_options(self):
|
2016-11-27 22:07:56 +00:00
|
|
|
pass
|
2015-08-22 13:25:15 +00:00
|
|
|
|
|
|
|
def run(self):
|
2016-11-27 22:07:56 +00:00
|
|
|
js_basedir = os.path.join(os.path.dirname(__file__), self.JS_DIR)
|
2015-08-22 13:25:15 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
from minify_web_js import minify_js_dir
|
2018-10-02 14:39:51 +00:00
|
|
|
|
2016-11-27 22:07:56 +00:00
|
|
|
import_error = ''
|
2015-08-22 13:25:15 +00:00
|
|
|
except ImportError as err:
|
|
|
|
import_error = err
|
|
|
|
|
2016-11-27 22:07:56 +00:00
|
|
|
for js_src_dir in self.JS_SRC_DIRS:
|
|
|
|
source_dir = os.path.join(js_basedir, js_src_dir)
|
|
|
|
try:
|
|
|
|
minify_js_dir(source_dir)
|
|
|
|
except NameError:
|
|
|
|
js_file = source_dir + '.js'
|
2017-01-09 18:02:28 +00:00
|
|
|
if os.path.isfile(js_file):
|
2018-10-02 14:39:51 +00:00
|
|
|
print(
|
|
|
|
'Unable to minify but found existing minified: {}'.format(
|
|
|
|
js_file
|
|
|
|
)
|
|
|
|
)
|
2016-11-27 22:07:56 +00:00
|
|
|
else:
|
|
|
|
# Unable to minify and no existing minified file found so exiting.
|
|
|
|
print('Import error: %s' % import_error)
|
|
|
|
sys.exit(1)
|
|
|
|
|
2017-03-22 12:45:46 +00:00
|
|
|
# Create the gettext.js file for translations.
|
2017-06-27 14:11:19 +00:00
|
|
|
try:
|
|
|
|
from gen_web_gettext import create_gettext_js
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
deluge_all_path = os.path.join(js_basedir, self.JS_SRC_DIRS[0])
|
|
|
|
print('Creating WebUI translation file: %s/gettext.js' % deluge_all_path)
|
|
|
|
create_gettext_js(deluge_all_path)
|
2017-03-22 12:45:46 +00:00
|
|
|
|
2016-11-27 22:07:56 +00:00
|
|
|
|
2021-12-13 21:10:42 +00:00
|
|
|
class CleanWebUI(Command):
|
2016-11-27 22:07:56 +00:00
|
|
|
description = 'Clean the documentation build and rst files'
|
|
|
|
user_options = []
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
js_basedir = os.path.join(os.path.dirname(__file__), BuildWebUI.JS_DIR)
|
2018-10-14 20:14:48 +00:00
|
|
|
|
|
|
|
# Remove files generated by minify script.
|
2016-11-27 22:07:56 +00:00
|
|
|
for js_src_dir in BuildWebUI.JS_SRC_DIRS:
|
|
|
|
for file_type in ('.js', '-debug.js'):
|
|
|
|
js_file = os.path.join(js_basedir, js_src_dir + file_type)
|
2021-12-28 20:20:57 +00:00
|
|
|
print(f'Deleting {js_file}')
|
2016-11-27 22:07:56 +00:00
|
|
|
try:
|
|
|
|
os.remove(js_file)
|
|
|
|
except OSError:
|
|
|
|
pass
|
2015-08-22 13:25:15 +00:00
|
|
|
|
2018-10-14 20:14:48 +00:00
|
|
|
# Remove generated gettext.js
|
|
|
|
js_file = os.path.join(js_basedir, 'gettext.js')
|
2021-12-28 20:20:57 +00:00
|
|
|
print(f'Deleting {js_file}')
|
2018-10-14 20:14:48 +00:00
|
|
|
try:
|
|
|
|
os.remove(js_file)
|
|
|
|
except OSError:
|
|
|
|
pass
|
|
|
|
|
2015-08-22 13:25:15 +00:00
|
|
|
|
2021-12-13 21:10:42 +00:00
|
|
|
class BuildTranslations(Command):
|
2012-01-02 16:53:28 +00:00
|
|
|
description = 'Compile .po files into .mo files & create .desktop file'
|
2007-09-16 01:24:08 +00:00
|
|
|
|
2008-11-29 01:22:29 +00:00
|
|
|
user_options = [
|
2015-08-25 12:20:14 +00:00
|
|
|
('build-lib', None, 'lib build folder'),
|
2018-06-01 14:35:19 +00:00
|
|
|
('develop', 'D', 'Compile translations in develop mode (deluge/i18n)'),
|
2008-11-29 01:22:29 +00:00
|
|
|
]
|
2013-05-06 06:34:26 +00:00
|
|
|
boolean_options = ['develop']
|
2008-11-29 01:22:29 +00:00
|
|
|
|
2007-09-16 01:24:08 +00:00
|
|
|
def initialize_options(self):
|
2008-11-29 01:22:29 +00:00
|
|
|
self.build_lib = None
|
2013-05-06 06:34:26 +00:00
|
|
|
self.develop = False
|
2007-09-16 01:24:08 +00:00
|
|
|
|
|
|
|
def finalize_options(self):
|
2008-11-29 01:22:29 +00:00
|
|
|
self.set_undefined_options('build', ('build_lib', 'build_lib'))
|
2007-09-16 01:24:08 +00:00
|
|
|
|
|
|
|
def run(self):
|
2015-08-22 13:25:15 +00:00
|
|
|
po_dir = os.path.join(os.path.dirname(__file__), 'deluge', 'i18n')
|
2011-07-13 20:49:25 +00:00
|
|
|
|
2013-05-06 06:34:26 +00:00
|
|
|
if self.develop:
|
2011-07-10 00:20:13 +00:00
|
|
|
basedir = po_dir
|
|
|
|
else:
|
|
|
|
basedir = os.path.join(self.build_lib, 'deluge', 'i18n')
|
2011-07-13 20:49:25 +00:00
|
|
|
|
2018-10-17 11:56:36 +00:00
|
|
|
intltool_merge = 'intltool-merge'
|
2021-12-13 21:10:42 +00:00
|
|
|
if not windows_check() and which(intltool_merge):
|
2017-02-23 11:53:39 +00:00
|
|
|
intltool_merge_opts = '--utf8 --quiet'
|
|
|
|
for data_file in (desktop_data, appdata_data):
|
|
|
|
# creates the translated file from .in file.
|
|
|
|
in_file = data_file + '.in'
|
|
|
|
if 'xml' in data_file:
|
|
|
|
intltool_merge_opts += ' --xml-style'
|
|
|
|
elif 'desktop' in data_file:
|
|
|
|
intltool_merge_opts += ' --desktop-style'
|
|
|
|
|
|
|
|
print('Creating file: %s' % data_file)
|
2018-10-02 14:39:51 +00:00
|
|
|
os.system(
|
|
|
|
'C_ALL=C '
|
|
|
|
+ '%s '
|
|
|
|
* 5
|
|
|
|
% (intltool_merge, intltool_merge_opts, po_dir, in_file, data_file)
|
|
|
|
)
|
2017-02-07 19:18:09 +00:00
|
|
|
|
2015-10-23 23:58:14 +00:00
|
|
|
print('Compiling po files from %s...' % po_dir)
|
2007-09-16 01:24:08 +00:00
|
|
|
for path, names, filenames in os.walk(po_dir):
|
|
|
|
for f in filenames:
|
2014-09-03 21:28:28 +00:00
|
|
|
upto_date = False
|
2007-09-16 01:24:08 +00:00
|
|
|
if f.endswith('.po'):
|
2018-10-02 14:39:51 +00:00
|
|
|
lang = f[: len(f) - 3]
|
2007-09-16 01:24:08 +00:00
|
|
|
src = os.path.join(path, f)
|
2011-07-10 00:20:13 +00:00
|
|
|
dest_path = os.path.join(basedir, lang, 'LC_MESSAGES')
|
2007-09-16 01:24:08 +00:00
|
|
|
dest = os.path.join(dest_path, 'deluge.mo')
|
|
|
|
if not os.path.exists(dest_path):
|
|
|
|
os.makedirs(dest_path)
|
|
|
|
if not os.path.exists(dest):
|
2011-07-13 20:49:25 +00:00
|
|
|
sys.stdout.write('%s, ' % lang)
|
|
|
|
sys.stdout.flush()
|
2007-09-16 01:24:08 +00:00
|
|
|
msgfmt.make(src, dest)
|
|
|
|
else:
|
|
|
|
src_mtime = os.stat(src)[8]
|
|
|
|
dest_mtime = os.stat(dest)[8]
|
|
|
|
if src_mtime > dest_mtime:
|
2011-07-13 20:49:25 +00:00
|
|
|
sys.stdout.write('%s, ' % lang)
|
|
|
|
sys.stdout.flush()
|
2007-09-16 01:24:08 +00:00
|
|
|
msgfmt.make(src, dest)
|
2011-07-13 20:49:25 +00:00
|
|
|
else:
|
2014-09-03 21:28:28 +00:00
|
|
|
upto_date = True
|
2011-07-22 18:12:47 +00:00
|
|
|
|
2014-09-03 21:28:28 +00:00
|
|
|
if upto_date:
|
2021-09-21 20:40:13 +00:00
|
|
|
sys.stdout.write(' po files already up to date. ')
|
2011-07-13 20:49:25 +00:00
|
|
|
sys.stdout.write('\b\b \nFinished compiling translation files. \n')
|
2007-09-16 01:24:08 +00:00
|
|
|
|
2013-05-06 06:34:26 +00:00
|
|
|
|
2021-12-13 21:10:42 +00:00
|
|
|
class CleanTranslations(Command):
|
2016-11-27 21:47:34 +00:00
|
|
|
description = 'Cleans translations files.'
|
2018-10-02 14:39:51 +00:00
|
|
|
user_options = [
|
|
|
|
('all', 'a', 'Remove all build output, not just temporary by-products')
|
|
|
|
]
|
2016-11-27 21:47:34 +00:00
|
|
|
boolean_options = ['all']
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
self.all = None
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
self.set_undefined_options('clean', ('all', 'all'))
|
|
|
|
|
|
|
|
def run(self):
|
2017-02-23 11:53:39 +00:00
|
|
|
for path in (desktop_data, appdata_data):
|
|
|
|
if os.path.isfile(path):
|
|
|
|
print('Deleting %s' % path)
|
|
|
|
os.remove(path)
|
2016-11-27 21:47:34 +00:00
|
|
|
|
|
|
|
|
2021-12-13 21:10:42 +00:00
|
|
|
class BuildPlugins(Command):
|
2015-08-25 12:20:14 +00:00
|
|
|
description = 'Build plugins into .eggs'
|
2008-11-23 05:57:35 +00:00
|
|
|
|
2013-05-06 06:34:26 +00:00
|
|
|
user_options = [
|
2015-08-25 12:20:14 +00:00
|
|
|
('install-dir=', None, 'develop install folder'),
|
2018-06-01 14:35:19 +00:00
|
|
|
('develop', 'D', 'Compile plugins in develop mode'),
|
2013-05-06 06:34:26 +00:00
|
|
|
]
|
|
|
|
boolean_options = ['develop']
|
2011-06-05 15:58:27 +00:00
|
|
|
|
|
|
|
def initialize_options(self):
|
2013-05-06 06:34:26 +00:00
|
|
|
self.install_dir = None
|
|
|
|
self.develop = False
|
2011-06-05 15:58:27 +00:00
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
# Build the plugin eggs
|
2015-08-25 12:20:14 +00:00
|
|
|
plugin_path = 'deluge/plugins/*'
|
2011-06-05 15:58:27 +00:00
|
|
|
|
2014-09-03 21:28:28 +00:00
|
|
|
for path in glob.glob(plugin_path):
|
2015-08-25 12:20:14 +00:00
|
|
|
if os.path.exists(os.path.join(path, 'setup.py')):
|
2013-05-06 06:34:26 +00:00
|
|
|
if self.develop and self.install_dir:
|
2018-10-02 14:39:51 +00:00
|
|
|
os.system(
|
|
|
|
'cd '
|
|
|
|
+ path
|
|
|
|
+ '&& '
|
|
|
|
+ sys.executable
|
|
|
|
+ ' setup.py develop --install-dir=%s' % self.install_dir
|
|
|
|
)
|
2013-05-06 06:34:26 +00:00
|
|
|
elif self.develop:
|
2018-10-02 14:39:51 +00:00
|
|
|
os.system(
|
|
|
|
'cd ' + path + '&& ' + sys.executable + ' setup.py develop'
|
|
|
|
)
|
2013-05-06 06:34:26 +00:00
|
|
|
else:
|
2018-10-02 14:39:51 +00:00
|
|
|
os.system(
|
|
|
|
'cd '
|
|
|
|
+ path
|
|
|
|
+ '&& '
|
|
|
|
+ sys.executable
|
|
|
|
+ ' setup.py bdist_egg -d ..'
|
|
|
|
)
|
2011-06-05 15:58:27 +00:00
|
|
|
|
|
|
|
|
2021-12-13 21:10:42 +00:00
|
|
|
class CleanPlugins(Command):
|
2015-08-25 12:20:14 +00:00
|
|
|
description = 'Cleans the plugin folders'
|
2018-10-02 14:39:51 +00:00
|
|
|
user_options = [
|
|
|
|
('all', 'a', 'Remove all build output, not just temporary by-products')
|
|
|
|
]
|
2008-11-25 22:21:14 +00:00
|
|
|
boolean_options = ['all']
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
self.all = None
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
self.set_undefined_options('clean', ('all', 'all'))
|
|
|
|
|
|
|
|
def run(self):
|
2015-08-25 12:20:14 +00:00
|
|
|
print('Cleaning the plugin\'s folders...')
|
2008-11-25 22:21:14 +00:00
|
|
|
|
2015-08-25 12:20:14 +00:00
|
|
|
plugin_path = 'deluge/plugins/*'
|
2008-11-25 22:21:14 +00:00
|
|
|
|
2014-09-03 21:28:28 +00:00
|
|
|
for path in glob.glob(plugin_path):
|
2015-08-25 12:20:14 +00:00
|
|
|
if os.path.exists(os.path.join(path, 'setup.py')):
|
|
|
|
c = 'cd ' + path + ' && ' + sys.executable + ' setup.py clean'
|
2008-11-25 22:21:14 +00:00
|
|
|
if self.all:
|
2015-08-25 12:20:14 +00:00
|
|
|
c += ' -a'
|
|
|
|
print('Calling \'%s\'' % c)
|
2008-11-25 22:21:14 +00:00
|
|
|
os.system(c)
|
|
|
|
|
|
|
|
# Delete the .eggs
|
2015-08-25 12:20:14 +00:00
|
|
|
if path[-4:] == '.egg':
|
2016-11-13 15:09:30 +00:00
|
|
|
print('Deleting egg file "%s"' % path)
|
2016-04-19 14:18:51 +00:00
|
|
|
os.remove(path)
|
|
|
|
|
|
|
|
# Delete the .egg-link
|
|
|
|
if path[-9:] == '.egg-link':
|
2016-11-13 15:09:30 +00:00
|
|
|
print('Deleting egg link "%s"' % path)
|
2008-11-25 22:21:14 +00:00
|
|
|
os.remove(path)
|
|
|
|
|
2015-08-25 12:20:14 +00:00
|
|
|
egg_info_dir_path = 'deluge/plugins/*/*.egg-info'
|
2011-06-05 15:58:27 +00:00
|
|
|
|
2014-09-03 21:28:28 +00:00
|
|
|
for path in glob.glob(egg_info_dir_path):
|
2011-06-05 15:58:27 +00:00
|
|
|
# Delete the .egg-info's directories
|
2015-08-25 12:20:14 +00:00
|
|
|
if path[-9:] == '.egg-info':
|
|
|
|
print('Deleting %s' % path)
|
2011-06-05 15:58:27 +00:00
|
|
|
for fpath in os.listdir(path):
|
|
|
|
os.remove(os.path.join(path, fpath))
|
|
|
|
os.removedirs(path)
|
|
|
|
|
2012-01-09 19:58:37 +00:00
|
|
|
|
2021-12-13 21:10:42 +00:00
|
|
|
class EggInfoPlugins(Command):
|
2016-11-27 21:49:19 +00:00
|
|
|
description = 'Create .egg-info directories for plugins'
|
|
|
|
|
|
|
|
user_options = []
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
# Build the plugin eggs
|
|
|
|
plugin_path = 'deluge/plugins/*'
|
|
|
|
|
|
|
|
for path in glob.glob(plugin_path):
|
|
|
|
if os.path.exists(os.path.join(path, 'setup.py')):
|
|
|
|
os.system('cd ' + path + '&& ' + sys.executable + ' setup.py egg_info')
|
|
|
|
|
|
|
|
|
|
|
|
class Build(_build):
|
|
|
|
sub_commands = [
|
|
|
|
('build_webui', None),
|
|
|
|
('build_trans', None),
|
2018-06-01 14:35:19 +00:00
|
|
|
('build_plugins', None),
|
2016-11-27 21:49:19 +00:00
|
|
|
] + _build.sub_commands
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
# Run all sub-commands (at least those that need to be run).
|
|
|
|
_build.run(self)
|
|
|
|
try:
|
2017-12-17 10:55:13 +00:00
|
|
|
from deluge._libtorrent import LT_VERSION
|
2018-10-02 14:39:51 +00:00
|
|
|
|
2021-12-28 20:20:57 +00:00
|
|
|
print(f'Info: Found libtorrent ({LT_VERSION}) installed.')
|
2016-11-27 21:49:19 +00:00
|
|
|
except ImportError as ex:
|
|
|
|
print('Warning: libtorrent (libtorrent-rasterbar) not found: %s' % ex)
|
|
|
|
|
|
|
|
|
|
|
|
class InstallData(_install_data):
|
|
|
|
"""Custom class to fix `setup install` copying data files to incorrect location. (Bug #1389)"""
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
self.install_dir = None
|
2018-10-02 14:39:51 +00:00
|
|
|
self.set_undefined_options(
|
|
|
|
'install',
|
|
|
|
('install_data', 'install_dir'),
|
|
|
|
('root', 'root'),
|
|
|
|
('force', 'force'),
|
|
|
|
)
|
2016-11-27 21:49:19 +00:00
|
|
|
|
|
|
|
def run(self):
|
|
|
|
_install_data.run(self)
|
|
|
|
|
|
|
|
|
2016-11-28 12:57:07 +00:00
|
|
|
class Clean(_clean):
|
2016-11-27 21:47:34 +00:00
|
|
|
sub_commands = _clean.sub_commands + [
|
|
|
|
('clean_plugins', None),
|
|
|
|
('clean_trans', None),
|
2018-10-02 14:39:51 +00:00
|
|
|
('clean_webui', None),
|
|
|
|
]
|
2016-11-28 12:57:07 +00:00
|
|
|
|
|
|
|
def run(self):
|
|
|
|
# Remove deluge egg-info.
|
|
|
|
root_egg_info_dir_path = 'deluge*.egg-info'
|
2014-09-03 21:28:28 +00:00
|
|
|
for path in glob.glob(root_egg_info_dir_path):
|
2015-08-25 12:20:14 +00:00
|
|
|
print('Deleting %s' % path)
|
2012-01-09 19:58:37 +00:00
|
|
|
for fpath in os.listdir(path):
|
|
|
|
os.remove(os.path.join(path, fpath))
|
|
|
|
os.removedirs(path)
|
|
|
|
|
2008-11-25 22:21:14 +00:00
|
|
|
# Run all sub-commands (at least those that need to be run)
|
|
|
|
for cmd_name in self.get_sub_commands():
|
|
|
|
self.run_command(cmd_name)
|
|
|
|
_clean.run(self)
|
|
|
|
|
2016-11-16 22:18:18 +00:00
|
|
|
|
2007-09-16 01:24:08 +00:00
|
|
|
cmdclass = {
|
2014-09-20 17:55:21 +00:00
|
|
|
'build': Build,
|
2015-08-22 13:25:15 +00:00
|
|
|
'build_webui': BuildWebUI,
|
2014-09-20 17:55:21 +00:00
|
|
|
'build_trans': BuildTranslations,
|
|
|
|
'build_plugins': BuildPlugins,
|
2018-11-02 00:09:53 +00:00
|
|
|
'build_docs': BuildDoc,
|
2019-06-15 18:44:33 +00:00
|
|
|
'spellcheck_docs': BuildDoc,
|
2015-08-24 22:35:24 +00:00
|
|
|
'install_data': InstallData,
|
2014-09-20 17:55:21 +00:00
|
|
|
'clean_plugins': CleanPlugins,
|
2016-11-27 21:47:34 +00:00
|
|
|
'clean_trans': CleanTranslations,
|
2016-11-27 17:04:12 +00:00
|
|
|
'clean_docs': CleanDocs,
|
2016-11-27 22:07:56 +00:00
|
|
|
'clean_webui': CleanWebUI,
|
2014-09-20 17:55:21 +00:00
|
|
|
'clean': Clean,
|
2014-09-21 14:37:29 +00:00
|
|
|
'egg_info_plugins': EggInfoPlugins,
|
|
|
|
'test': PyTest,
|
2007-09-16 01:24:08 +00:00
|
|
|
}
|
|
|
|
|
2016-11-27 22:04:31 +00:00
|
|
|
|
2015-09-20 17:39:20 +00:00
|
|
|
if not windows_check() and not osx_check():
|
2016-12-01 19:41:58 +00:00
|
|
|
for icon_path in glob.glob('deluge/ui/data/icons/hicolor/*x*'):
|
|
|
|
size = os.path.basename(icon_path)
|
2018-11-08 12:29:14 +00:00
|
|
|
icons = glob.glob(os.path.join(icon_path, 'apps', 'deluge*.png'))
|
2021-12-28 20:20:57 +00:00
|
|
|
_data_files.append((f'share/icons/hicolor/{size}/apps', icons))
|
2018-10-02 14:39:51 +00:00
|
|
|
_data_files.extend(
|
|
|
|
[
|
|
|
|
(
|
|
|
|
'share/icons/hicolor/scalable/apps',
|
|
|
|
['deluge/ui/data/icons/hicolor/scalable/apps/deluge.svg'],
|
|
|
|
),
|
|
|
|
('share/pixmaps', ['deluge/ui/data/pixmaps/deluge.png']),
|
|
|
|
(
|
|
|
|
'share/man/man1',
|
|
|
|
[
|
|
|
|
'docs/man/deluge.1',
|
|
|
|
'docs/man/deluged.1',
|
|
|
|
'docs/man/deluge-gtk.1',
|
|
|
|
'docs/man/deluge-web.1',
|
|
|
|
'docs/man/deluge-console.1',
|
|
|
|
],
|
|
|
|
),
|
|
|
|
]
|
|
|
|
)
|
2016-11-27 22:04:31 +00:00
|
|
|
if os.path.isfile(desktop_data):
|
2015-08-27 10:27:37 +00:00
|
|
|
_data_files.append(('share/applications', [desktop_data]))
|
2017-02-07 19:18:09 +00:00
|
|
|
if os.path.isfile(appdata_data):
|
|
|
|
_data_files.append(('share/appdata', [appdata_data]))
|
2011-07-22 18:12:47 +00:00
|
|
|
|
2016-11-27 22:04:31 +00:00
|
|
|
_entry_points['console_scripts'] = [
|
2016-12-01 19:41:58 +00:00
|
|
|
'deluge-console = deluge.ui.console:start',
|
2022-01-30 15:38:52 +00:00
|
|
|
]
|
|
|
|
# On Windows use gui_scripts to hide cmd popup
|
|
|
|
script_type = 'gui_scripts' if windows_check() else 'console_scripts'
|
|
|
|
_entry_points[script_type] = [
|
2016-12-01 19:41:58 +00:00
|
|
|
'deluge-web = deluge.ui.web:start',
|
2018-10-02 14:39:51 +00:00
|
|
|
'deluged = deluge.core.daemon_entry:start_daemon',
|
|
|
|
]
|
2010-10-31 09:18:09 +00:00
|
|
|
if windows_check():
|
2018-10-02 14:39:51 +00:00
|
|
|
_entry_points['console_scripts'].extend(
|
|
|
|
[
|
|
|
|
'deluge-debug = deluge.ui.ui_entry:start_ui',
|
|
|
|
'deluge-web-debug = deluge.ui.web:start',
|
|
|
|
'deluged-debug = deluge.core.daemon_entry:start_daemon',
|
|
|
|
]
|
|
|
|
)
|
2016-11-27 22:04:31 +00:00
|
|
|
_entry_points['gui_scripts'] = [
|
2016-12-01 19:41:58 +00:00
|
|
|
'deluge = deluge.ui.ui_entry:start_ui',
|
2018-07-13 08:34:49 +00:00
|
|
|
'deluge-gtk = deluge.ui.gtk3:start',
|
2018-10-02 14:39:51 +00:00
|
|
|
]
|
2016-11-27 22:04:31 +00:00
|
|
|
_entry_points['deluge.ui'] = [
|
2016-12-01 19:41:58 +00:00
|
|
|
'console = deluge.ui.console:Console',
|
|
|
|
'web = deluge.ui.web:Web',
|
2018-07-13 08:34:49 +00:00
|
|
|
'gtk = deluge.ui.gtk3:Gtk',
|
2018-10-02 14:39:51 +00:00
|
|
|
]
|
2016-11-27 22:04:31 +00:00
|
|
|
|
2010-10-31 09:18:09 +00:00
|
|
|
|
2018-10-12 13:41:05 +00:00
|
|
|
_package_data['deluge'] = [
|
2015-09-04 18:43:06 +00:00
|
|
|
'ui/data/pixmaps/*.png',
|
|
|
|
'ui/data/pixmaps/*.svg',
|
|
|
|
'ui/data/pixmaps/*.ico',
|
|
|
|
'ui/data/pixmaps/*.gif',
|
|
|
|
'ui/data/pixmaps/flags/*.png',
|
|
|
|
'plugins/*.egg',
|
2018-10-02 14:39:51 +00:00
|
|
|
'i18n/*/LC_MESSAGES/*.mo',
|
|
|
|
]
|
2015-09-04 18:43:06 +00:00
|
|
|
_package_data['deluge.ui.web'] = [
|
|
|
|
'index.html',
|
|
|
|
'css/*.css',
|
|
|
|
'icons/*.png',
|
|
|
|
'images/*.gif',
|
|
|
|
'images/*.png',
|
|
|
|
'js/*.js',
|
|
|
|
'js/extjs/*.js',
|
|
|
|
'render/*.html',
|
|
|
|
'themes/css/*.css',
|
|
|
|
'themes/images/*/*.gif',
|
|
|
|
'themes/images/*/*.png',
|
|
|
|
'themes/images/*/*/*.gif',
|
2018-10-02 14:39:51 +00:00
|
|
|
'themes/images/*/*/*.png',
|
|
|
|
]
|
2018-07-13 08:34:49 +00:00
|
|
|
_package_data['deluge.ui.gtk3'] = ['glade/*.ui']
|
2015-09-04 18:43:06 +00:00
|
|
|
|
2018-10-17 11:57:08 +00:00
|
|
|
setup_requires = ['setuptools', 'wheel']
|
|
|
|
install_requires = [
|
2019-05-17 08:52:06 +00:00
|
|
|
'twisted[tls]>=17.1',
|
2018-10-17 11:57:08 +00:00
|
|
|
# Add pyasn1 for setuptools workaround:
|
|
|
|
# https://github.com/pypa/setuptools/issues/1510
|
|
|
|
'pyasn1',
|
2018-11-01 20:53:46 +00:00
|
|
|
'rencode',
|
2018-10-17 11:57:08 +00:00
|
|
|
'pyopenssl',
|
|
|
|
'pyxdg',
|
|
|
|
'mako',
|
2019-06-21 09:56:10 +00:00
|
|
|
'setuptools',
|
2018-11-11 14:56:49 +00:00
|
|
|
"pywin32; sys_platform == 'win32'",
|
|
|
|
"certifi; sys_platform == 'win32'",
|
2018-10-17 11:57:08 +00:00
|
|
|
'zope.interface',
|
|
|
|
]
|
2019-06-21 09:56:10 +00:00
|
|
|
extras_require = {
|
|
|
|
'all': [
|
|
|
|
'setproctitle',
|
|
|
|
'pillow',
|
|
|
|
'chardet',
|
2020-02-13 05:13:44 +00:00
|
|
|
'ifaddr',
|
2019-06-21 09:56:10 +00:00
|
|
|
]
|
|
|
|
}
|
2018-04-25 13:23:05 +00:00
|
|
|
|
2007-07-04 08:24:30 +00:00
|
|
|
# Main setup
|
|
|
|
setup(
|
2015-08-25 12:20:14 +00:00
|
|
|
name='deluge',
|
2015-09-04 18:43:06 +00:00
|
|
|
version=_version,
|
2016-11-27 21:50:33 +00:00
|
|
|
fullname='Deluge BitTorrent Client',
|
|
|
|
description='BitTorrent Client',
|
2017-06-24 22:23:36 +00:00
|
|
|
author='Deluge Team',
|
|
|
|
maintainer='Calum Lind',
|
|
|
|
maintainer_email='calumlind+deluge@gmail.com',
|
2015-08-25 12:20:14 +00:00
|
|
|
keywords='torrent bittorrent p2p fileshare filesharing',
|
2018-10-16 12:15:07 +00:00
|
|
|
long_description=open('README.md').read(),
|
|
|
|
long_description_content_type='text/markdown',
|
2018-04-25 13:23:05 +00:00
|
|
|
url='https://deluge-torrent.org',
|
2019-05-21 14:48:43 +00:00
|
|
|
project_urls={
|
|
|
|
'GitHub (mirror)': 'https://github.com/deluge-torrent/deluge',
|
|
|
|
'Sourcecode': 'http://git.deluge-torrent.org/deluge',
|
|
|
|
'Issues': 'https://dev.deluge-torrent.org/report/1',
|
|
|
|
'Discussion': 'https://forum.deluge-torrent.org',
|
|
|
|
'Documentation': 'https://deluge.readthedocs.io',
|
|
|
|
},
|
2017-06-24 22:23:36 +00:00
|
|
|
classifiers=[
|
2018-04-25 13:23:05 +00:00
|
|
|
'Development Status :: 4 - Beta',
|
2017-06-24 22:23:36 +00:00
|
|
|
'Environment :: Console',
|
|
|
|
'Environment :: Web Environment',
|
|
|
|
'Environment :: X11 Applications :: GTK',
|
|
|
|
'Framework :: Twisted',
|
|
|
|
'Intended Audience :: End Users/Desktop',
|
2018-10-02 14:39:51 +00:00
|
|
|
(
|
|
|
|
'License :: OSI Approved :: '
|
|
|
|
'GNU General Public License v3 or later (GPLv3+)'
|
|
|
|
),
|
2018-04-25 13:23:05 +00:00
|
|
|
'Programming Language :: Python',
|
2017-06-24 22:23:36 +00:00
|
|
|
'Operating System :: MacOS :: MacOS X',
|
|
|
|
'Operating System :: Microsoft :: Windows',
|
|
|
|
'Operating System :: POSIX',
|
2018-10-02 14:39:51 +00:00
|
|
|
'Topic :: Internet',
|
|
|
|
],
|
2021-12-28 20:20:57 +00:00
|
|
|
python_requires='>=3.6',
|
2018-10-18 08:19:35 +00:00
|
|
|
license='GPLv3+',
|
2014-09-03 21:28:28 +00:00
|
|
|
cmdclass=cmdclass,
|
2018-10-17 11:57:08 +00:00
|
|
|
setup_requires=setup_requires,
|
|
|
|
install_requires=install_requires,
|
2019-06-21 09:56:10 +00:00
|
|
|
extras_require=extras_require,
|
2014-09-03 21:28:28 +00:00
|
|
|
data_files=_data_files,
|
2015-09-04 18:43:06 +00:00
|
|
|
package_data=_package_data,
|
|
|
|
exclude_package_data=_exclude_package_data,
|
2017-06-24 21:29:55 +00:00
|
|
|
packages=find_packages(exclude=['deluge.plugins.*', 'deluge.tests']),
|
2018-06-01 14:35:19 +00:00
|
|
|
entry_points=_entry_points,
|
2008-07-10 04:40:13 +00:00
|
|
|
)
|