win32 changes

svn: r21331
This commit is contained in:
Josip Pisoj 2013-02-10 17:53:43 +00:00
parent 9c7a058ef4
commit da9106834a

View File

@ -62,15 +62,28 @@ def intltool_version():
'''
Return the version of intltool as a tuple.
'''
cmd = 'intltool-update --version | head -1 | cut -d" " -f3'
if sys.version_info[0] < 3:
retcode, version_str = commands.getstatusoutput(cmd)
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:
retcode, version_str = subprocess.getstatusoutput(cmd)
if retcode != 0:
return None
else:
return tuple([int(num) for num in version_str.split('.')])
cmd = 'intltool-update --version | head -1 | cut -d" " -f3'
if sys.version_info[0] < 3:
retcode, version_str = commands.getstatusoutput(cmd)
else:
retcode, version_str = subprocess.getstatusoutput(cmd)
if retcode != 0:
return None
return tuple([int(num) for num in version_str.split('.')])
def substitute_variables(filename_in, filename_out, subst_vars):
'''
@ -198,7 +211,15 @@ def merge(in_file, out_file, option, po_dir='po', cache=True):
option += ' -c ' + cache_file
if (not os.path.exists(out_file) and os.path.exists(in_file)):
cmd = (('LC_ALL=C intltool-merge %(opt)s %(po_dir)s %(in_file)s '
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 '
'%(out_file)s') %
{'opt' : option,
'po_dir' : po_dir,
@ -259,7 +280,8 @@ class build(_build):
"""Custom build command."""
def run(self):
build_trans(self)
build_man(self)
if not sys.platform == 'win32':
build_man(self)
build_intl(self)
write_const_py(self)
_build.run(self)