Fix structure of build directory for locale files (merged from trunk; changes by Nick.H), road to alpha2

svn: r20899
This commit is contained in:
Jérôme Rapinat 2012-12-31 09:44:49 +00:00
parent 8b26f688cb
commit b9cd27550f
3 changed files with 21 additions and 37 deletions

View File

@ -89,19 +89,7 @@ APP_VCARD = ["text/x-vcard", "text/x-vcalendar"]
# system paths # system paths
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
if sys.platform == "win32": LOCALE_DIR = "@LOCALE_DIR@"
if sys.prefix == os.path.dirname(os.getcwd()):
PREFIXDIR = sys.prefix
SYSCONFDIR = os.path.join(sys.prefix, "etc")
else:
PREFIXDIR = os.path.join(os.path.dirname(__file__), os.pardir)
SYSCONFDIR = os.path.join(PREFIXDIR, "etc")
elif sys.platform == "darwin" and sys.prefix != sys.exec_prefix:
PREFIXDIR = sys.prefix
SYSCONFDIR = os.path.join(sys.prefix, "etc")
else:
PREFIXDIR = "@prefix@"
SYSCONFDIR = "@sysconfdir@"
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #

View File

@ -41,7 +41,7 @@ import logging
# gramps modules # gramps modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from ..const import PREFIXDIR, ROOT_DIR from ..const import LOCALE_DIR
from ..constfunc import mac, UNITYPE from ..constfunc import mac, UNITYPE
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -49,22 +49,16 @@ from ..constfunc import mac, UNITYPE
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
if "GRAMPSI18N" in os.environ: if "GRAMPSI18N" in os.environ:
if os.path.exists(os.environ["GRAMPSI18N"]): LOCALEDIR = os.environ["GRAMPSI18N"]
LOCALEDIR = os.environ["GRAMPSI18N"] else:
else: LOCALEDIR = LOCALE_DIR
LOCALEDIR = None
elif os.path.exists( os.path.join(ROOT_DIR, "lang") ): if not os.path.exists(LOCALEDIR):
LOCALEDIR = os.path.join(ROOT_DIR, "lang")
elif os.path.exists(os.path.join(PREFIXDIR, "share/locale")):
LOCALEDIR = os.path.join(PREFIXDIR, "share/locale")
else:
lang = os.environ.get('LANG', 'en') lang = os.environ.get('LANG', 'en')
if lang and lang[:2] == 'en': if lang and lang[:2] == 'en':
pass # No need to display warning, we're in English pass # No need to display warning, we're in English
else: else:
logging.warning('Locale dir does not exist at ' + logging.warning('Locale dir does not exist at ' + LOCALEDIR)
os.path.join(PREFIXDIR, "share/locale"))
logging.warning('Running python setup.py install --prefix=YourPrefixDir might fix the problem')
LOCALEDIR = None LOCALEDIR = None
LOCALEDOMAIN = 'gramps' LOCALEDOMAIN = 'gramps'

View File

@ -47,7 +47,7 @@ if sys.version_info[0] < 3:
import commands import commands
from stat import ST_MODE from stat import ST_MODE
VERSION = '4.0.0-alpha1' VERSION = '4.0.0-alpha2'
ALL_LINGUAS = ('bg', 'ca', 'cs', 'da', 'de', 'el', 'en_GB', 'es', 'fi', 'fr', 'he', ALL_LINGUAS = ('bg', 'ca', 'cs', 'da', 'de', 'el', 'en_GB', 'es', 'fi', 'fr', 'he',
'hr', 'hu', 'it', 'ja', 'lt', 'nb', 'nl', 'nn', 'pl', 'pt_BR', 'hr', 'hu', 'it', 'ja', 'lt', 'nb', 'nl', 'nn', 'pl', 'pt_BR',
'pt_PT', 'ru', 'sk', 'sl', 'sq', 'sv', 'uk', 'vi', 'zh_CN') 'pt_PT', 'ru', 'sk', 'sl', 'sq', 'sv', 'uk', 'vi', 'zh_CN')
@ -87,8 +87,10 @@ def build_trans(build_cmd):
data_files = build_cmd.distribution.data_files data_files = build_cmd.distribution.data_files
for lang in ALL_LINGUAS: for lang in ALL_LINGUAS:
po_file = os.path.join('po', lang + '.po') po_file = os.path.join('po', lang + '.po')
mo_file = os.path.join(build_cmd.build_base, 'mo', lang, 'gramps.mo') mo_file = os.path.join(build_cmd.build_base, 'mo', lang, 'LC_MESSAGES',
mo_file_unix = build_cmd.build_base + '/mo/' + lang + '/gramps.mo' 'gramps.mo')
mo_file_unix = (build_cmd.build_base + '/mo/' + lang +
'/LC_MESSAGES/gramps.mo')
mo_dir = os.path.dirname(mo_file) mo_dir = os.path.dirname(mo_file)
if not(os.path.isdir(mo_dir) or os.path.islink(mo_dir)): if not(os.path.isdir(mo_dir) or os.path.islink(mo_dir)):
os.makedirs(mo_dir) os.makedirs(mo_dir)
@ -231,24 +233,24 @@ def write_gramps_script(install_cmd, build_scripts):
log.info('changing mode of %s to %o', filename, mode) log.info('changing mode of %s to %o', filename, mode)
os.chmod(filename, mode) os.chmod(filename, mode)
def write_const_py(install_cmd): def write_const_py(command):
''' '''
Write the const.py file. Write the const.py file.
''' '''
const_py_in = os.path.join('gramps', 'gen', 'const.py.in') const_py_in = os.path.join('gramps', 'gen', 'const.py.in')
const_py = os.path.join('gramps', 'gen', 'const.py') const_py = os.path.join('gramps', 'gen', 'const.py')
if hasattr(install_cmd, 'install_data'): if hasattr(command, 'install_data'):
#during install #during install
prefix = "'%s'" % install_cmd.install_data locale_dir = os.path.join(command.install_data, 'share', 'locale')
sysconfdir = "'%s'" % os.path.join(install_cmd.install_data, 'etc') # Is this correct?
else: else:
#in build #in build
prefix = 'os.path.join(os.path.dirname(__file__), os.pardir)' if os.access(const_py, os.F_OK):
sysconfdir = prefix + ' + "' + os.sep + 'etc"' # Is this correct? # Prevent overwriting version created during install
return
locale_dir = os.path.join(command.build_base, 'mo')
subst_vars = (('@VERSIONSTRING@', VERSION), subst_vars = (('@VERSIONSTRING@', VERSION),
('"@prefix@"', prefix), ('@LOCALE_DIR@', locale_dir))
('"@sysconfdir@"', sysconfdir))
substitute_variables(const_py_in, const_py, subst_vars) substitute_variables(const_py_in, const_py, subst_vars)