win32 changes

svn: r21331
This commit is contained in:
Josip Pisoj 2013-02-10 17:53:43 +00:00
parent 705355104a
commit 96e042919c

View File

@ -62,6 +62,20 @@ def intltool_version():
''' '''
Return the version of intltool as a tuple. Return the version of intltool as a tuple.
''' '''
if sys.platform == 'win32':
cmd = ["perl", "-e print qx(intltool-update --version) =~ m/(\d+.\d+.\d+)/;"]
try:
ver, ret = subprocess.Popen(cmd ,stdout=subprocess.PIPE,
stderr=subprocess.PIPE).communicate()
if sys.version_info[0] > 2:
ver = ver.decode("utf-8")
if ver > "":
version_str = ver
else:
return (0,0,0)
except:
return (0,0,0)
else:
cmd = 'intltool-update --version | head -1 | cut -d" " -f3' cmd = 'intltool-update --version | head -1 | cut -d" " -f3'
if sys.version_info[0] < 3: if sys.version_info[0] < 3:
retcode, version_str = commands.getstatusoutput(cmd) retcode, version_str = commands.getstatusoutput(cmd)
@ -69,7 +83,6 @@ def intltool_version():
retcode, version_str = subprocess.getstatusoutput(cmd) retcode, version_str = subprocess.getstatusoutput(cmd)
if retcode != 0: if retcode != 0:
return None return None
else:
return tuple([int(num) for num in version_str.split('.')]) return tuple([int(num) for num in version_str.split('.')])
def substitute_variables(filename_in, filename_out, subst_vars): def substitute_variables(filename_in, filename_out, subst_vars):
@ -198,6 +211,14 @@ def merge(in_file, out_file, option, po_dir='po', cache=True):
option += ' -c ' + cache_file option += ' -c ' + cache_file
if (not os.path.exists(out_file) and os.path.exists(in_file)): if (not os.path.exists(out_file) and os.path.exists(in_file)):
if sys.platform == 'win32':
cmd = (('set LC_ALL=C && intltool-merge %(opt)s %(po_dir)s %(in_file)s '
'%(out_file)s') %
{'opt' : option,
'po_dir' : po_dir,
'in_file' : in_file,
'out_file' : out_file})
else:
cmd = (('LC_ALL=C intltool-merge %(opt)s %(po_dir)s %(in_file)s ' cmd = (('LC_ALL=C intltool-merge %(opt)s %(po_dir)s %(in_file)s '
'%(out_file)s') % '%(out_file)s') %
{'opt' : option, {'opt' : option,
@ -259,6 +280,7 @@ class build(_build):
"""Custom build command.""" """Custom build command."""
def run(self): def run(self):
build_trans(self) build_trans(self)
if not sys.platform == 'win32':
build_man(self) build_man(self)
build_intl(self) build_intl(self)
write_const_py(self) write_const_py(self)