[Pythonmac-SIG] Python dieing outside project builder
Alexandre Parenteau
aparente@adobe.com
Thu, 13 Jun 2002 12:58:20 -0700
Mattew,
I don't think the current folder should have any importance with the
frameworks since the paths are hard coded at ./configure time. I'm
developing from CodeWarrior BTW.
Here is what I do:
#elif TARGET_RT_MAC_CFM
console_output_state = 1;
PyMac_SetConsoleHandler(PyMac_DummyReadHandler, PyMac_DummyWriteHandler,
PyMac_DummyWriteHandler);
PyMacSchedParams scp;
PyMac_GetSchedParams(&scp);
scp.process_events = 0;
PyMac_SetSchedParams(&scp);
Py_SetProgramName("maccvs");
#elif TARGET_RT_MAC_MACHO
Py_SetProgramName("maccvsX");
Py_Initialize();
#else
I have also some code which makes sure that prior to that the current
resource fork is the application one which has the 'Popt' resource inside,
but I suspect it is used only with PythonCFM's Py_MacInitialize.
Some more code:
PyEval_InitThreads();
m_mainInterpreter = PyThreadState_Swap(NULL);
PyThreadState *OLD = PyThreadState_Swap(m_mainInterpreter);
PyObject *m = Py_InitModule4("_cvsgui", &gAllMethods[0],
"The cvsgui glue functions", (PyObject*)NULL,PYTHON_API_VERSION);
....
PyThreadState_Swap(OLD );
resource 'Popt' (PYTHONOPTIONSOVERRIDE_ID, "Options") {
POPT_VERSION_CURRENT,
noInspect,
noVerbose,
noOptimize,
noUnbuffered,
noDebugParser,
unused_0,
noCloseOutput,
interactiveOptions,
argcArgv,
newStandardExceptions,
sitePython,
navService,
delayConsole,
noDivisionWarning,
unixNewlines,
};
Hope it helps,
Alex.
>
> On donderdag, juni 13, 2002, at 03:36 , Matthew Smith wrote:
>
>> Hello,
>>
>> I'm linking to the python framework in an app I'm working on,
>> the app needs
>> to run a python script at start-up.
>>
>> If I run the app from inside project builder everything works
>> and the return
>> value for executing the script is fine.
>>
>> If the program is launched outside project builder (eg
>> double-clicking on it
>> in the finder), the script doesn't run and the return value
>> gives an error.
>>
>> The script I am running is with the .app file in the build directory...
>>
>> Any ideas?
>
> Just a wild guess: when you double-click you could have a
> different working directory than when you run from Project
> Builder. You could put some debug output in your embedding
> application (for instance print the working directory, or set
> the Py_VerboseFlag to 1 before calling Python), and the output
> will appear in the console window
> (Applications->Utilities->Console).
>
> I'm also not 100% sure which Python initialize routine you need
> to call if your Python scripts want access to Carbon methods. I
> think Py_Initialize() may be good enough, but it could be that
> you have to use PyMac_Initialize() (as in MacPython). Or maybe
> you even need something completely different (i.e.
> Py_Initialize() plus some of the stuff in PyMac_Initialize().
>
> Maybe someone else has already experimented with embedding
> MachoPython and has information to share?
> --
> - Jack Jansen <Jack.Jansen@oratrix.com>
> http://www.cwi.nl/~jack -
> - If I can't dance I don't want to be part of your revolution --
> Emma Goldman -
>
>
>
> _______________________________________________
> Pythonmac-SIG maillist - Pythonmac-SIG@python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
>
--
Alexandre Parenteau
Computer Scientist
Core Technologies, AGM
Adobe Systems, Inc.
408-536-6166