How did PortableApps implement relative paths?

One of the things that impressed me about the PortableApps implementation is how they made Gramps so much more agnostic about locations of the User Directory & Media objects.

Whenever a USB device is plugged into a new system, it is assigned an arbitrary drive letter. But PortableGramps detects its own location upon launch and revises the relative offsets. Then triggers Gramps. And Gramps registers the correct .ini files, plugins, relative media path, database path, and so forth.

And if the installation is dragged to a hard drive, it detects that and adapts transparently.

Oh, the PortableApps implementation isn’t utterly agnostic on Windows… it is only 32bit. (See their 64bit policy.)

Is this something that could (or should) be adapted to the core of Gramps?

It would be lovely if some future version of Gramps could be told the User Directory is at a different location (say an external drive that had been pulled from a system where the OS had been crashed) and Gramps would adapt to register the add-ons, finding the .ini files & trees with their Media objects. Thus allowing at-risk research to be easily recovered via a full backup.

Obviously, there would be some tricky issues to resolve. Like: what what happens with dependencies like GraphViz; how to resolve Media objects with absolute paths on secondary partitions.

The absolute paths might have already been addressed elsewhere. (I don’t use Media objects because I’d rather invest that indexing effort in a Document Management System.) If a Linux user restores a full backup from a Windows user, does the restore also resolve the absolute paths for Media objects those weren’t on the Windows OS partition?

I was able to modify the bundled Mac version and launch it from a USB stick.

After installing the bundled version from the .dmg file, I made a copy of Gramps.app and gave it a different name. Then, within the new copy, I edited Contents/Resources/gramps_launcher.py and changed the APPDATA environment variable to point within the bundle instead of the usual location:

# environ[‘APPDATA’] = join(environ[‘HOME’], ‘Library’, ‘Application Support’)
environ[‘APPDATA’] = join (bundle_lib, PYVER, ‘site-packages’, ‘gramps’)

(That’s the same location that was already being used for GRAMPDIR.)

Then I copied the new version onto a USB stick and launched it from there. It was much slower, of course.

Maybe another possibility is to launch Gramps from the command line and override the APPDATA setting (although that variable is not listed here), and then create a desktop icon to launch it that way, but I don’t know if that can be done.

1 Like

Continuation of the subject How did PortableApps implement relative paths? :

Contrary to what @emyoulation said, relative media path does not always work.

It seems using a linux style path for Media relative path in Gramps preferences, at least for Gramps PortableApp, is the way to store media path and make it compatible to drive letter change from PC to PC. e.g:

That Windows media style path : i:\gramps\grampsportable\data\Archive Documents
don’t work anymore if drive letter on another PC change from I: to D: or anything else than I:

But this linux style one: /gramps/grampsportable/data/Archive Documents
works fine with the PortableApp on any PC with any drive letter the USB stick is assigned to.


I’ve just seen @ennoborg answer to another post very similar to mine

One of the notes added to the Gramps Downloads page was about backwards compatibility with Windows XP. The maintainer of the Gramps Portable package on PortableApps was staying with XP. That mean his need was for the 32-bit version. When 5.0 release made building an XP compatible Gramps too onerous, another maintainer took up the PortableGramps project.

(Please note: Gramps prefers the Python-3.5 and Gtk-3.18 libraries and newer. Those libraries have dropped support for Windows XP. But Gramps can still be run on Windows XP with earlier library versions, i.e., Python3.4.4 and Gtk-3.16)

At what point will it not be possible to use Gramps will XP compatible libraries or in 32-bit modes?

I just added that 4.2.6 was the last PowerPC installer.