2018-04-24 18:22:10 +00:00
|
|
|
#!/usr/bin/env python
|
2007-07-28 03:37:57 +00:00
|
|
|
|
2020-05-01 14:43:20 +00:00
|
|
|
from setuptools import setup, Distribution, Command
|
|
|
|
|
2008-07-16 22:13:38 +00:00
|
|
|
from distutils.command.install_data import install_data
|
2008-04-10 16:08:53 +00:00
|
|
|
from distutils.command.build import build
|
2007-12-29 03:01:28 +00:00
|
|
|
from distutils.dep_util import newer
|
2010-01-19 20:33:35 +00:00
|
|
|
from distutils.log import warn, info, error
|
|
|
|
from distutils.errors import DistutilsFileError
|
2020-05-01 14:43:20 +00:00
|
|
|
|
2007-12-29 03:01:28 +00:00
|
|
|
import glob
|
|
|
|
import os
|
|
|
|
import sys
|
2008-07-06 16:27:00 +00:00
|
|
|
import subprocess
|
2008-06-18 17:07:15 +00:00
|
|
|
import platform
|
2007-12-29 03:01:28 +00:00
|
|
|
|
2010-01-19 20:33:35 +00:00
|
|
|
from terminatorlib.version import APP_NAME, APP_VERSION
|
2008-04-03 04:44:58 +00:00
|
|
|
|
2020-05-17 21:24:14 +00:00
|
|
|
GETTEXT_SOURCE = 'po'
|
|
|
|
GETTEXT_DOMAIN = 'terminator'
|
|
|
|
GETTEXT_TARGET = os.path.join('share', 'locale')
|
2016-12-12 21:53:46 +00:00
|
|
|
CSS_DIR = os.path.join('terminatorlib', 'themes')
|
2007-12-29 03:01:28 +00:00
|
|
|
|
2020-05-01 15:38:28 +00:00
|
|
|
if sys.version_info < (3, 0):
|
|
|
|
PYTEST_VERSION = '<5'
|
2020-05-11 02:34:18 +00:00
|
|
|
BABELGLADE_VERSION = '< 0.7'
|
2020-05-01 15:38:28 +00:00
|
|
|
else:
|
|
|
|
PYTEST_VERSION = '>0'
|
2020-05-11 02:34:18 +00:00
|
|
|
BABELGLADE_VERSION = '> 0'
|
2020-05-01 15:38:28 +00:00
|
|
|
|
2020-05-01 14:43:20 +00:00
|
|
|
|
2008-07-06 17:28:31 +00:00
|
|
|
class TerminatorDist(Distribution):
|
|
|
|
global_options = Distribution.global_options + [
|
2015-09-01 20:50:09 +00:00
|
|
|
("build-documentation", None, "Build the documentation"),
|
|
|
|
("install-documentation", None, "Install the documentation"),
|
2008-08-29 23:57:35 +00:00
|
|
|
("without-icon-cache", None, "Don't attempt to run gtk-update-icon-cache")]
|
2008-07-06 16:27:00 +00:00
|
|
|
|
2008-07-06 17:28:31 +00:00
|
|
|
def __init__ (self, *args):
|
2008-08-29 23:57:35 +00:00
|
|
|
self.without_icon_cache = False
|
2008-07-06 17:28:31 +00:00
|
|
|
Distribution.__init__(self, *args)
|
2008-07-06 16:27:00 +00:00
|
|
|
|
|
|
|
|
2020-05-17 21:24:14 +00:00
|
|
|
class CustomBuild(build):
|
|
|
|
"""
|
|
|
|
Custom build extensions to build
|
|
|
|
"""
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
build.run(self)
|
|
|
|
self.build_i18n()
|
|
|
|
|
|
|
|
def build_i18n(self):
|
|
|
|
"""
|
|
|
|
Compiling files for gettext from *.po to *.mo with the proper target path
|
|
|
|
"""
|
|
|
|
info('compiling i18n files')
|
|
|
|
from babel.messages.frontend import compile_catalog
|
|
|
|
compiler = compile_catalog(self.distribution)
|
|
|
|
compiler.domain = [GETTEXT_DOMAIN]
|
|
|
|
|
|
|
|
for po in glob.glob(os.path.join(GETTEXT_SOURCE, '*.po')):
|
|
|
|
lang = os.path.basename(po[:-3])
|
|
|
|
mo = os.path.join(self.build_base, GETTEXT_TARGET, lang, 'LC_MESSAGES', 'terminator.mo')
|
|
|
|
|
|
|
|
directory = os.path.dirname(mo)
|
|
|
|
if not os.path.exists(directory):
|
|
|
|
os.makedirs(directory)
|
|
|
|
|
|
|
|
if newer(po, mo):
|
|
|
|
compiler.input_file = po
|
|
|
|
compiler.output_file = mo
|
|
|
|
compiler.run()
|
|
|
|
|
2015-09-01 20:50:09 +00:00
|
|
|
|
2008-08-29 23:57:35 +00:00
|
|
|
class Uninstall(Command):
|
|
|
|
description = "Attempt an uninstall from an install --record file"
|
|
|
|
|
|
|
|
user_options = [('manifest=', None, 'Installation record filename')]
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
self.manifest = None
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def get_command_name(self):
|
|
|
|
return 'uninstall'
|
|
|
|
|
|
|
|
def run(self):
|
2009-09-02 15:22:26 +00:00
|
|
|
f = None
|
2008-08-29 23:57:35 +00:00
|
|
|
self.ensure_filename('manifest')
|
|
|
|
try:
|
2008-09-03 18:34:20 +00:00
|
|
|
try:
|
2010-01-19 20:33:35 +00:00
|
|
|
if not self.manifest:
|
|
|
|
raise DistutilsFileError("Pass manifest with --manifest=file")
|
2008-09-03 18:34:20 +00:00
|
|
|
f = open(self.manifest)
|
|
|
|
files = [file.strip() for file in f]
|
2018-04-24 18:22:10 +00:00
|
|
|
except IOError as e:
|
2008-09-03 18:34:20 +00:00
|
|
|
raise DistutilsFileError("unable to open install manifest: %s", str(e))
|
2008-08-29 23:57:35 +00:00
|
|
|
finally:
|
2009-09-02 15:22:26 +00:00
|
|
|
if f:
|
|
|
|
f.close()
|
2008-08-29 23:57:35 +00:00
|
|
|
|
|
|
|
for file in files:
|
|
|
|
if os.path.isfile(file) or os.path.islink(file):
|
|
|
|
info("removing %s" % repr(file))
|
|
|
|
if not self.dry_run:
|
|
|
|
try:
|
|
|
|
os.unlink(file)
|
2018-04-24 18:22:10 +00:00
|
|
|
except OSError as e:
|
2008-08-29 23:57:35 +00:00
|
|
|
warn("could not delete: %s" % repr(file))
|
|
|
|
elif not os.path.isdir(file):
|
|
|
|
info("skipping %s" % repr(file))
|
|
|
|
|
|
|
|
dirs = set()
|
|
|
|
for file in reversed(sorted(files)):
|
|
|
|
dir = os.path.dirname(file)
|
|
|
|
if dir not in dirs and os.path.isdir(dir) and len(os.listdir(dir)) == 0:
|
|
|
|
dirs.add(dir)
|
|
|
|
# Only nuke empty Python library directories, else we could destroy
|
|
|
|
# e.g. locale directories we're the only app with a .mo installed for.
|
|
|
|
if dir.find("site-packages/") > 0:
|
|
|
|
info("removing %s" % repr(dir))
|
|
|
|
if not self.dry_run:
|
|
|
|
try:
|
|
|
|
os.rmdir(dir)
|
2018-04-24 18:22:10 +00:00
|
|
|
except OSError as e:
|
2008-08-29 23:57:35 +00:00
|
|
|
warn("could not remove directory: %s" % str(e))
|
|
|
|
else:
|
|
|
|
info("skipping empty directory %s" % repr(dir))
|
|
|
|
|
|
|
|
|
2008-04-10 16:08:53 +00:00
|
|
|
class InstallData(install_data):
|
|
|
|
def run (self):
|
2016-12-12 21:53:46 +00:00
|
|
|
self.data_files.extend (self._find_css_files ())
|
2020-05-17 21:24:14 +00:00
|
|
|
self.data_files.extend(self._find_mo_files())
|
2008-04-10 16:08:53 +00:00
|
|
|
install_data.run (self)
|
2008-08-29 23:57:35 +00:00
|
|
|
if not self.distribution.without_icon_cache:
|
|
|
|
self._update_icon_cache ()
|
2008-04-10 16:08:53 +00:00
|
|
|
|
2008-08-29 23:57:35 +00:00
|
|
|
# We should do this on uninstall too
|
|
|
|
def _update_icon_cache(self):
|
|
|
|
info("running gtk-update-icon-cache")
|
|
|
|
try:
|
|
|
|
subprocess.call(["gtk-update-icon-cache", "-q", "-f", "-t", os.path.join(self.install_dir, "share/icons/hicolor")])
|
2018-04-24 18:22:10 +00:00
|
|
|
except Exception as e:
|
2008-08-29 23:57:35 +00:00
|
|
|
warn("updating the GTK icon cache failed: %s" % str(e))
|
2008-07-06 16:27:00 +00:00
|
|
|
|
2020-05-17 21:24:14 +00:00
|
|
|
def _find_mo_files(self):
|
|
|
|
"""
|
|
|
|
search for gettext files built during build step
|
|
|
|
"""
|
2008-04-10 16:08:53 +00:00
|
|
|
data_files = []
|
|
|
|
|
2020-05-17 21:24:14 +00:00
|
|
|
build_base = self.distribution.command_obj['build'].build_base
|
|
|
|
for mo in glob.glob(os.path.join(build_base, GETTEXT_TARGET, '*', 'LC_MESSAGES', '*.mo')):
|
|
|
|
dest = mo.lstrip(build_base + os.sep)
|
|
|
|
data_files.append((dest, [mo]))
|
2007-12-29 03:01:28 +00:00
|
|
|
|
|
|
|
return data_files
|
|
|
|
|
2016-12-12 21:53:46 +00:00
|
|
|
def _find_css_files (self):
|
|
|
|
data_files = []
|
|
|
|
|
|
|
|
for css_dir in glob.glob (os.path.join (CSS_DIR, '*')):
|
2016-12-12 22:20:02 +00:00
|
|
|
srce = glob.glob (os.path.join(css_dir, 'gtk-3.0', 'apps', '*.css'))
|
2016-12-12 21:53:46 +00:00
|
|
|
dest = os.path.join('share', 'terminator', css_dir, 'gtk-3.0', 'apps')
|
|
|
|
data_files.append((dest, srce))
|
|
|
|
|
|
|
|
return data_files
|
|
|
|
|
|
|
|
|
2020-05-17 21:24:14 +00:00
|
|
|
class UpdateCatalogs(Command):
|
|
|
|
"""Update all gettext catalogs """
|
|
|
|
description = __doc__
|
|
|
|
user_options = []
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
from babel.messages.frontend import update_catalog
|
|
|
|
updater = update_catalog(self.distribution)
|
|
|
|
updater.input_file = os.path.join(GETTEXT_SOURCE, 'terminator.pot')
|
|
|
|
|
|
|
|
for po in glob.glob(os.path.join(GETTEXT_SOURCE, '*.po')):
|
|
|
|
updater.output_file = po
|
|
|
|
updater.run()
|
|
|
|
|
|
|
|
|
2013-01-30 12:37:41 +00:00
|
|
|
if platform.system() in ['FreeBSD', 'OpenBSD']:
|
2008-06-18 17:07:15 +00:00
|
|
|
man_dir = 'man'
|
|
|
|
else:
|
|
|
|
man_dir = 'share/man'
|
|
|
|
|
2020-05-01 15:38:28 +00:00
|
|
|
test_deps = [
|
|
|
|
'pytest'
|
|
|
|
]
|
|
|
|
|
2017-03-13 18:40:25 +00:00
|
|
|
setup(name=APP_NAME,
|
2008-03-29 14:57:37 +00:00
|
|
|
version=APP_VERSION,
|
2007-07-28 03:37:57 +00:00
|
|
|
description='Terminator, the robot future of terminals',
|
|
|
|
author='Chris Jones',
|
|
|
|
author_email='cmsj@tenshu.net',
|
2020-04-12 23:10:15 +00:00
|
|
|
url='https://github.com/gnome-terminator/terminator',
|
2008-03-29 14:57:37 +00:00
|
|
|
license='GNU GPL v2',
|
2011-09-28 08:25:13 +00:00
|
|
|
scripts=['terminator', 'remotinator'],
|
2007-12-29 02:27:39 +00:00
|
|
|
data_files=[
|
2008-02-14 23:55:17 +00:00
|
|
|
('share/applications', ['data/terminator.desktop']),
|
2020-05-01 19:38:00 +00:00
|
|
|
('share/metainfo', ['data/terminator.metainfo.xml']),
|
2008-06-18 17:07:15 +00:00
|
|
|
(os.path.join(man_dir, 'man1'), ['doc/terminator.1']),
|
|
|
|
(os.path.join(man_dir, 'man5'), ['doc/terminator_config.5']),
|
2015-08-03 18:22:15 +00:00
|
|
|
('share/pixmaps', ['data/icons/hicolor/48x48/apps/terminator.png']),
|
|
|
|
('share/icons/hicolor/scalable/apps', glob.glob('data/icons/hicolor/scalable/apps/*.svg')),
|
|
|
|
('share/icons/hicolor/16x16/apps', glob.glob('data/icons/hicolor/16x16/apps/*.png')),
|
|
|
|
('share/icons/hicolor/22x22/apps', glob.glob('data/icons/hicolor/22x22/apps/*.png')),
|
|
|
|
('share/icons/hicolor/24x24/apps', glob.glob('data/icons/hicolor/24x24/apps/*.png')),
|
|
|
|
('share/icons/hicolor/32x32/apps', glob.glob('data/icons/hicolor/32x32/apps/*.png')),
|
|
|
|
('share/icons/hicolor/48x48/apps', glob.glob('data/icons/hicolor/48x48/apps/*.png')),
|
|
|
|
('share/icons/hicolor/16x16/actions', glob.glob('data/icons/hicolor/16x16/actions/*.png')),
|
|
|
|
('share/icons/hicolor/16x16/status', glob.glob('data/icons/hicolor/16x16/status/*.png')),
|
|
|
|
('share/icons/HighContrast/scalable/apps', glob.glob('data/icons/HighContrast/scalable/apps/*.svg')),
|
|
|
|
('share/icons/HighContrast/16x16/apps', glob.glob('data/icons/HighContrast/16x16/apps/*.png')),
|
|
|
|
('share/icons/HighContrast/22x22/apps', glob.glob('data/icons/HighContrast/22x22/apps/*.png')),
|
|
|
|
('share/icons/HighContrast/24x24/apps', glob.glob('data/icons/HighContrast/24x24/apps/*.png')),
|
|
|
|
('share/icons/HighContrast/32x32/apps', glob.glob('data/icons/HighContrast/32x32/apps/*.png')),
|
|
|
|
('share/icons/HighContrast/48x48/apps', glob.glob('data/icons/HighContrast/48x48/apps/*.png')),
|
|
|
|
('share/icons/HighContrast/16x16/actions', glob.glob('data/icons/HighContrast/16x16/actions/*.png')),
|
|
|
|
('share/icons/HighContrast/16x16/status', glob.glob('data/icons/HighContrast/16x16/status/*.png')),
|
2007-12-29 02:27:39 +00:00
|
|
|
],
|
2020-04-05 11:37:51 +00:00
|
|
|
packages=[
|
|
|
|
'terminatorlib',
|
|
|
|
'terminatorlib.plugins',
|
|
|
|
],
|
2020-05-01 14:43:20 +00:00
|
|
|
setup_requires=[
|
|
|
|
'pytest-runner',
|
2020-05-11 00:52:23 +00:00
|
|
|
'babel',
|
2020-05-11 02:34:18 +00:00
|
|
|
'BabelGladeExtractor ' + BABELGLADE_VERSION,
|
2020-05-01 14:43:20 +00:00
|
|
|
],
|
2020-04-05 11:37:51 +00:00
|
|
|
install_requires=[
|
|
|
|
'pycairo',
|
|
|
|
'configobj',
|
|
|
|
'dbus-python',
|
|
|
|
'pygobject',
|
|
|
|
'psutil',
|
|
|
|
],
|
2020-05-01 15:38:28 +00:00
|
|
|
tests_require=test_deps,
|
|
|
|
extras_require={'test': test_deps},
|
2013-08-29 11:00:20 +00:00
|
|
|
package_data={'terminatorlib': ['preferences.glade', 'layoutlauncher.glade']},
|
2020-05-17 22:03:28 +00:00
|
|
|
cmdclass={'build': CustomBuild, 'install_data': InstallData, 'uninstall': Uninstall,
|
|
|
|
'update_catalogs': UpdateCatalogs},
|
2020-05-01 14:43:20 +00:00
|
|
|
distclass=TerminatorDist)
|
2007-07-28 03:37:57 +00:00
|
|
|
|