2012/12/27 John Ralls <jralls@ceridwen.us>

On Dec 26, 2012, at 4:29 PM, Nick Hall <nick__hall@hotmail.com> wrote:

> On 26/12/12 07:05, John Ralls wrote:
>> Right. The current code setting PREFIXDIR assumes that LOCALEDIR is `pwd`/../.., and is left over from the ancien regime where $GRAMPSHOME was $PREFIX/share/gramps.
>> ISTM sys.prefix is a lot more reliable, and will give the right answer almost always -- and users can use $GRAMPSI18N for the cases when it's wrong.
>> Does that make sense to you?
> As it happens sys.prefix is the default location for both the code and data directories with distutils.  If the user chooses a different location for the code and data directories, then sys.prefix will most likely point to the code directory rather than the data directory (where the locale files are installed).  Perhaps we can assume that any user doing so will understand the consequences and be able to set GRAMPSI18N.

Sys.prefix actually points to the root of all the directories. It's either what was passed in the --prefix argument to configure when Python was built or $PYTHONHOME if that's set in the environment.

> If distutils is used for installation then setting PREFIXDIR correctly will obviously be correct 100% of the time.

Well, yes, regardless of whether distutils is used. The trick -- and object of this discussion -- is how to set PREFIXDIR. Or rather, how to find the translation files, because that's all PREFIXDIR is used for.

> Problems are more likely to occur for packagers though.  If Gramps is stored in a temporary location for packaging, then PREFIXDIR may well be set incorrectly.  I think that this is what Benny was trying to fix by specifying the PREFIXDIR relative __file__.

I should let him speak for himself about his motivations, but the translation files (gramps.mo for each language) aren't likely to be anywhere near const.py. It does make sense for ROOT_DIR in those cases where it's used to find code or the glade files.

> It would be convenient not to generate const.py in the build, and we are close to this.  SYSCONFDIR is not used, and if we decide to handle PREFIXDIR differently, then we only set the version variables from within the setup script.

There's one more factor here if we're relying on Distutils: It doesn't actually have to install stuff into sys.prefix: The installer can specify an alternative prefix [1], and we need to know what that prefix is -- or we can explicitly say that it's going to be sys.prefix and if anyone wants it to be anywhere else they can just set $GRAMPSI18N.

ISTM if we're going to keep track of where distutils puts the translation files we need setup.py to record it in const.py. Otherwise we should just look in $GRAMPSI18N and sys.prefix/share/locale and be done with it. Frankly, I prefer the second course.

I have no experience in packaging and locale.
So, for me, whatever you, Nick and Jerome work out that works is good.


John Ralls

[1] http://docs.python.org/3/install/index.html#alternate-installation
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
Gramps-devel mailing list