From xfcelists at sstuhr.dk Sun Apr 30 21:33:58 2006 From: xfcelists at sstuhr.dk (Stefan Stuhr) Date: Sun, 30 Apr 2006 21:33:58 +0200 Subject: [Installit-dev] setup.py installation Message-ID: <1146425639.8024.53.camel@localhost.localdomain> Hi, I have just updated my Xfce SVN update script (based on the one by Kelnos) to support the Python distutils setup.py installation method, because I wanted to check out InstallIt. I don't like the idea of pure Python applications depending on make, autotools, etc. for installation, when distutils can be used - especially when InstallIt supports binary packages. I had to do some magic to make my script support uninstallation of InstallIt (distutils doesn't support it directly), but it wasn't too hard. My update script works, and InstallIt gets installed in prefix /opt/xfce4-svn/. But I get the following traceback when I try to run i2t outside the build directory: Traceback (most recent call last): File "/opt/xfce4-svn/bin/i2t", line 40, in ? main.run() File "/opt/xfce4-svn/lib/python2.4/site-packages/i2t/main.py", line 33, in run window = InstallItWindow() File "/opt/xfce4-svn/lib/python2.4/site-packages/i2t/ui/main.py", line 111, in __init__ self.set_icon_from_file(path.join("ui", "pixmaps", "i2t.png")) gobject.GError: Failed to open file 'ui/pixmaps/i2t.png': No such file or directory There are two problems here, as far as I can tell: 1. InstallIt's setup.py doesn't install every needed file. In fact, it omits the subdirectories of the ui and i18n directories. 2. InstallIt seems to lookup resources such as icons in subdirectories of the current working directory. When I do run i2t from the build directory, it works fine. The UI seems to be very nice. One thing I notice is that the "popup-menu" signal isn't used to pop up the popup menu in the main package list. Thanks, Stefan From info at sten-net.de Sun Apr 30 22:00:49 2006 From: info at sten-net.de (Jannis Pohlmann) Date: Sun, 30 Apr 2006 22:00:49 +0200 Subject: [Installit-dev] setup.py installation In-Reply-To: <1146425639.8024.53.camel@localhost.localdomain> References: <1146425639.8024.53.camel@localhost.localdomain> Message-ID: <20060430220049.06d41c74.info@sten-net.de> On Sun, 30 Apr 2006 21:33:58 +0200, Stefan Stuhr wrote: > Hi, > > I have just updated my Xfce SVN update script (based on the one by > Kelnos) to support the Python distutils setup.py installation method, > because I wanted to check out InstallIt. > > I don't like the idea of pure Python applications depending on make, > autotools, etc. for installation, when distutils can be used - > especially when InstallIt supports binary packages. It does not and probably won't. > I had to do some magic to make my script support uninstallation of > InstallIt (distutils doesn't support it directly), but it wasn't too > hard. > > My update script works, and InstallIt gets installed in > prefix /opt/xfce4-svn/. > > But I get the following traceback when I try to run i2t outside the > build directory: > Traceback (most recent call last): > File "/opt/xfce4-svn/bin/i2t", line 40, in ? > main.run() > File "/opt/xfce4-svn/lib/python2.4/site-packages/i2t/main.py", line > 33, in run window = InstallItWindow() > File "/opt/xfce4-svn/lib/python2.4/site-packages/i2t/ui/main.py", > line 111, in __init__ > self.set_icon_from_file(path.join("ui", "pixmaps", "i2t.png")) > gobject.GError: Failed to open file 'ui/pixmaps/i2t.png': No such file > or directory > > There are two problems here, as far as I can tell: > 1. InstallIt's setup.py doesn't install every needed file. In > fact, it omits the subdirectories of the ui and i18n directories. > 2. InstallIt seems to lookup resources such as icons in > subdirectories of the current working directory. Yep. I havent figured out yet how to determine the distutils data dir path used during the installation. If this is possible, I could create a script during setup which contains information about the installation and refer to it when looking up icons and UI descriptions. > When I do run i2t from the build directory, it works fine. The UI > seems to be very nice. One thing I notice is that the "popup-menu" > signal isn't used to pop up the popup menu in the main package list. Hmm, possible. I'll look into that. Regards, Jannis -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available URL: From xfcelists at sstuhr.dk Sun Apr 30 22:27:03 2006 From: xfcelists at sstuhr.dk (Stefan Stuhr) Date: Sun, 30 Apr 2006 22:27:03 +0200 Subject: [Installit-dev] setup.py installation In-Reply-To: <20060430220049.06d41c74.info@sten-net.de> References: <1146425639.8024.53.camel@localhost.localdomain> <20060430220049.06d41c74.info@sten-net.de> Message-ID: <1146428823.8024.71.camel@localhost.localdomain> s?n, 30 04 2006 kl. 22:00 +0200, skrev Jannis Pohlmann: > > There are two problems here, as far as I can tell: > > 1. InstallIt's setup.py doesn't install every needed file. In > > fact, it omits the subdirectories of the ui and i18n directories. > > 2. InstallIt seems to lookup resources such as icons in > > subdirectories of the current working directory. > > Yep. I havent figured out yet how to determine the distutils data dir > path used during the installation. If this is possible, I could create > a script during setup which contains information about the > installation > and refer to it when looking up icons and UI descriptions. The GNOME menueditor Alacarte is written in Python, and used to use distutils before version 0.9. Maybe you can look at their setup.py. 0.7.5 - simple, nice: http://dev.realistanew.com/smeg/0.7.5/smeg-0.7.5.tar.gz 0.8 - more complicated with locale stuff (is it really necessary for i18n?): http://dev.realistanew.com/alacarte/releases/0.8/alacarte-0.8.tar.gz 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. 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/. [1]: http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq08.004.htp > Regards, > Jannis Stefan From info at sten-net.de Sun Apr 30 22:36:48 2006 From: info at sten-net.de (Jannis Pohlmann) Date: Sun, 30 Apr 2006 22:36:48 +0200 Subject: [Installit-dev] setup.py installation In-Reply-To: <1146428823.8024.71.camel@localhost.localdomain> References: <1146425639.8024.53.camel@localhost.localdomain> <20060430220049.06d41c74.info@sten-net.de> <1146428823.8024.71.camel@localhost.localdomain> Message-ID: <20060430223648.7957f2a2.info@sten-net.de> On Sun, 30 Apr 2006 22:27:03 +0200, Stefan Stuhr wrote: > s?n, 30 04 2006 kl. 22:00 +0200, skrev Jannis Pohlmann: > > > There are two problems here, as far as I can tell: > > > 1. InstallIt's setup.py doesn't install every needed file. In > > > fact, it omits the subdirectories of the ui and i18n directories. > > > 2. InstallIt seems to lookup resources such as icons in > > > subdirectories of the current working directory. > > > > Yep. I havent figured out yet how to determine the distutils data > > dir path used during the installation. If this is possible, I could > > create a script during setup which contains information about the > > installation > > and refer to it when looking up icons and UI descriptions. > > The GNOME menueditor Alacarte is written in Python, and used to use > distutils before version 0.9. Maybe you can look at their setup.py. > > 0.7.5 - simple, nice: > http://dev.realistanew.com/smeg/0.7.5/smeg-0.7.5.tar.gz > > 0.8 - more complicated with locale stuff (is it really necessary for > i18n?): > http://dev.realistanew.com/alacarte/releases/0.8/alacarte-0.8.tar.gz Thanks for the hints, I'll take a look at those programs. > 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. Regards, Jannis -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available URL: From xfcelists at sstuhr.dk Sun Apr 30 22:55:36 2006 From: xfcelists at sstuhr.dk (Stefan Stuhr) Date: Sun, 30 Apr 2006 22:55:36 +0200 Subject: [Installit-dev] setup.py installation In-Reply-To: <20060430223648.7957f2a2.info@sten-net.de> References: <1146425639.8024.53.camel@localhost.localdomain> <20060430220049.06d41c74.info@sten-net.de> <1146428823.8024.71.camel@localhost.localdomain> <20060430223648.7957f2a2.info@sten-net.de> Message-ID: <1146430537.8024.87.camel@localhost.localdomain> 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