Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #71964

Re: Loading modules from files through C++

Date 2014-05-24 16:48 +0200
From Roland Plüss <roland@rptd.ch>
Subject Re: Loading modules from files through C++
References (10 earlier) <53790CCF.1070905@rptd.ch> <CAPTjJmrOeSsmoxqk8iCL2tKEX9Qa1yHBLzfbfvNr_7Ap+AP6pg@mail.gmail.com> <537B8E31.7000607@rptd.ch> <CAPTjJmrnjrfhd=nLKogVkdsm-_KzG6mRKrFbCVYhaXdv6-Ortw@mail.gmail.com> <537D2433.7080606@rptd.ch>
Newsgroups comp.lang.python
Message-ID <mailman.10263.1400942910.18130.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

> # CODE #
> PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, NULL, NULL, 0, NULL,
> NULL, NULL, NULL, NULL };
>
> moduledef.m_name = "MyModule";
> moduledef.m_doc = "MyModule";
> pModule = PyModule_Create( &moduledef );
> PyState_AddModule( pModule, &moduledef );
>
> PyRun_SimpleString( "print( globals() )\n" );
> PyRun_SimpleString( "import MyModule\nprint( globals() )\n" );
> # CODE #
>
> yields this:
>
> {'__name__': '__main__', '__builtins__': <module 'builtins' (built-in)>,
> '__doc__': None, '__loader__': <class
> '_frozen_importlib.BuiltinImporter'>, '__package__': None}
> Traceback (most recent call last):
>   File "<string>", line 1, in <module>
> ImportError: No module named 'MyModule'
>
Anybody got an idea? Somebody has a working example where he create a
valid module from C++? It's just a namespace not even yet script sources
applied.

-- 
Yours sincerely
Plüss Roland

Leader and Head Programmer
- Game: Epsylon ( http://www.indiedb.com/games/epsylon )
- Game Engine: Drag[en]gine ( http://www.indiedb.com/engines/dragengine
, http://dragengine.rptd.ch/wiki )
- Normal Map Generator: DENormGen ( http://epsylon.rptd.ch/denormgen.php )
- As well as various Blender export scripts und game tools

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Loading modules from files through C++ Roland Plüss <roland@rptd.ch> - 2014-05-24 16:48 +0200

csiph-web