----------  Forwarded Message  ----------

Subject: Re: [PyInstaller] prgramatically retrieve the runtime path
Date: Wednesday, August 08, 2012, 11:54:45 AM
From: Karsten Hilbert <[email protected]>
To: Sebastian Hilbert <[email protected]>
CC: [email protected]

Please include me as CC since I'm not on the list.

On Tue, Aug 07, 2012 at 05:54:07PM +0200, Hilbert, Sebastian wrote:

> > Am 07.08.2012 06:31, schrieb Sebastian Hilbert:
> > > Inside gnumed.exe there are some additional files such as gmManual.py
> > > (think those are included via the hook ?)
> > > 
> > >  How can I get a list of files included into the gnumed.exe ?
> > 
> > gmManual.py is a module and it is already included into the packages
> > .exe (more exactly into out1.PYZ) by the hook you created. You can
> > access this list from within the .spec-file via a.pure (I think).
> > 
> > But again: what is your aim? There may be quite a different solution for
> > your problem.
> 
> To be precise gmManual is one of many plugins which is loaded by the GNUmed 
> application. This works just fine when running gnumed.exe.
> 
> There is one specific feature in GNUmed which lets the user define which 
plugins 
> to load. For this to work the GNUmed application scans a specific directory 
> named wxpython inside the GNUMed directory. When GNUmed is frozen there is 
no 
> such directory in the fileystem by default.
> 
> I was under the impression that the gnumed.exe gets extracted somwhere in 
the 
> filesystem when gnumed.exe is run so one can access the content packaged 
> within.
> 
> So the question basically is how do I tell what content (files/modules is 
> inside the gnumed.exe) the way I would by listing the content in a directory 
> when not being frozen.

I will try to explain.

GNUmed allows the user to choose which of the GUI plugins to
load. Those plugins come with the application (are not user
provided). They typically reside in places like

        /home/user/git/gnumed/Gnumed/client/wxpython/gui/

        (if running from a copy of the git tree)

or

        /usr/share/gnumed/Gnumed/client/wxpython/gui/

        (if running as an installed Debian package)

Since we want to forego keeping a list of "known plugins"
inside the code we look in a few known places for directores
matching

        */wxpython/gui/

namely all of sys.path and the "application base dir" which
is currently detected by this code:

        # where the main script (the "binary") is installed
        # (this would be "gnumed.py")
        if getattr(sys, 'frozen', False):
                _log.info('frozen app, installed into temporary path')
                # this would find the path of *THIS* file
                #self.local_base_dir = os.path.dirname(__file__)
                # while this is documented on the web, ${_MEIPASS2} does not 
exist
                #self.local_base_dir = os.environ.get('_MEIPASS2')
                # this is what Martin Zibricky <[email protected]> told us 
to use
                # when asking about this on [email protected]
                self.local_base_dir = sys._MEIPASS
        else:
                self.local_base_dir = 
os.path.abspath(os.path.dirname(sys.argv[0]))

Note how we already attempt to account for being frozen
including various attempts that failed. Our packager now
told me that our frozen app is of the -onedir variety. The
pyinstaller manual says we should be looking at
sys.executable for that which is what I'll be trying next

