Turn --without-gettext into a global option, so it doesn't need to be hacked into every command class.

This commit is contained in:
Thomas Hurst 2008-07-06 18:28:31 +01:00
parent 71f9dc5ca1
commit f03e8675b0
1 changed files with 11 additions and 33 deletions

View File

@ -2,7 +2,7 @@
from distutils.core import setup
from distutils.command.install_data import install_data
from distutils.command.install import install
from distutils.dist import Distribution
from distutils.command.build import build
from distutils.dep_util import newer
from distutils.log import info
@ -16,22 +16,21 @@ from terminatorlib.version import *
PO_DIR = 'po'
MO_DIR = os.path.join('build', 'mo')
WITHOUT_GETTEXT = False
# Someone with more distutils clue needs to sort out our --without-gettext nonsense
class BuildData(build):
user_options = build.user_options
user_options.append(("without-gettext", None, "Don't build gettext .mo files"))
class TerminatorDist(Distribution):
global_options = Distribution.global_options + [
("without-gettext", None, "Don't build/install gettext .mo files")]
def initialize_options(self):
build.initialize_options(self)
def __init__ (self, *args):
self.without_gettext = False
Distribution.__init__(self, *args)
class BuildData(build):
def run (self):
build.run (self)
if self.without_gettext or WITHOUT_GETTEXT:
if self.distribution.without_gettext:
return
for po in glob.glob (os.path.join (PO_DIR, '*.po')):
@ -55,29 +54,7 @@ class BuildData(build):
sys.exit(1)
class Install(install):
user_options = install.user_options
user_options.append(("without-gettext", None, "Don't install gettext .mo files"))
def initialize_options(self):
install.initialize_options(self)
self.without_gettext = False
def run(self):
global WITHOUT_GETTEXT
if self.without_gettext:
WITHOUT_GETTEXT = True
install.run(self)
class InstallData(install_data):
user_options = install_data.user_options
user_options.append(("without-gettext", None, "Don't build gettext .mo files"))
def initialize_options(self):
install_data.initialize_options(self)
self.without_gettext = False
def run (self):
self.data_files.extend (self._find_mo_files ())
install_data.run (self)
@ -86,7 +63,7 @@ class InstallData(install_data):
def _find_mo_files (self):
data_files = []
if not (self.without_gettext or WITHOUT_GETTEXT):
if not self.distribution.without_gettext:
for mo in glob.glob (os.path.join (MO_DIR, '*', 'terminator.mo')):
lang = os.path.basename(os.path.dirname(mo))
dest = os.path.join('share', 'locale', lang, 'LC_MESSAGES')
@ -121,6 +98,7 @@ setup(name='Terminator',
('share/icons/hicolor/16x16/actions', glob.glob('data/icons/16x16/actions/*.png')),
],
packages=['terminatorlib'],
cmdclass={'build': BuildData, 'install_data': InstallData, 'install': Install}
cmdclass={'build': BuildData, 'install_data': InstallData},
distclass=TerminatorDist
)