[Installit-dev] setup.py installation

Stefan Stuhr xfcelists at sstuhr.dk
Sun Apr 30 22:55:36 CEST 2006


søn, 30 04 2006 kl. 22:36 +0200, skrev Jannis Pohlmann:
> On Sun, 30 Apr 2006 22:27:03 +0200, Stefan Stuhr wrote: 
> > Regarding icons, what about using GtkIconTheme? I have experience
> > with a lot of memory leaks with PyGTK and pixbufs[1], however, so
> > don't overdo it.
> 
> You still need to define the icon (and its path) you want to register
> to the icon theme in order to be able to look it up later.
> 
> > And regarding other resources, you could put them in share/installit/,
> > e.g. share/installit/xml/. It shouldn't be too hard to find them
> > again, it seems that the binary always is in bin/.
> 
> Well, of course they would be put into share/i2t/, but the problem is
> *which* share/ we have put it. We can't search the whole filesystem for
> a share/i2t. So we have to remember the data dir during the setup in
> order to access it directly later.

Here's the smart thing. If $prefix is /usr/local, then the main
"binary", i2t, will be in /usr/local/bin/. In that case, share/i2t/ will
be in /usr/local/share/i2t/.
On the other hand, if $prefix is /opt/xfce, then the i2t "binary" will
be in /opt/xfce/bin. And share/i2t/ will be in /opt/xfce/share/i2t/.

So, all you have to do is to have som mechanism in i2t to resolve
symbolic links in a safe way. Something like this:
---------- 8< ----------
# Return the real path if possible
def GetRealPath(filepath):
	history = []
	filepath = os.path.normcase(os.path.abspath(filepath))
	while os.path.islink(filepath):
		history.append(filepath)
		old_filepath = filepath
		filepath = os.readlink(filepath)
		filepath = \
os.path.normcase(os.path.normpath(os.path.join(os.path.dirname(old_filepath), filepath)))
		if filepath in history:
			return history[0]
	return filepath
---------- >8 ----------
It may not be necessary with the "history"-part, but you can use it just
in case.

Then you can use
GetRealPath(sys.argv[0])
to get the real path to the i2t file, that you know is in $prefix/bin.
It shouldn't be too hard to find $prefix/share/i2t/ from there.

> Regards,
> Jannis

Stefan




More information about the Installit-dev mailing list