Here are a few relevant snippets from our log file:

        gm.launcher (<string>::log_startup_info() #274): process environment:
        gm.launcher (<string>::log_startup_info() #276):                        
  
${TMP}: C:\DOKUME~1\basti\LOKALE~1\Temp
        gm.launcher (<string>::log_startup_info() #276):                 
${COMPUTERNAME}: DEVEL
        gm.launcher (<string>::log_startup_info() #276):                   
${USERDOMAIN}: DEVEL
        gm.launcher (<string>::log_startup_info() #276):           
${COMMONPROGRAMFILES}: C:\Programme\Gemeinsame Dateien
        gm.launcher (<string>::log_startup_info() #276):         
${PROCESSOR_IDENTIFIER}: x86 Family 6 Model 37 Stepping 5, GenuineIntel
        gm.launcher (<string>::log_startup_info() #276):                 
${PROGRAMFILES}: C:\Programme
        gm.launcher (<string>::log_startup_info() #276):           
${PROCESSOR_REVISION}: 2505
        gm.launcher (<string>::log_startup_info() #276):                        
 
${PATH}: C:\Programme\MiKTeX 2.8\miktex\bin;C:\WINDOWS\system32;C:\WINDOWS;C:
\WINDOWS\System32\Wbem;c:\MinGW\bin;C:\Program Files\MetaEmotion\GinkgoCADx
        gm.launcher (<string>::log_startup_info() #276):                   
${SYSTEMROOT}: C:\WINDOWS
        gm.launcher (<string>::log_startup_info() #276):                        
 
${TEMP}: C:\DOKUME~1\basti\LOKALE~1\Temp
        gm.launcher (<string>::log_startup_info() #276):       
${PROCESSOR_ARCHITECTURE}: x86
        gm.launcher (<string>::log_startup_info() #276):              
${ALLUSERSPROFILE}: C:\Dokumente und Einstellungen\All Users
        gm.launcher (<string>::log_startup_info() #276):                  
${SESSIONNAME}: Console
        gm.launcher (<string>::log_startup_info() #276):                     
${HOMEPATH}: \Dokumente und Einstellungen\basti
        gm.launcher (<string>::log_startup_info() #276):                     
${USERNAME}: basti
        gm.launcher (<string>::log_startup_info() #276):                  
${LOGONSERVER}: \\DEVEL
        gm.launcher (<string>::log_startup_info() #276):                      
${COMSPEC}: C:\WINDOWS\system32\cmd.exe
        gm.launcher (<string>::log_startup_info() #276):                      
${PATHEXT}: .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
        gm.launcher (<string>::log_startup_info() #276):                   
${CLIENTNAME}: Console
        gm.launcher (<string>::log_startup_info() #276):             
${FP_NO_HOST_CHECK}: NO
        gm.launcher (<string>::log_startup_info() #276):                       
${WINDIR}: C:\WINDOWS
        gm.launcher (<string>::log_startup_info() #276):                      
${APPDATA}: C:\Dokumente und Einstellungen\basti\Anwendungsdaten
        gm.launcher (<string>::log_startup_info() #276):                    
${HOMEDRIVE}: C:
        gm.launcher (<string>::log_startup_info() #276):                  
${SYSTEMDRIVE}: C:
        gm.launcher (<string>::log_startup_info() #276):         
${NUMBER_OF_PROCESSORS}: 1
        gm.launcher (<string>::log_startup_info() #276):              
${PROCESSOR_LEVEL}: 6
        gm.launcher (<string>::log_startup_info() #276):                        
   
${OS}: Windows_NT
        gm.launcher (<string>::log_startup_info() #276):                  
${USERPROFILE}: C:\Dokumente und Einstellungen\basti
        ...
        gm.cfg (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmcfg2::add_cli()
 
#431): raw command line is:
        gm.cfg (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmcfg2::add_cli()
 
#432): ['C:\\Programme\\GNUmed-client\\bin\\gnumed.exe', '--lang-gettext=de']
        ...
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::init_paths()
 
#140): detecting paths directly
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::init_paths()
 
#146): app name passed in as [gnumed]
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::init_paths()
 
#153): frozen app, installed into temporary path
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::_set_system_config_dir()
 
#265): [gmPaths:system_config_dir]: invalid path [/etc\gnumed]
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::_set_system_app_data_dir()
 
#277): [gmPaths:system_app_data_dir]: invalid path [C:\Python26\share\gnumed]
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::init_paths()
 
#187): temp dir already set
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::__log_paths()
 
#235): sys.argv[0]: C:\Programme\GNUmed-client\bin\gnumed.exe
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::__log_paths()
 
#236):         __file__ : C:\Programme\GNUmed-client\bin\gnumed.exe?
183808\Gnumed\pycommon\gmTools.pyc
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::__log_paths()
 
#237): dirname(__file__): C:\Programme\GNUmed-client\bin\gnumed.exe?
183808\Gnumed\pycommon
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::__log_paths()
 
#238): os.environ["_MEIPASS2"]: <not found>
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::__log_paths()
 
#239): sys._MEIPASS: C:\Programme\GNUmed-client\bin
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::__log_paths()
 
#240): local application base dir: C:\Programme\GNUmed-client\bin
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::__log_paths()
 
#241): current working dir: C:\Programme\GNUmed-client
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::__log_paths()
 
#242): user home dir: C:\Dokumente und Einstellungen\basti
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::__log_paths()
 
#243): user-specific config dir: C:\Dokumente und Einstellungen\basti\.gnumed
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::__log_paths()
 
#244): system-wide config dir: C:\Dokumente und Einstellungen\basti\.gnumed
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::__log_paths()
 
#245): system-wide application data dir: C:\Programme\GNUmed-client\bin
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::__log_paths()
 
#246): temporary dir: c:\dokume~1\basti\lokale~1\temp\gnumed\gm-emvbd8
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::init_paths()
 
#201): re-detecting paths with wxPython
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::init_paths()
 
#204): wxPython app name is [gnumed]
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::_set_system_config_dir()
 
#265): [gmPaths:system_config_dir]: invalid path [C:\Dokumente und 
Einstellungen\All Users\Anwendungsdaten\gnumed]
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::init_paths()
 
#224): this platform (wxMSW) sometimes returns a broken value for the system-
wide application data dir
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::__log_paths()
 
#235): sys.argv[0]: C:\Programme\GNUmed-client\bin\gnumed.exe
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::__log_paths()
 
#236):         __file__ : C:\Programme\GNUmed-client\bin\gnumed.exe?
183808\Gnumed\pycommon\gmTools.pyc
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::__log_paths()
 
#237): dirname(__file__): C:\Programme\GNUmed-client\bin\gnumed.exe?
183808\Gnumed\pycommon
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::__log_paths()
 
#238): os.environ["_MEIPASS2"]: <not found>
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::__log_paths()
 
#239): sys._MEIPASS: C:\Programme\GNUmed-client\bin
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::__log_paths()
 
#240): local application base dir: C:\Programme\GNUmed-client\bin
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::__log_paths()
 
#241): current working dir: C:\Programme\GNUmed-client
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::__log_paths()
 
#242): user home dir: C:\Dokumente und Einstellungen\basti
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::__log_paths()
 
#243): user-specific config dir: C:\Dokumente und 
Einstellungen\basti\Anwendungsdaten\.gnumed
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::__log_paths()
 
#244): system-wide config dir: C:\Dokumente und Einstellungen\basti\.gnumed
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::__log_paths()
 
#245): system-wide application data dir: C:\Programme\GNUmed-client\bin
        gm.tools (c:\workplace\gnumed-
client.1.2.2\build\pyi.win32\gnumed\outpyz1.pyz\gnumed.pycommon.gmtools::__log_paths()
 
#246): temporary dir: c:\dokume~1\basti\lokale~1\temp\gnumed\gm-emvbd8

So, apart from trying dirname(sys.executable) this still
begs the question: When running from a -onedir frozen app
where should we expect to find the plugins from
wxpython/gui/ at runtime ?

Karsten
-- 
GPG key ID E4071346 @ gpg-keyserver.de
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346
-----------------------------------------

-- 
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pyinstaller?hl=en.

Reply via email to