mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-09 18:08:39 +00:00
[Packaging] Start replacing deprecated distutils
Working towards removing distutils > direct usage of distutils is now actively discouraged, with setuptools being the preferred replacement. Ref: https://setuptools.pypa.io/en/latest/deprecated/distutils-legacy.html
This commit is contained in:
parent
bca0aa3532
commit
073bbbc09d
2 changed files with 23 additions and 14 deletions
|
@ -22,11 +22,16 @@ import fnmatch
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from distutils.spawn import find_executable
|
|
||||||
|
try:
|
||||||
|
from shutil import which
|
||||||
|
except ImportError:
|
||||||
|
# PY2 Fallback
|
||||||
|
from distutils.spawn import find_executable as which
|
||||||
|
|
||||||
closure_cmd = None
|
closure_cmd = None
|
||||||
for cmd in ['closure-compiler', 'closure']:
|
for cmd in ['closure-compiler', 'closure']:
|
||||||
if find_executable(cmd):
|
if which(cmd):
|
||||||
closure_cmd = cmd
|
closure_cmd = cmd
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
28
setup.py
28
setup.py
|
@ -15,19 +15,23 @@ import glob
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import sys
|
import sys
|
||||||
from distutils import cmd
|
|
||||||
from distutils.command.build import build as _build
|
from distutils.command.build import build as _build
|
||||||
from distutils.command.clean import clean as _clean
|
from distutils.command.clean import clean as _clean
|
||||||
from distutils.command.install_data import install_data as _install_data
|
from distutils.command.install_data import install_data as _install_data
|
||||||
from distutils.spawn import find_executable
|
|
||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
|
|
||||||
from setuptools import find_packages, setup
|
from setuptools import Command, find_packages, setup
|
||||||
from setuptools.command.test import test as _test
|
from setuptools.command.test import test as _test
|
||||||
|
|
||||||
import msgfmt
|
import msgfmt
|
||||||
from version import get_version
|
from version import get_version
|
||||||
|
|
||||||
|
try:
|
||||||
|
from shutil import which
|
||||||
|
except ImportError:
|
||||||
|
# PY2 Fallback
|
||||||
|
from distutils.spawn import find_executable as which
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from sphinx.setup_command import BuildDoc
|
from sphinx.setup_command import BuildDoc
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -72,7 +76,7 @@ class PyTest(_test):
|
||||||
sys.exit(errcode)
|
sys.exit(errcode)
|
||||||
|
|
||||||
|
|
||||||
class CleanDocs(cmd.Command):
|
class CleanDocs(Command):
|
||||||
description = 'Clean the documentation build and module rst files'
|
description = 'Clean the documentation build and module rst files'
|
||||||
user_options = []
|
user_options = []
|
||||||
|
|
||||||
|
@ -94,7 +98,7 @@ class CleanDocs(cmd.Command):
|
||||||
os.remove(module)
|
os.remove(module)
|
||||||
|
|
||||||
|
|
||||||
class BuildWebUI(cmd.Command):
|
class BuildWebUI(Command):
|
||||||
description = 'Minify WebUI files'
|
description = 'Minify WebUI files'
|
||||||
user_options = []
|
user_options = []
|
||||||
|
|
||||||
|
@ -145,7 +149,7 @@ class BuildWebUI(cmd.Command):
|
||||||
create_gettext_js(deluge_all_path)
|
create_gettext_js(deluge_all_path)
|
||||||
|
|
||||||
|
|
||||||
class CleanWebUI(cmd.Command):
|
class CleanWebUI(Command):
|
||||||
description = 'Clean the documentation build and rst files'
|
description = 'Clean the documentation build and rst files'
|
||||||
user_options = []
|
user_options = []
|
||||||
|
|
||||||
|
@ -177,7 +181,7 @@ class CleanWebUI(cmd.Command):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class BuildTranslations(cmd.Command):
|
class BuildTranslations(Command):
|
||||||
description = 'Compile .po files into .mo files & create .desktop file'
|
description = 'Compile .po files into .mo files & create .desktop file'
|
||||||
|
|
||||||
user_options = [
|
user_options = [
|
||||||
|
@ -202,7 +206,7 @@ class BuildTranslations(cmd.Command):
|
||||||
basedir = os.path.join(self.build_lib, 'deluge', 'i18n')
|
basedir = os.path.join(self.build_lib, 'deluge', 'i18n')
|
||||||
|
|
||||||
intltool_merge = 'intltool-merge'
|
intltool_merge = 'intltool-merge'
|
||||||
if not windows_check() and find_executable(intltool_merge):
|
if not windows_check() and which(intltool_merge):
|
||||||
intltool_merge_opts = '--utf8 --quiet'
|
intltool_merge_opts = '--utf8 --quiet'
|
||||||
for data_file in (desktop_data, appdata_data):
|
for data_file in (desktop_data, appdata_data):
|
||||||
# creates the translated file from .in file.
|
# creates the translated file from .in file.
|
||||||
|
@ -250,7 +254,7 @@ class BuildTranslations(cmd.Command):
|
||||||
sys.stdout.write('\b\b \nFinished compiling translation files. \n')
|
sys.stdout.write('\b\b \nFinished compiling translation files. \n')
|
||||||
|
|
||||||
|
|
||||||
class CleanTranslations(cmd.Command):
|
class CleanTranslations(Command):
|
||||||
description = 'Cleans translations files.'
|
description = 'Cleans translations files.'
|
||||||
user_options = [
|
user_options = [
|
||||||
('all', 'a', 'Remove all build output, not just temporary by-products')
|
('all', 'a', 'Remove all build output, not just temporary by-products')
|
||||||
|
@ -270,7 +274,7 @@ class CleanTranslations(cmd.Command):
|
||||||
os.remove(path)
|
os.remove(path)
|
||||||
|
|
||||||
|
|
||||||
class BuildPlugins(cmd.Command):
|
class BuildPlugins(Command):
|
||||||
description = 'Build plugins into .eggs'
|
description = 'Build plugins into .eggs'
|
||||||
|
|
||||||
user_options = [
|
user_options = [
|
||||||
|
@ -314,7 +318,7 @@ class BuildPlugins(cmd.Command):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class CleanPlugins(cmd.Command):
|
class CleanPlugins(Command):
|
||||||
description = 'Cleans the plugin folders'
|
description = 'Cleans the plugin folders'
|
||||||
user_options = [
|
user_options = [
|
||||||
('all', 'a', 'Remove all build output, not just temporary by-products')
|
('all', 'a', 'Remove all build output, not just temporary by-products')
|
||||||
|
@ -361,7 +365,7 @@ class CleanPlugins(cmd.Command):
|
||||||
os.removedirs(path)
|
os.removedirs(path)
|
||||||
|
|
||||||
|
|
||||||
class EggInfoPlugins(cmd.Command):
|
class EggInfoPlugins(Command):
|
||||||
description = 'Create .egg-info directories for plugins'
|
description = 'Create .egg-info directories for plugins'
|
||||||
|
|
||||||
user_options = []
|
user_options = []
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue