Hi everyone,
I've been having problem trying to use Gambit-C scheme in Python.
Everything works fine if I compile Gambit-C alone and run it. But if
I try to combine it with Cython to make a extension it doesn't work.
I've been working on the problem with the Gambit-C folks and was
hoping there might be some suggestions on the Python side. I've
attached my code -- just run make. To run the standalone created by
Cython:
$ ./server_setup
-----------------------------------------------------------------------------------------------------------------
Here's a typical Python session:
Process Python finished
Python 2.7.1 (r271:86832, Dec 29 2010, 01:38:09)
Type "copyright", "credits" or "license" for more information.
IPython 0.10.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints
more.
In [2]: import gambit
In [3]: gambit.cleanup ()
Gambit-C cleanup complete
In [4]: gambit.setup ()
Gambit-C setup successful
In [5]: gambit.cleanup ()
Process Python exited abnormally with code 1
-----------------------------------------------------------------------------------------------------------------
This is on OS X 10.6.6 with gcc-4.2, Cython 0.14, Python 2.7.1 and
Gambit-C 4.6.0 from git. To install Gambit-C see:
http://dynamo.iro.umontreal.ca/~gambit/wiki/index.php/Contributing_Patches_to_Gambit_Source_Code
or maybe
http://www.iro.umontreal.ca/~gambit/download/gambit/v4.6/prebuilt/
though I'm using the above. Macports might work also.
The code for this is here:
https://docs.google.com/leaf?id=0B4PJONnq-MgAZGNiZTg4ZGUtNmRmYy00ZGE4LTgxNjMtMzY3NmRkMDM5MWE2&hl=en&authkey=CPzbuq4C
I should mention that neither printf nor sleep work if, e.g., I
modify the Gambit-C source code like the following (in
gambit/lib/setup.c):
___EXP_FUNC(void,___cleanup) ___PVOID
{
/*
* Only do cleanup once after successful setup.
*/
printf ("setup_state : %i \n" , setup_state);
fflush (stdout);
sleep(30);
if (setup_state != 1)
return;
setup_state = 2;
___cleanup_mem ();
___cleanup_os ();
}
Thanks!
-Dave