[Pythonmac-SIG] error trying to run c extension from carbon Python

Jack Jansen Jack.Jansen@oratrix.com
Thu, 20 Jun 2002 22:16:34 +0200


Stephen,
are you extending Python (building a new module to be imported) 
or embedding Python (putting the whole interpreter into another 
program)?

Some of the things you mention are used for embedding only 
(calls to PyMac_Initialize and such) but in other places you're 
referrring to failures to import something.

If you're extending Python: you don't need to recompile anything 
(except your extension module, of course), if you take the 
standard MacPython binary installer and also select the 
"developer" option (not selected with the easy install) you 
should be all set. If you also use distutils to build your 
extension you should have no problems whatsoever.

If you're embedding Python you may not need source either: you 
just call PyMac_Initialize() and then you can do any call you 
want. You want to read both the "embedding" section of the 
standard Python docs and :Mac:Demo:embed.html from the MacPython 
distribution.

On woensdag, juni 19, 2002, at 07:53 , Magladry, Stephen wrote:

> I am trying to run a c extension for a build of Python Carbon 
> and when I try
> to import the c extension, I get a "Interpreter not initialized 
> (version
> mismatch?)" error. Here's a run down of what I have done.
>
> 1. Tried to use stock Carbon Python. It isn't even able to import a new
> sample library. It come back with a syntax error, some kind of 
> stdin error
> if I remember correctly.
> 2. Needed to modify the Carbon project. As built, It doesn't 
> support Dynamic
> Loading. I added the three options USE_MAC_SHARED_LIBRARIES,
> USE_MAC_APPLETE_SUPPORT and  HAVE_DYNAMIC_LOADING.
> 2.5 Also use the call PYMac_Initialize() instead of PY_Initialize().
> 3. Add the necessary supporting c files in order to get Carbon 
> Python with
> the above library support linking.
> 3.5 Use dyload_mac.c in place of dynload_stub.c.
> 4. Rebuild PythonCarbonCore using the config.h files as the 
> above project.
> 5. Build a simple c extension that weak links to the newly created
> PythonCarbonCore.
> 6. Move the new created, PythonCarbonApp, PythonCarbonCore and 
> myLibrary to
> the same folder.
> 7. Fire up The Python interpreter.
> 8. Enter the command Import myLibrary, with the library file named
> "myLibrary.carbon.slb".
> 9. Get the error "Interpreter not initialized (version mismatch?)".
>
> I have stepped through the code at the interpreter level and 
> the last line
> of code that gets executed, at least at the interpreter level is
> GetDiskFragment, line 86 in dynload_mac.c. If I try to step 
> over this line
> of code, I get the error.
>
> Questions:
>
> 1. Anyone know why I'm getting this error? It doesn't seem like 
> I have a
> version mismatch since everything is running off the same code base.
> 2. Does anyone see something glaring that I have done wrong?
> 3. Has anyone been able to set up a Python Carbon that is able 
> to call c
> extensions?
> 4. Is it even possible in the current state to have the Carbon 
> code call a c
> extensions?
>
>
> Thanks for your time,
>
>
> Stephen Magladry
>
>
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
>
--
- 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 -