[Pythonmac-SIG] how do you determine if you're running a
bundlebuilder standalone?
Bob Ippolito
bob at redivi.com
Sat Aug 21 21:31:35 CEST 2004
On Aug 21, 2004, at 3:20 PM, Kevin Altis wrote:
> On Aug 21, 2004, at 12:13 PM, Bob Ippolito wrote:
>
>>
>> On Aug 20, 2004, at 2:09 PM, Kevin Altis wrote:
>>
>>> I have the following function for determining at runtime whether a
>>> program is running standalone, but it needs to be updated for Mac OS
>>> X and bundlebuilder.
>>>
>>> # Thomas Heller's function for determining
>>> # if a module is running standalone
>>> def main_is_frozen():
>>> return (hasattr(sys, "importers") # py2exe
>>> or imp.is_frozen("__main__") # cx_freeze or tools/freeze
>>> or hasattr(sys, "frozen") # McMillan installer
>>> )
>>>
>>> What's the magic attribute for bundlebuilder standalones?
>>
>> Why do you need to know if something is "frozen" with bundlebuilder
>> anyway? Knowing whether it's standalone or not doesn't do much for
>> you.. I'm sure there's a method that will determine what you want to
>> actually know whether or not it is standalone.
>>
>
> The main reason I use it is that with PythonCard there are a number of
> default configuration files that are stored in the package directory,
> that wouldn't normally be available when running a standalone. When
> PythonCard is run for the first time on a users system, these files
> are copied to ~/pythoncard_config and then the user-specific versions
> are used. When someone builds a standalone, they can copy these files
> into their local directory if they want to keep the same functionality
> as someone that would have the full package installed or they can just
> rely on the default configs that are part of the Python code. So, in
> the configuration.py module of PythonCard is specifically checks for
> whether the code is running standalone or not and then sets the config
> path accordingly, so the user code doesn't really have to worry about
> these kind of details.
Ok so why not check for
os.path.join(os.path.dirname(getattr(sys.modules['__main__'],
'__file__', '')), 'pythoncard_config'), then
os.path.join(os.path.expanduser('~'), 'pythoncard_config'), then the
package path, whatever that may be?
-bob
More information about the Pythonmac-SIG
mailing list