[wxPython-users] Cross-platform distribution

Robin Dunn robin at alldunn.com
Mon Oct 1 13:00:15 PDT 2007


Dusty Phillips wrote:
> Hi,
> 
> I'm trying to figure out a better way to ship extra so called
> "resource" files with my wxPython-based application such that they can
> be accessed in a cross-platform manner. I'm aware this is a common
> problem, but google hasn't suggested a standard solution.
> 
> I currently use distutils rather clumsily and place these files in the
> data_files array:
>   data_files=[
>     ('share/pallavi', [
>         'config/pallavi_config.py',
>         'config/pallavi128.xpm'
>         ]),
>     ('share/pallavi/lexing_languages', map(lambda x:
> "config/lexing_languages/%s" % x ,filter(lambda x: x.endswith(".py"),
> os.listdir('config/lexing_languages')))),
>   ],
> 
> This installs the relevant files to /usr/share/pallavi or
> /usr/local/share/pallavi under Linux systems (assuming the installer
> doesn't pass strange prefixes to setup.py), and to
> C:\Python2x\share\pallavi\ under Windows (with the same assumption). I
> don't know what happens on a Mac and I'm not in a position to worry
> about it until a Mac user becomes interested in my software or I buy
> one (its on my wish list!)
> 
> I don't know how to reliably access these paths under wxPython.
> wx.StandardPaths returns /usr/share/pallavi under Linux, which is
> exactly what I need. However, under Windows, it currently returns
> C:\Python25\lib\site-packages\wx-2.8-msw-unicode\wx and the
> documentation tells me it should actually be returning C:\Program
> Files\Pallavi\.

It's actually based on the location of the main wx resource instance, 
which on Windows is linked to the wx DLL.  The assumption is that either 
wx will be staticly linked to a C++ app, or the C++ app will have it's 
own resource instance that includes wx's.  Neither of those is true for 
wxPython so it falls back to the DLL.


> 
> So I need to know how to either:
> a) get wxPython to return C:\Python2x\share\pallavi or whichever
> similar path is related to the Python installation OR

On Windows you can use something like os.path.join(sys.prefix, 
'share/pallavi), although I'm not sure what that will do with a py2exe's 
app...  On the other hand, a py2exe'd app would probably do the right 
thing with wx.StandardPaths because the location of the wx DLL file 
would be in the Program Files subdir then (or wherever the app was 
installed.)

-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wxpython-users mailing list