[C++-sig] Re: compile errors with embedding example from tutorial

Chad Austin caustin at gmail.com
Fri Jul 2 18:48:43 CEST 2004


Heh, I've run into that problem before too.  You may have to do the
import with PyImport_Import or whatever it is.  (The C equivalent of
__import__)

Oddly enough, I'm not seeing any of the problems you are.  See the
attached files.  Works fine for me.

Chad at basilisk ~/tmp/bp
$ scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
g++ -DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_NO_TEMPLATE_EXPORT -I/usr/local/inc
lude/boost-1_31 -I/usr/include/python2.3 -c -o hello.os hello.cpp
g++ -shared -o hello.dll hello.os -L/usr/lib/python2.3/config -L/usr/local/lib -
lboost_python-gcc -lpython2.3
scons: done building targets.

Chad at basilisk ~/tmp/bp
$ python
Python 2.3.4 (#1, Jun 13 2004, 11:21:03)
[GCC 3.3.1 (cygming special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import hello
>>> w = hello.World()
>>> w.run()
>>> import os
>>> os.system('cat hello.txt')
Hello world!0
>>>


On Fri, 2 Jul 2004 16:18:59 +0000 (UTC), Faheem Mitha
<faheem at email.unc.edu> wrote:
> 
> On Fri, 2 Jul 2004 10:43:29 -0500, Chad Austin <caustin at gmail.com> wrote:
> > Now that I think about it, perhaps your extension module doesn't have
> > direct access to the builtins, while __main__ does.  Try changing your
> > hard-coded script to:
> >
> >           "from __builtin__ import *\n"
> >           "hello = file('hello.txt', 'w')\n"
> >           "hello.write('Hello world!')\n"
> >           "hello.close()"
> 
> I've tried this already.  I think someone else suggested this. I get
> (after building with bjam):
> 
> **************************************************************************
> In [1]: import embed_ext
> 
> In [2]: embed_ext.foo()
> ---------------------------------------------------------------------------
> ImportError                               Traceback (most recent call last)
> 
> /usr/local/src/boost/boost-1.31.0/libs/python/example/
> bin/example/embed_ext.so/gcc/debug/shared-linkable-true/<console>
> 
> /usr/local/src/boost/boost-1.31.0/libs/python/example/
> bin/example/embed_ext.so/gcc/debug/shared-linkable-true/<string>
> 
> ImportError: __import__ not found
> 
> **************************************************************************
> 
> I don't know what this means. :-( . Perhaps simply that it does not
> have the `import' builtin available to import `__builtin__'. :-) Have
> you been able to reproduce any of these results? Thanks.
> 
> 
> 
>                                                                        Faheem.
> 
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
> 


-- 
Chad Austin
http://aegisknight.org/
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: hello.cpp
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20040702/a8383820/attachment.txt>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SConstruct
Type: application/octet-stream
Size: 419 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20040702/a8383820/attachment.obj>


More information about the Cplusplus-sig mailing list